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

Support more than one channel when masking background #639

Conversation

franziskamoos
Copy link
Contributor

@franziskamoos franziskamoos commented Jan 17, 2024

The original code could only work with one channel input for masking the background. This commit adds support for more than one channel.

Checklist before merging

  • I added an appropriate entry to CHANGELOG.md

Closes #640

The orginal code could only work with one channel input. This commit adds support for more than one channel.
@franziskamoos
Copy link
Contributor Author

This is the error we got without the fix:

2024-01-16 14:49:41,035; INFO; Now processing ROI 1/3
2024-01-16 14:49:41,118; INFO; [_preprocess_input] image_array.shape=(2, 18, 296, 316)
2024-01-16 14:49:41,118; INFO; [_preprocess_input] region=(slice(0, 18, None), slice(36, 332, None), slice(140, 456, None))
2024-01-16 14:49:41,131; INFO; [_preprocess_input] ROI_table_path='/path/230828CS001AAA48h.zarr/B/02/0/tables/organoid_ROI_table'
2024-01-16 14:49:41,131; INFO; [_preprocess_input] attrs.asdict()={'encoding-type': 'anndata', 'encoding-version': '0.1.0', 'instance_key': 'label', 'region': {'path': '../labels/organoids'}, 'type': 'ngff:region_table'}
/code/fractal-tasks-core/fractal_tasks_core/tables/v1.py:41: FutureWarning: Table type `ngff:region_table` is currently accepted instead of `masking_roi_table`, but it will be deprecated in the future. Please switch to `type='masking_roi_table'`.
  warnings.warn(warning_msg, FutureWarning)
2024-01-16 14:49:41,132; INFO; masking_label_path='/path/230828CS001AAA48h.zarr/B/02/0/tables/../labels/organoids/0'
2024-01-16 14:49:41,133; INFO; [_preprocess_input] masking_label_path='/path/230828CS001AAA48h.zarr/B/02/0/tables/../labels/organoids/0', masking_label_array.shape=(18, 540, 640)
2024-01-16 14:49:41,134; INFO; [_preprocess_input] current_label_path='/path/230828CS001AAA48h.zarr/B/02/0/labels/Organoids_test/0', current_label_array.shape=(18, 2160, 2560)
2024-01-16 14:49:41,146; INFO; Upscaling of masking label is needed
2024-01-16 14:49:41,163; INFO; background_4D.shape=(1, 18, 296, 316)
Traceback (most recent call last):
  File "/code/cellpose_2D3D_merging/src/cellpose_2d3d_merging/cellpose_2D3D_merging.py", line 918, in <module>
    run_fractal_task(
  File "/code/fractal-tasks-core/fractal_tasks_core/tasks/_utils.py", line 79, in run_fractal_task
    metadata_update = task_function(**pars)
  File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
  File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
  File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
  File "/code/cellpose_2D3D_merging/src/cellpose_2d3d_merging/cellpose_2D3D_merging.py", line 806, in cellpose_segmentation
    new_label_img = masked_loading_wrapper(
  File "/code/fractal-tasks-core/fractal_tasks_core/masked_loading.py", line 238, in masked_loading_wrapper
    ) = _preprocess_input(image_array, **preprocessing_kwargs)
  File "/code/fractal-tasks-core/fractal_tasks_core/masked_loading.py", line 175, in _preprocess_input
    image_array[background_4D] = 0
IndexError: boolean index did not match indexed array along dimension 0; dimension is 2 but corresponding boolean dimension is 1

@jluethi
Copy link
Collaborator

jluethi commented Jan 17, 2024

Thanks a lot for reporting this and providing a fix for it!

@tcompa Can we reproduce this in our current test cases with a dual channel image and include a (currently failing) test that then gets solved by this PR?

@tcompa
Copy link
Collaborator

tcompa commented Jan 18, 2024

Can we reproduce this in our current test cases with a dual channel image and include a (currently failing) test that then gets solved by this PR?

Done.


Thanks a lot @FranziskaMoos-FMI!

@tcompa tcompa merged commit 222679f into fractal-analytics-platform:main Jan 18, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix masked-loading when using two channels in cellpose task.
3 participants