-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add 2D support for Cellpose & napari workflows task (closes #398) #403
Conversation
Coverage reportThe coverage rate went from
Diff Coverage details (click to unfold)fractal_tasks_core/lib_regions_of_interest.py
fractal_tasks_core/tasks/cellpose_segmentation.py
fractal_tasks_core/tasks/napari_workflows_wrapper.py
fractal_tasks_core/lib_zattrs_utils.py
fractal_tasks_core/init.py
|
Now added a workaround to handle coordinateTransformations that follow the spec better than us, see #420 (comment) |
|
It does work, see #398 (comment) |
If you run a ValueError('Something wrong: label_shape=(540, 1280) but expected_dimensions=3') (as verified with the new test_napari_workflow_CYX_wrong_dimensions test). Are there other useful checks that come to mind? |
Should we include a test that a 3D input with the z dimension > 1 fails when we set Let's not go too deep here though. I think when doing the axes refactor, we may want to reconsider whether expected_dimensions is a parameter that really needs to be exposed to the user |
We already had the following cases = [
(2, 2, True),
(2, 3, False),
(3, 3, True),
(3, 2, True),
]
@pytest.mark.parametrize(
"expected_dimensions,zarr_dimensions,expected_success", cases
)
def test_expected_dimensions(
expected_dimensions: int,
zarr_dimensions: int,
expected_success: bool,
tmp_path: Path,
testdata_path: Path,
zenodo_zarr: List[str],
zenodo_zarr_metadata: List[Dict[str, Any]],
):
# Prepare zarr
zarr_path = tmp_path / "tmp_out/"
if zarr_dimensions == 2:
metadata = prepare_2D_zarr(
str(zarr_path),
zenodo_zarr,
zenodo_zarr_metadata,
remove_labels=True,
)
else:
metadata = prepare_3D_zarr(
str(zarr_path), zenodo_zarr, zenodo_zarr_metadata
)
debug(zarr_path)
debug(metadata)
# First napari-workflows task (labeling)
workflow_file = str(
testdata_path / "napari_workflows/wf_5-labeling_only.yaml"
)
input_specs: Dict[str, Dict[str, Union[str, int]]] = {
"input_image": {"type": "image", "wavelength_id": "A01_C01"},
}
output_specs: Dict[str, Dict[str, Union[str, int]]] = {
"output_label": {
"type": "label",
"label_name": "label_DAPI",
},
}
for component in metadata["image"]:
arguments = dict(
input_paths=[str(zarr_path)],
output_path=str(zarr_path),
metadata=metadata,
component=component,
input_specs=input_specs,
output_specs=output_specs,
workflow_file=workflow_file,
input_ROI_table="FOV_ROI_table",
level=3,
expected_dimensions=expected_dimensions,
)
if expected_success:
napari_workflows_wrapper(**arguments)
else:
with pytest.raises(ValueError):
napari_workflows_wrapper(**arguments) which I can tweak to also include the CYX case. |
Done now (461c5de), with this list of cases
|
Adding support to process 2D OME-Zarr files with the Cellpose & napari workflows task.
The resulting label images by cellpose are always 3D arrays. If the input image was 2 dimensional, it's of shape (1, shape_y, shape_x).
What still needs to be done:
expected_dimensions
and if there are weird edge cases thereI want to cover 1 & 2 for this PR. Point 3 may be moved to another issue => #411