Skip to content

Commit 9ab60cd

Browse files
committed
Expose z chunking options & improve defaults. Closes #21
1 parent de7c200 commit 9ab60cd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/fractal_helper_tasks/__FRACTAL_MANIFEST__.json

+5
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@
116116
"type": "string",
117117
"description": "If the image name between 2D & 3D don't match, this is the suffix that should be added to the 3D image. If the 2D image is in \"/path/to/my_plate_mip.zarr/B/03/0\" and the 3D image is in \"/path/to/my_plate.zarr/B/03/0_illum_corr\", the value should be \"_illum_corr\"."
118118
},
119+
"z_chunks": {
120+
"title": "Z Chunks",
121+
"type": "integer",
122+
"description": "Chunking for the Z dimension"
123+
},
119124
"overwrite": {
120125
"default": false,
121126
"title": "Overwrite",

src/fractal_helper_tasks/convert_2D_segmentation_to_3D.py

+9
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def convert_2D_segmentation_to_3D(
9999
plate_suffix: str = "_mip",
100100
image_suffix_2D_to_remove: Optional[str] = None,
101101
image_suffix_3D_to_add: Optional[str] = None,
102+
z_chunks: Optional[int] = None,
102103
overwrite: bool = False,
103104
) -> None:
104105
"""Convert 2D segmentation to 3D segmentation.
@@ -141,6 +142,7 @@ def convert_2D_segmentation_to_3D(
141142
If the 2D image is in "/path/to/my_plate_mip.zarr/B/03/0" and the
142143
3D image is in "/path/to/my_plate.zarr/B/03/0_illum_corr", the
143144
value should be "_illum_corr".
145+
z_chunks: Chunking for the Z dimension
144146
overwrite: If `True`, overwrite existing label and ROI tables in the
145147
3D OME-Zarr
146148
"""
@@ -179,6 +181,13 @@ def convert_2D_segmentation_to_3D(
179181
with zarr.open(zarr_3D_url, mode="rw+") as zarr_img:
180182
zarr_3D = da.from_zarr(zarr_img[0])
181183
new_z_planes = zarr_3D.shape[-3]
184+
z_chunk_3d = zarr_3D.chunksize[-3]
185+
186+
# TODO: Improve axis detection in ngio refactor?
187+
if z_chunks:
188+
chunks[-3] = z_chunks
189+
else:
190+
chunks[-3] = z_chunk_3d
182191

183192
image_meta = load_NgffImageMeta(zarr_3D_url)
184193
z_pixel_size = image_meta.get_pixel_sizes_zyx(level=0)[0]

0 commit comments

Comments
 (0)