Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow channel fix and cropping fix #23

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions src/napari_ndev/_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ def batch_utilities(

image_list = os.listdir(image_directory)

img = AICSImage(image_directory / image_list[0])

all_x, all_y, all_z = False, False, False
if X_range == slice(0, img.dims.X, 1):
all_x = True
if Y_range == slice(0, img.dims.Y, 1):
all_y = True
if Z_range == slice(0, img.dims.Z, 1):
all_z = True

for file in tqdm(image_list, label="file"):
result_stack = None
img = AICSImage(image_directory / file)
Expand Down Expand Up @@ -148,6 +158,13 @@ def batch_utilities(
)

# T C Z Y X default from aicsimageio
if all_x is True:
X_range = slice(0, img.dims.X, 1)
if all_y is True:
Y_range = slice(0, img.dims.Y, 1)
if all_z is True:
Z_range = slice(0, img.dims.Z, 1)

ch_img = ch_img[:, :, Z_range, Y_range, X_range]

# project along the Z axis (2)
Expand Down Expand Up @@ -380,17 +397,21 @@ def batch_workflow(
image_stack = []
img = AICSImage(image_directory / file)

"""for each root selected in the root list, extract the channel image
and set the workflow root names, this will be used later for workflow.get
"""
for idx, root in enumerate(root_list):
ch_img = _get_channel_image(img=img, dims=img_dims, channel=root)

ch_img = _get_channel_image(
img=img, dims=img_dims, channel=root)
print(ch_img.shape)
wf.set(name=wf.roots()[idx], func_or_data=ch_img)

image_stack.append(ch_img)

# dask_stack = da.stack(image_stack, axis=0)

result = wf.get(name=wf.leafs())
result_stack = cle.pull(result)
result_stack = cle.pull(result) # adds a new dim at 0th axis, as "C"

"""extract the leaf name corresponding to each root to save into
channel names
Expand All @@ -407,6 +428,8 @@ def batch_workflow(
result_stack = da.concatenate([dask_images, dask_result], axis=0)
result_names = root_list + result_names

# print(result_stack.shape)

save_name = str(file + ".ome.tif")
save_uri = result_directory / save_name

Expand Down
Loading