# -*- coding: utf-8 -*-
"""
Created on Thu Dec 11 15:23:13 2025

@author: Jiawen

This script produces a zstack using gfp images at a given phase. 
The zstack would be useful for constructing 3D strcuture, and taking cross sectional planes

"""


import config
from functions import *
import glob
import tifffile
#%%
phase = 5.8+4.2
stack2gfptif = glob.glob(config.stack2gfp_image)
stack2gfpp_list = glob.glob(config.stack2gfp_plist)

stack2plist = []
stack2plist = load_plist(stack2gfpp_list)
#%%
zpos = get_z_pos(stack2plist)
wall_stack = []
for z in zpos:
    frame = closest_wall(stack2gfptif, stack2plist, z, 0.05, phase)
    wall_stack.append(frame)

filename = 'phase_'+str(phase)+'gfpstack.tif'
tifffile.imwrite(filename, wall_stack)

