ngio 0.2.0a3__tar.gz → 0.2.0b1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ngio-0.2.0a3 → ngio-0.2.0b1}/.gitignore +3 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/PKG-INFO +4 -1
- {ngio-0.2.0a3 → ngio-0.2.0b1}/docs/notebooks/basic_usage.ipynb +5 -39
- {ngio-0.2.0a3 → ngio-0.2.0b1}/pyproject.toml +10 -23
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/__init__.py +4 -4
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/common/__init__.py +12 -2
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/common/_array_pipe.py +106 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/common/_axes_transforms.py +3 -2
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/common/_dimensions.py +7 -0
- ngio-0.2.0b1/src/ngio/common/_masking_roi.py +158 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/common/_pyramid.py +16 -11
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/common/_roi.py +74 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/common/_slicer.py +1 -2
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/common/_zoom.py +5 -3
- ngio-0.2.0b1/src/ngio/hcs/__init__.py +5 -0
- ngio-0.2.0b1/src/ngio/hcs/plate.py +399 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/images/abstract_image.py +97 -28
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/images/create.py +48 -29
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/images/image.py +99 -46
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/images/label.py +109 -92
- ngio-0.2.0b1/src/ngio/images/masked_image.py +259 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/images/omezarr_container.py +201 -64
- ngio-0.2.0b1/src/ngio/ome_zarr_meta/__init__.py +47 -0
- ngio-0.2.0b1/src/ngio/ome_zarr_meta/_meta_handlers.py +791 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/ome_zarr_meta/ngio_specs/__init__.py +8 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/ome_zarr_meta/ngio_specs/_channels.py +11 -0
- ngio-0.2.0b1/src/ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py +377 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/ome_zarr_meta/ngio_specs/_ngio_image.py +169 -119
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/ome_zarr_meta/ngio_specs/_pixel_size.py +35 -3
- ngio-0.2.0b1/src/ngio/ome_zarr_meta/v04/__init__.py +23 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/ome_zarr_meta/v04/_v04_spec_utils.py +85 -12
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/__init__.py +2 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/_validators.py +2 -4
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/backends/_anndata_utils.py +2 -1
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/backends/_anndata_v1.py +2 -1
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/backends/_json_v1.py +1 -1
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/tables_container.py +12 -2
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/v1/__init__.py +1 -2
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/v1/_feature_table.py +7 -5
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/v1/_generic_table.py +65 -11
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/v1/_roi_table.py +145 -27
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/utils/_datasets.py +4 -2
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/utils/_fractal_fsspec_store.py +3 -2
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/utils/_logger.py +3 -1
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/utils/_zarr_utils.py +25 -2
- ngio-0.2.0b1/tests/conftest.py +40 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_c1yx.zarr/.zattrs +86 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_c1yx.zarr/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_c1yx.zarr/0/.zarray +27 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_c1yx.zarr/1/.zarray +27 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_c1yx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_c1yx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_c1yx.zarr/labels/label/.zattrs +59 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_c1yx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_c1yx.zarr/labels/label/0/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_c1yx.zarr/labels/label/1/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_cyx.zarr/.zattrs +79 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_cyx.zarr/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_cyx.zarr/0/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_cyx.zarr/1/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_cyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_cyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_cyx.zarr/labels/label/.zattrs +52 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_cyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_cyx.zarr/labels/label/0/.zarray +23 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_cyx.zarr/labels/label/1/.zarray +23 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_czyx.zarr/.zattrs +86 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_czyx.zarr/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_czyx.zarr/0/.zarray +27 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_czyx.zarr/1/.zarray +27 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_czyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_czyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_czyx.zarr/labels/label/.zattrs +59 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_czyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_czyx.zarr/labels/label/0/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_czyx.zarr/labels/label/1/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tcyx.zarr/.zattrs +86 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tcyx.zarr/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tcyx.zarr/0/.zarray +27 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tcyx.zarr/1/.zarray +27 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tcyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tcyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tcyx.zarr/labels/label/.zattrs +59 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tcyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tcyx.zarr/labels/label/0/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tcyx.zarr/labels/label/1/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tczyx.zarr/.zattrs +93 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tczyx.zarr/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tczyx.zarr/0/.zarray +29 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tczyx.zarr/1/.zarray +29 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tczyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tczyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tczyx.zarr/labels/label/.zattrs +66 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tczyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tczyx.zarr/labels/label/0/.zarray +27 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tczyx.zarr/labels/label/1/.zarray +27 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tyx.zarr/.zattrs +68 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tyx.zarr/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tyx.zarr/0/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tyx.zarr/1/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tyx.zarr/labels/label/.zattrs +59 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tyx.zarr/labels/label/0/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tyx.zarr/labels/label/1/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tzyx.zarr/.zattrs +75 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tzyx.zarr/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tzyx.zarr/0/.zarray +27 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tzyx.zarr/1/.zarray +27 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tzyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tzyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tzyx.zarr/labels/label/.zattrs +66 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tzyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tzyx.zarr/labels/label/0/.zarray +27 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_tzyx.zarr/labels/label/1/.zarray +27 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_yx.zarr/.zattrs +61 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_yx.zarr/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_yx.zarr/0/.zarray +23 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_yx.zarr/1/.zarray +23 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_yx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_yx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_yx.zarr/labels/label/.zattrs +52 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_yx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_yx.zarr/labels/label/0/.zarray +23 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_yx.zarr/labels/label/1/.zarray +23 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_zyx.zarr/.zattrs +68 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_zyx.zarr/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_zyx.zarr/0/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_zyx.zarr/1/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_zyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_zyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_zyx.zarr/labels/label/.zattrs +59 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_zyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_zyx.zarr/labels/label/0/.zarray +25 -0
- ngio-0.2.0b1/tests/data/v04/images/test_image_zyx.zarr/labels/label/1/.zarray +25 -0
- ngio-0.2.0b1/tests/unit/hcs/test_plate.py +57 -0
- ngio-0.2.0b1/tests/unit/images/test_create.py +128 -0
- ngio-0.2.0b1/tests/unit/images/test_images.py +25 -0
- ngio-0.2.0b1/tests/unit/images/test_masked_images.py +73 -0
- ngio-0.2.0b1/tests/unit/images/test_omezarr_container.py +155 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/tests/unit/tables/test_backends.py +7 -5
- {ngio-0.2.0a3 → ngio-0.2.0b1}/tests/unit/tables/test_feature_table.py +1 -1
- ngio-0.2.0b1/tests/unit/tables/test_generic_table.py +56 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/tests/unit/tables/test_masking_roi_table_v1.py +1 -1
- ngio-0.2.0b1/tests/unit/tables/test_table_group.py +34 -0
- ngio-0.2.0b1/tests/unit/test_ome_zarr_meta/test_image_handler.py +15 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/tests/unit/test_ome_zarr_meta/test_unit_ngio_specs.py +12 -4
- {ngio-0.2.0a3 → ngio-0.2.0b1}/tests/unit/test_ome_zarr_meta/test_unit_v04_utils.py +2 -2
- ngio-0.2.0a3/src/ngio/hcs/__init__.py +0 -60
- ngio-0.2.0a3/src/ngio/ome_zarr_meta/__init__.py +0 -35
- ngio-0.2.0a3/src/ngio/ome_zarr_meta/_generic_handlers.py +0 -320
- ngio-0.2.0a3/src/ngio/ome_zarr_meta/_meta_handlers.py +0 -142
- ngio-0.2.0a3/src/ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py +0 -5
- ngio-0.2.0a3/src/ngio/ome_zarr_meta/v04/__init__.py +0 -11
- ngio-0.2.0a3/src/ngio/ome_zarr_meta/v04/_meta_handlers.py +0 -54
- ngio-0.2.0a3/src/ngio/tables/v1/_masking_roi_table.py +0 -175
- ngio-0.2.0a3/tests/conftest.py +0 -11
- ngio-0.2.0a3/tests/unit/images/test_omezarr_container.py +0 -98
- ngio-0.2.0a3/tests/unit/tables/test_generic_table.py +0 -24
- ngio-0.2.0a3/tests/unit/tables/test_table_group.py +0 -9
- ngio-0.2.0a3/tests/unit/test_ome_zarr_meta/test_image_handler.py +0 -13
- {ngio-0.2.0a3 → ngio-0.2.0b1}/.copier-answers.yml +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/.gitattributes +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/.github/ISSUE_TEMPLATE.md +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/.github/TEST_FAIL_TEMPLATE.md +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/.github/dependabot.yml +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/.github/workflows/build_docs.yml +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/.github/workflows/ci.yml +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/.pre-commit-config.yaml +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/LICENSE +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/README.md +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/_typos.toml +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/docs/api/core.md +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/docs/getting-started.md +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/docs/index.md +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/docs/notebooks/image.ipynb +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/docs/notebooks/processing.ipynb +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/mkdocs.yml +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/common/_common_types.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/images/__init__.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/ome_zarr_meta/ngio_specs/_axes.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/ome_zarr_meta/ngio_specs/_dataset.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/backends/__init__.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/backends/_abstract_backend.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/tables/backends/_table_backends.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/utils/__init__.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/src/ngio/utils/_errors.py +0 -0
- {ngio-0.2.0a3/tests/data/meta_v04 → ngio-0.2.0b1/tests/data/v04/meta}/base_ome_zarr_image_meta.json +0 -0
- {ngio-0.2.0a3/tests/data/meta_v04 → ngio-0.2.0b1/tests/data/v04/meta}/base_ome_zarr_image_meta_wrong_axis_order.json +0 -0
- {ngio-0.2.0a3/tests/data/meta_v04 → ngio-0.2.0b1/tests/data/v04/meta}/base_ome_zarr_label_meta.json +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/tests/unit/common/test_dimensions.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/tests/unit/common/test_pyramid.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/tests/unit/common/test_roi.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/tests/unit/tables/test_roi_table_v1.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/tests/unit/tables/test_validators.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/tests/unit/utils/test_download_datasets.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b1}/tests/unit/utils/test_zarr_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ngio
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.0b1
|
|
4
4
|
Summary: Next Generation file format IO
|
|
5
5
|
Project-URL: homepage, https://github.com/lorenzocerrone/ngio
|
|
6
6
|
Project-URL: repository, https://github.com/lorenzocerrone/ngio
|
|
@@ -29,6 +29,7 @@ Requires-Dist: requests
|
|
|
29
29
|
Requires-Dist: xarray
|
|
30
30
|
Requires-Dist: zarr<3
|
|
31
31
|
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: devtools; extra == 'dev'
|
|
32
33
|
Requires-Dist: matplotlib; extra == 'dev'
|
|
33
34
|
Requires-Dist: mypy; extra == 'dev'
|
|
34
35
|
Requires-Dist: napari; extra == 'dev'
|
|
@@ -38,6 +39,7 @@ Requires-Dist: pre-commit; extra == 'dev'
|
|
|
38
39
|
Requires-Dist: pyqt5; extra == 'dev'
|
|
39
40
|
Requires-Dist: rich; extra == 'dev'
|
|
40
41
|
Requires-Dist: ruff; extra == 'dev'
|
|
42
|
+
Requires-Dist: scikit-image; extra == 'dev'
|
|
41
43
|
Provides-Extra: docs
|
|
42
44
|
Requires-Dist: mkdocs; extra == 'docs'
|
|
43
45
|
Requires-Dist: mkdocs-autorefs; extra == 'docs'
|
|
@@ -50,6 +52,7 @@ Requires-Dist: scikit-image; extra == 'docs'
|
|
|
50
52
|
Provides-Extra: test
|
|
51
53
|
Requires-Dist: pytest; extra == 'test'
|
|
52
54
|
Requires-Dist: pytest-cov; extra == 'test'
|
|
55
|
+
Requires-Dist: scikit-image; extra == 'test'
|
|
53
56
|
Description-Content-Type: text/markdown
|
|
54
57
|
|
|
55
58
|
# NGIO - Next Generation file format IO
|
|
@@ -86,10 +86,10 @@
|
|
|
86
86
|
"print(image)\n",
|
|
87
87
|
"\n",
|
|
88
88
|
"# 3. Get image from a specific pixel size using the pixel_size keyword\n",
|
|
89
|
-
"image = omezarr_container.get_image(\n",
|
|
90
|
-
" pixel_size=PixelSize(x=0.65, y=0.65, z=
|
|
91
|
-
")\n",
|
|
92
|
-
"print(image)"
|
|
89
|
+
"# image = omezarr_container.get_image(\n",
|
|
90
|
+
"# pixel_size=PixelSize(x=0.65, y=0.65, z=1), strict=True\n",
|
|
91
|
+
"# )\n",
|
|
92
|
+
"print(image.pixel_size == PixelSize(x=0.325, y=0.325, z=1))"
|
|
93
93
|
]
|
|
94
94
|
},
|
|
95
95
|
{
|
|
@@ -287,6 +287,7 @@
|
|
|
287
287
|
"metadata": {},
|
|
288
288
|
"outputs": [],
|
|
289
289
|
"source": [
|
|
290
|
+
"import fsspec\n",
|
|
290
291
|
"import fsspec.implementations.http\n",
|
|
291
292
|
"\n",
|
|
292
293
|
"url = (\n",
|
|
@@ -298,7 +299,6 @@
|
|
|
298
299
|
"\n",
|
|
299
300
|
"fs = fsspec.implementations.http.HTTPFileSystem(client_kwargs={})\n",
|
|
300
301
|
"store = fs.get_mapper(url)\n",
|
|
301
|
-
"\n",
|
|
302
302
|
"omezarr = open_omezarr_container(store)\n",
|
|
303
303
|
"omezarr"
|
|
304
304
|
]
|
|
@@ -319,40 +319,6 @@
|
|
|
319
319
|
"omezarr\n",
|
|
320
320
|
"```"
|
|
321
321
|
]
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
"cell_type": "code",
|
|
325
|
-
"execution_count": null,
|
|
326
|
-
"metadata": {},
|
|
327
|
-
"outputs": [],
|
|
328
|
-
"source": [
|
|
329
|
-
"from ngio import open_omezarr_container\n",
|
|
330
|
-
"from ngio.utils import fractal_fsspec_store\n",
|
|
331
|
-
"\n",
|
|
332
|
-
"store = fractal_fsspec_store(\n",
|
|
333
|
-
" url=\"https://fractal.mls.uzh.ch/vizarr/data/data/active/lorcerr/fractal/104_altmeyer_10097/443_experiment3/AP411_U2OS.zarr/A/1/0\",\n",
|
|
334
|
-
" fractal_token=\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI0MCIsImF1ZCI6WyJmYXN0YXBpLXVzZXJzOmF1dGgiXSwiZXhwIjoxNzQxMzY1NzY2fQ.wnpJSL6rtkKIoFeW7D31sVpEXeDcD0VrahwbF4CGbNI\",\n",
|
|
335
|
-
")\n",
|
|
336
|
-
"omezarr = open_omezarr_container(store)\n",
|
|
337
|
-
"print(omezarr)\n",
|
|
338
|
-
"print(omezarr.get_image(path=\"3\").get_array())"
|
|
339
|
-
]
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
"cell_type": "code",
|
|
343
|
-
"execution_count": null,
|
|
344
|
-
"metadata": {},
|
|
345
|
-
"outputs": [],
|
|
346
|
-
"source": [
|
|
347
|
-
"omezarr.get_image(path=\"3\").get_array()"
|
|
348
|
-
]
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
"cell_type": "code",
|
|
352
|
-
"execution_count": null,
|
|
353
|
-
"metadata": {},
|
|
354
|
-
"outputs": [],
|
|
355
|
-
"source": []
|
|
356
322
|
}
|
|
357
323
|
],
|
|
358
324
|
"metadata": {
|
|
@@ -51,18 +51,20 @@ dependencies = [
|
|
|
51
51
|
# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
|
|
52
52
|
# "extras" (e.g. for `pip install .[test]`)
|
|
53
53
|
[project.optional-dependencies]
|
|
54
|
-
test = ["pytest", "pytest-cov"]
|
|
54
|
+
test = ["pytest", "pytest-cov", "scikit-image"]
|
|
55
55
|
|
|
56
56
|
dev = [
|
|
57
57
|
"napari",
|
|
58
58
|
"pyqt5",
|
|
59
59
|
"matplotlib",
|
|
60
|
+
"devtools",
|
|
60
61
|
"notebook",
|
|
61
62
|
"mypy",
|
|
62
|
-
"pdbpp",
|
|
63
|
+
"pdbpp", # https://github.com/pdbpp/pdbpp
|
|
63
64
|
"pre-commit",
|
|
64
|
-
"rich",
|
|
65
|
+
"rich", # https://github.com/Textualize/rich
|
|
65
66
|
"ruff",
|
|
67
|
+
"scikit-image",
|
|
66
68
|
] # add anything else you like to have in your dev environment here
|
|
67
69
|
|
|
68
70
|
docs = [
|
|
@@ -212,18 +214,12 @@ test13 = { features = ["py13", "test"], solve-group = "py13" }
|
|
|
212
214
|
# dev env
|
|
213
215
|
dev = { features = ["dev", "test"], solve-group = "py11" }
|
|
214
216
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
217
|
+
[tool.pixi.tasks]
|
|
218
|
+
serve_docs = "mkdocs serve"
|
|
219
|
+
run_tests = "pytest"
|
|
220
|
+
clean_nb_data = "rm -rf ./docs/notebooks/**/*.zarr"
|
|
218
221
|
test_nb = { cmd = "jupyter-execute ./docs/notebooks/*.ipynb" }
|
|
219
|
-
|
|
220
|
-
[tool.pixi.feature.py12.tasks]
|
|
221
|
-
pytest_test12 = "pytest"
|
|
222
|
-
|
|
223
|
-
[tool.pixi.feature.py13.tasks]
|
|
224
|
-
pytest_test13 = "pytest"
|
|
225
|
-
|
|
226
|
-
[tool.pixi.feature.task-feat.tasks]
|
|
222
|
+
test = { depends-on = ["run_tests", "clean_nb_data", "test_nb"] }
|
|
227
223
|
pre_commit_install = "pre-commit install"
|
|
228
224
|
|
|
229
225
|
ruff-fix-imports = "ruff check --select I --fix"
|
|
@@ -233,12 +229,3 @@ pre-commit = { cmd = "pre-commit run --all-files", depends-on = [
|
|
|
233
229
|
"pre_commit_install",
|
|
234
230
|
"ruff-format",
|
|
235
231
|
] }
|
|
236
|
-
|
|
237
|
-
[tool.pixi.tasks]
|
|
238
|
-
serve_docs = "mkdocs serve"
|
|
239
|
-
test = { depends-on = [
|
|
240
|
-
"pytest_test11",
|
|
241
|
-
"pytest_test12",
|
|
242
|
-
"pytest_test13",
|
|
243
|
-
"test_nb",
|
|
244
|
-
] }
|
|
@@ -10,7 +10,7 @@ __author__ = "Lorenzo Cerrone"
|
|
|
10
10
|
__email__ = "lorenzo.cerrone@uzh.ch"
|
|
11
11
|
|
|
12
12
|
from ngio.common import ArrayLike, Dimensions
|
|
13
|
-
from ngio.hcs import OmeZarrPlate,
|
|
13
|
+
from ngio.hcs import OmeZarrPlate, create_empty_plate, open_omezarr_plate
|
|
14
14
|
from ngio.images import (
|
|
15
15
|
Image,
|
|
16
16
|
Label,
|
|
@@ -20,22 +20,22 @@ from ngio.images import (
|
|
|
20
20
|
open_image,
|
|
21
21
|
open_omezarr_container,
|
|
22
22
|
)
|
|
23
|
-
from ngio.ome_zarr_meta.ngio_specs import AxesSetup, PixelSize
|
|
23
|
+
from ngio.ome_zarr_meta.ngio_specs import AxesSetup, ImageInWellPath, PixelSize
|
|
24
24
|
|
|
25
25
|
__all__ = [
|
|
26
26
|
"ArrayLike",
|
|
27
27
|
"AxesSetup",
|
|
28
28
|
"Dimensions",
|
|
29
29
|
"Image",
|
|
30
|
+
"ImageInWellPath",
|
|
30
31
|
"Label",
|
|
31
32
|
"OmeZarrContainer",
|
|
32
33
|
"OmeZarrPlate",
|
|
33
|
-
"OmeZarrWell",
|
|
34
34
|
"PixelSize",
|
|
35
35
|
"create_empty_omezarr",
|
|
36
|
+
"create_empty_plate",
|
|
36
37
|
"create_omezarr_from_array",
|
|
37
38
|
"open_image",
|
|
38
39
|
"open_omezarr_container",
|
|
39
40
|
"open_omezarr_plate",
|
|
40
|
-
"open_omezarr_well",
|
|
41
41
|
]
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"""Common classes and functions that are used across the package."""
|
|
2
2
|
|
|
3
|
-
from ngio.common._array_pipe import
|
|
3
|
+
from ngio.common._array_pipe import (
|
|
4
|
+
get_masked_pipe,
|
|
5
|
+
get_pipe,
|
|
6
|
+
set_masked_pipe,
|
|
7
|
+
set_pipe,
|
|
8
|
+
)
|
|
4
9
|
from ngio.common._axes_transforms import (
|
|
5
10
|
transform_dask_array,
|
|
6
11
|
transform_list,
|
|
@@ -8,8 +13,9 @@ from ngio.common._axes_transforms import (
|
|
|
8
13
|
)
|
|
9
14
|
from ngio.common._common_types import ArrayLike
|
|
10
15
|
from ngio.common._dimensions import Dimensions
|
|
16
|
+
from ngio.common._masking_roi import compute_masking_roi
|
|
11
17
|
from ngio.common._pyramid import consolidate_pyramid, init_empty_pyramid, on_disk_zoom
|
|
12
|
-
from ngio.common._roi import RasterCooROI, WorldCooROI
|
|
18
|
+
from ngio.common._roi import RasterCooROI, WorldCooROI, roi_to_slice_kwargs
|
|
13
19
|
from ngio.common._slicer import (
|
|
14
20
|
SliceTransform,
|
|
15
21
|
compute_and_slices,
|
|
@@ -27,16 +33,20 @@ __all__ = [
|
|
|
27
33
|
"SliceTransform",
|
|
28
34
|
"WorldCooROI",
|
|
29
35
|
"compute_and_slices",
|
|
36
|
+
"compute_masking_roi",
|
|
30
37
|
"consolidate_pyramid",
|
|
31
38
|
"dask_get_slice",
|
|
32
39
|
"dask_set_slice",
|
|
33
40
|
"dask_zoom",
|
|
41
|
+
"get_masked_pipe",
|
|
34
42
|
"get_pipe",
|
|
35
43
|
"init_empty_pyramid",
|
|
36
44
|
"numpy_get_slice",
|
|
37
45
|
"numpy_set_slice",
|
|
38
46
|
"numpy_zoom",
|
|
39
47
|
"on_disk_zoom",
|
|
48
|
+
"roi_to_slice_kwargs",
|
|
49
|
+
"set_masked_pipe",
|
|
40
50
|
"set_pipe",
|
|
41
51
|
"transform_dask_array",
|
|
42
52
|
"transform_list",
|
|
@@ -158,3 +158,109 @@ def set_pipe(
|
|
|
158
158
|
)
|
|
159
159
|
else:
|
|
160
160
|
raise NgioValueError("Unknown patch type, expected numpy, dask or delayed.")
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _mask_pipe_common(
|
|
164
|
+
array: zarr.Array,
|
|
165
|
+
label_array: zarr.Array,
|
|
166
|
+
label: int,
|
|
167
|
+
*,
|
|
168
|
+
dimensions_array: Dimensions,
|
|
169
|
+
dimensions_label: Dimensions,
|
|
170
|
+
axes_order: Collection[str] | None = None,
|
|
171
|
+
mode: Literal["numpy", "dask", "delayed"] = "numpy",
|
|
172
|
+
**slice_kwargs: slice | int | Iterable[int],
|
|
173
|
+
):
|
|
174
|
+
array_patch = get_pipe(
|
|
175
|
+
array,
|
|
176
|
+
dimensions=dimensions_array,
|
|
177
|
+
axes_order=axes_order,
|
|
178
|
+
mode=mode,
|
|
179
|
+
**slice_kwargs,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
if "c" in slice_kwargs.keys():
|
|
183
|
+
# This makes the strong assumption that the
|
|
184
|
+
# user is passing the channel axis as "c"
|
|
185
|
+
# This will fail if the channel axis is queried
|
|
186
|
+
# with a different on-disk name
|
|
187
|
+
slice_kwargs.pop("c")
|
|
188
|
+
|
|
189
|
+
label_patch = get_pipe(
|
|
190
|
+
label_array,
|
|
191
|
+
dimensions=dimensions_label,
|
|
192
|
+
axes_order=axes_order,
|
|
193
|
+
mode=mode,
|
|
194
|
+
**slice_kwargs,
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
if isinstance(array_patch, np.ndarray):
|
|
198
|
+
label_patch = np.broadcast_to(label_patch, array_patch.shape)
|
|
199
|
+
elif isinstance(array_patch, dask.array.Array):
|
|
200
|
+
label_patch = dask.array.broadcast_to(label_patch, array_patch.shape)
|
|
201
|
+
else:
|
|
202
|
+
raise NgioValueError(f"Mode {mode} not yet supported for masked array.")
|
|
203
|
+
|
|
204
|
+
mask = label_patch == label
|
|
205
|
+
return array_patch, mask
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def get_masked_pipe(
|
|
209
|
+
array: zarr.Array,
|
|
210
|
+
label_array: zarr.Array,
|
|
211
|
+
label: int,
|
|
212
|
+
*,
|
|
213
|
+
dimensions_array: Dimensions,
|
|
214
|
+
dimensions_label: Dimensions,
|
|
215
|
+
axes_order: Collection[str] | None = None,
|
|
216
|
+
mode: Literal["numpy", "dask", "delayed"] = "numpy",
|
|
217
|
+
**slice_kwargs: slice | int | Iterable[int],
|
|
218
|
+
):
|
|
219
|
+
array_patch, mask = _mask_pipe_common(
|
|
220
|
+
array=array,
|
|
221
|
+
label_array=label_array,
|
|
222
|
+
label=label,
|
|
223
|
+
dimensions_array=dimensions_array,
|
|
224
|
+
dimensions_label=dimensions_label,
|
|
225
|
+
axes_order=axes_order,
|
|
226
|
+
mode=mode,
|
|
227
|
+
**slice_kwargs,
|
|
228
|
+
)
|
|
229
|
+
array_patch[~mask] = 0
|
|
230
|
+
return array_patch
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def set_masked_pipe(
|
|
234
|
+
array: zarr.Array,
|
|
235
|
+
label_array: zarr.Array,
|
|
236
|
+
label: int,
|
|
237
|
+
patch: ArrayLike,
|
|
238
|
+
*,
|
|
239
|
+
dimensions_array: Dimensions,
|
|
240
|
+
dimensions_label: Dimensions,
|
|
241
|
+
axes_order: Collection[str] | None = None,
|
|
242
|
+
**slice_kwargs: slice | int | Iterable[int],
|
|
243
|
+
):
|
|
244
|
+
if isinstance(patch, dask.array.Array):
|
|
245
|
+
mode = "dask"
|
|
246
|
+
elif isinstance(patch, np.ndarray):
|
|
247
|
+
mode = "numpy"
|
|
248
|
+
else:
|
|
249
|
+
raise NgioValueError(
|
|
250
|
+
"Mode not yet supported for masked array. Expected a numpy or dask array."
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
array_patch, mask = _mask_pipe_common(
|
|
254
|
+
array=array,
|
|
255
|
+
label_array=label_array,
|
|
256
|
+
label=label,
|
|
257
|
+
dimensions_array=dimensions_array,
|
|
258
|
+
dimensions_label=dimensions_label,
|
|
259
|
+
axes_order=axes_order,
|
|
260
|
+
mode=mode,
|
|
261
|
+
**slice_kwargs,
|
|
262
|
+
)
|
|
263
|
+
patch = np.where(mask, patch, array_patch)
|
|
264
|
+
set_pipe(
|
|
265
|
+
array, patch, dimensions=dimensions_array, axes_order=axes_order, **slice_kwargs
|
|
266
|
+
)
|
|
@@ -9,6 +9,7 @@ from ngio.ome_zarr_meta.ngio_specs._axes import (
|
|
|
9
9
|
AxesTransformation,
|
|
10
10
|
AxesTranspose,
|
|
11
11
|
)
|
|
12
|
+
from ngio.utils import NgioValueError
|
|
12
13
|
|
|
13
14
|
T = TypeVar("T")
|
|
14
15
|
|
|
@@ -44,7 +45,7 @@ def transform_numpy_array(
|
|
|
44
45
|
elif isinstance(operation, AxesSqueeze):
|
|
45
46
|
array = np.squeeze(array, axis=operation.axes)
|
|
46
47
|
else:
|
|
47
|
-
raise
|
|
48
|
+
raise NgioValueError(f"Unknown operation {operation}")
|
|
48
49
|
return array
|
|
49
50
|
|
|
50
51
|
|
|
@@ -59,5 +60,5 @@ def transform_dask_array(
|
|
|
59
60
|
elif isinstance(operation, AxesSqueeze):
|
|
60
61
|
array = da.squeeze(array, axis=operation.axes)
|
|
61
62
|
else:
|
|
62
|
-
raise
|
|
63
|
+
raise NgioValueError(f"Unknown operation {operation}")
|
|
63
64
|
return array
|
|
@@ -57,6 +57,13 @@ class Dimensions:
|
|
|
57
57
|
return 1
|
|
58
58
|
return self._shape[index]
|
|
59
59
|
|
|
60
|
+
def has_axis(self, axis_name: str) -> bool:
|
|
61
|
+
"""Return whether the axis exists."""
|
|
62
|
+
index = self._axes_mapper.get_axis(axis_name)
|
|
63
|
+
if index is None:
|
|
64
|
+
return False
|
|
65
|
+
return True
|
|
66
|
+
|
|
60
67
|
def get_shape(self, axes_order: Collection[str]) -> tuple[int, ...]:
|
|
61
68
|
"""Return the shape in the given axes order."""
|
|
62
69
|
transforms = self._axes_mapper.to_order(axes_order)
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Utilities to build masking regions of interest (ROIs)."""
|
|
2
|
+
|
|
3
|
+
import itertools
|
|
4
|
+
|
|
5
|
+
import dask
|
|
6
|
+
import dask.array as da
|
|
7
|
+
import dask.delayed
|
|
8
|
+
import numpy as np
|
|
9
|
+
import scipy.ndimage as ndi
|
|
10
|
+
|
|
11
|
+
from ngio.common._roi import RasterCooROI, WorldCooROI
|
|
12
|
+
from ngio.ome_zarr_meta import PixelSize
|
|
13
|
+
from ngio.utils import NgioValueError
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _compute_offsets(chunks):
|
|
17
|
+
"""Given a chunks tuple, compute cumulative offsets for each axis.
|
|
18
|
+
|
|
19
|
+
Returns a list where each element is a list of offsets for that dimension.
|
|
20
|
+
"""
|
|
21
|
+
offsets = []
|
|
22
|
+
for dim_chunks in chunks:
|
|
23
|
+
dim_offsets = [0]
|
|
24
|
+
for size in dim_chunks:
|
|
25
|
+
dim_offsets.append(dim_offsets[-1] + size)
|
|
26
|
+
offsets.append(dim_offsets)
|
|
27
|
+
return offsets
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _adjust_slices(slices, offset):
|
|
31
|
+
"""Adjust slices to global coordinates using the provided offset."""
|
|
32
|
+
adjusted_slices = {}
|
|
33
|
+
for label, s in slices.items():
|
|
34
|
+
adjusted = tuple(
|
|
35
|
+
slice(s_dim.start + off, s_dim.stop + off)
|
|
36
|
+
for s_dim, off in zip(s, offset, strict=True)
|
|
37
|
+
)
|
|
38
|
+
adjusted_slices[label] = adjusted
|
|
39
|
+
return adjusted_slices
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@dask.delayed
|
|
43
|
+
def _process_chunk(chunk, offset):
|
|
44
|
+
"""Process a single chunk.
|
|
45
|
+
|
|
46
|
+
run ndi.find_objects and adjust the slices
|
|
47
|
+
to global coordinates using the provided offset.
|
|
48
|
+
"""
|
|
49
|
+
local_slices = compute_slices(chunk)
|
|
50
|
+
local_slices = _adjust_slices(local_slices, offset)
|
|
51
|
+
return local_slices
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _merge_slices(
|
|
55
|
+
slice1: tuple[slice, ...], slice2: tuple[slice, ...]
|
|
56
|
+
) -> tuple[slice, ...]:
|
|
57
|
+
"""Merge two slices."""
|
|
58
|
+
merged = []
|
|
59
|
+
for s1, s2 in zip(slice1, slice2, strict=True):
|
|
60
|
+
start = min(s1.start, s2.start)
|
|
61
|
+
stop = max(s1.stop, s2.stop)
|
|
62
|
+
merged.append(slice(start, stop))
|
|
63
|
+
return tuple(merged)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dask.delayed
|
|
67
|
+
def _collect_slices(
|
|
68
|
+
local_slices: list[dict[int, tuple[slice, ...]]],
|
|
69
|
+
) -> dict[int, tuple[slice]]:
|
|
70
|
+
"""Collect the slices from the delayed results."""
|
|
71
|
+
global_slices = {}
|
|
72
|
+
for result in local_slices:
|
|
73
|
+
for label, s in result.items():
|
|
74
|
+
if label in global_slices:
|
|
75
|
+
global_slices[label] = _merge_slices(global_slices[label], s)
|
|
76
|
+
else:
|
|
77
|
+
global_slices[label] = s
|
|
78
|
+
return global_slices
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def compute_slices(segmentation: np.ndarray) -> dict[int, tuple[slice, ...]]:
|
|
82
|
+
"""Compute slices for each label in a segmentation.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
segmentation (ndarray): The segmentation array.
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
dict[int, tuple[slice]]: A dictionary with the label as key
|
|
89
|
+
and the slice as value.
|
|
90
|
+
"""
|
|
91
|
+
slices = ndi.find_objects(segmentation)
|
|
92
|
+
slices_dict = {}
|
|
93
|
+
for label, s in enumerate(slices, start=1):
|
|
94
|
+
if s is None:
|
|
95
|
+
continue
|
|
96
|
+
else:
|
|
97
|
+
slices_dict[label] = s
|
|
98
|
+
return slices_dict
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def lazy_compute_slices(segmentation: da.Array) -> dict[int, tuple[slice, ...]]:
|
|
102
|
+
"""Compute slices for each label in a segmentation."""
|
|
103
|
+
global_offsets = _compute_offsets(segmentation.chunks)
|
|
104
|
+
delayed_chunks = segmentation.to_delayed()
|
|
105
|
+
|
|
106
|
+
grid_shape = tuple(len(c) for c in segmentation.chunks)
|
|
107
|
+
|
|
108
|
+
grid_indices = list(itertools.product(*[range(n) for n in grid_shape]))
|
|
109
|
+
delayed_results = []
|
|
110
|
+
for idx, chunk in zip(grid_indices, np.ravel(delayed_chunks), strict=True):
|
|
111
|
+
offset = tuple(global_offsets[dim][idx[dim]] for dim in range(len(idx)))
|
|
112
|
+
delayed_result = _process_chunk(chunk, offset)
|
|
113
|
+
delayed_results.append(delayed_result)
|
|
114
|
+
|
|
115
|
+
return _collect_slices(delayed_results).compute()
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def compute_masking_roi(
|
|
119
|
+
segmentation: np.ndarray | da.Array, pixel_size: PixelSize
|
|
120
|
+
) -> list[WorldCooROI]:
|
|
121
|
+
"""Compute a ROIs for each label in a segmentation.
|
|
122
|
+
|
|
123
|
+
This function expects a 2D or 3D segmentation array.
|
|
124
|
+
And this function expects the axes order to be 'zyx' or 'yx'.
|
|
125
|
+
Other axes orders are not supported.
|
|
126
|
+
|
|
127
|
+
"""
|
|
128
|
+
if segmentation.ndim not in [2, 3]:
|
|
129
|
+
raise NgioValueError("Only 2D and 3D segmentations are supported.")
|
|
130
|
+
|
|
131
|
+
if isinstance(segmentation, da.Array):
|
|
132
|
+
slices = lazy_compute_slices(segmentation)
|
|
133
|
+
else:
|
|
134
|
+
slices = compute_slices(segmentation)
|
|
135
|
+
|
|
136
|
+
rois = []
|
|
137
|
+
for label, slice_ in slices.items():
|
|
138
|
+
if len(slice_) == 2:
|
|
139
|
+
min_z, min_y, min_x = 0, slice_[0].start, slice_[1].start
|
|
140
|
+
max_z, max_y, max_x = 1, slice_[0].stop, slice_[1].stop
|
|
141
|
+
elif len(slice_) == 3:
|
|
142
|
+
min_z, min_y, min_x = slice_[0].start, slice_[1].start, slice_[2].start
|
|
143
|
+
max_z, max_y, max_x = slice_[0].stop, slice_[1].stop, slice_[2].stop
|
|
144
|
+
else:
|
|
145
|
+
raise ValueError("Invalid slice length.")
|
|
146
|
+
roi = RasterCooROI(
|
|
147
|
+
name=str(label),
|
|
148
|
+
x_length=max_x - min_x,
|
|
149
|
+
y_length=max_y - min_y,
|
|
150
|
+
z_length=max_z - min_z,
|
|
151
|
+
x=min_x,
|
|
152
|
+
y=min_y,
|
|
153
|
+
z=min_z,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
roi = roi.to_world_coo_roi(pixel_size)
|
|
157
|
+
rois.append(roi)
|
|
158
|
+
return rois
|
|
@@ -7,7 +7,12 @@ import numpy as np
|
|
|
7
7
|
import zarr
|
|
8
8
|
|
|
9
9
|
from ngio.common._zoom import _zoom_inputs_check, dask_zoom, numpy_zoom
|
|
10
|
-
from ngio.utils import
|
|
10
|
+
from ngio.utils import (
|
|
11
|
+
AccessModeLiteral,
|
|
12
|
+
NgioValueError,
|
|
13
|
+
StoreOrGroup,
|
|
14
|
+
open_group_wrapper,
|
|
15
|
+
)
|
|
11
16
|
|
|
12
17
|
|
|
13
18
|
def _on_disk_numpy_zoom(
|
|
@@ -64,7 +69,7 @@ def _on_disk_coarsen(
|
|
|
64
69
|
elif _order == 0:
|
|
65
70
|
aggregation_function = np.max
|
|
66
71
|
else:
|
|
67
|
-
raise
|
|
72
|
+
raise NgioValueError(
|
|
68
73
|
f"Aggregation function must be provided for order {_order}"
|
|
69
74
|
)
|
|
70
75
|
|
|
@@ -77,7 +82,7 @@ def _on_disk_coarsen(
|
|
|
77
82
|
if factor.is_integer():
|
|
78
83
|
coarsening_setup[i] = int(factor)
|
|
79
84
|
else:
|
|
80
|
-
raise
|
|
85
|
+
raise NgioValueError(
|
|
81
86
|
f"Coarsening factor must be an integer, got {factor} on axis {i}"
|
|
82
87
|
)
|
|
83
88
|
|
|
@@ -103,13 +108,13 @@ def on_disk_zoom(
|
|
|
103
108
|
mode (Literal["dask", "numpy", "coarsen"]): The mode to use. Defaults to "dask".
|
|
104
109
|
"""
|
|
105
110
|
if not isinstance(source, zarr.Array):
|
|
106
|
-
raise
|
|
111
|
+
raise NgioValueError("source must be a zarr array")
|
|
107
112
|
|
|
108
113
|
if not isinstance(target, zarr.Array):
|
|
109
|
-
raise
|
|
114
|
+
raise NgioValueError("target must be a zarr array")
|
|
110
115
|
|
|
111
116
|
if source.dtype != target.dtype:
|
|
112
|
-
raise
|
|
117
|
+
raise NgioValueError("source and target must have the same dtype")
|
|
113
118
|
|
|
114
119
|
match mode:
|
|
115
120
|
case "numpy":
|
|
@@ -122,7 +127,7 @@ def on_disk_zoom(
|
|
|
122
127
|
target,
|
|
123
128
|
)
|
|
124
129
|
case _:
|
|
125
|
-
raise
|
|
130
|
+
raise NgioValueError("mode must be either 'dask', 'numpy' or 'coarsen'")
|
|
126
131
|
|
|
127
132
|
|
|
128
133
|
def _find_closest_arrays(
|
|
@@ -181,19 +186,19 @@ def init_empty_pyramid(
|
|
|
181
186
|
) -> None:
|
|
182
187
|
# Return the an Image object
|
|
183
188
|
if chunks is not None and len(chunks) != len(ref_shape):
|
|
184
|
-
raise
|
|
189
|
+
raise NgioValueError(
|
|
185
190
|
"The shape and chunks must have the same number of dimensions."
|
|
186
191
|
)
|
|
187
192
|
|
|
188
193
|
if len(ref_shape) != len(scaling_factors):
|
|
189
|
-
raise
|
|
194
|
+
raise NgioValueError(
|
|
190
195
|
"The shape and scaling factor must have the same number of dimensions."
|
|
191
196
|
)
|
|
192
197
|
|
|
193
198
|
root_group, _ = open_group_wrapper(store, mode=mode)
|
|
194
199
|
for path in paths:
|
|
195
200
|
if any(s < 1 for s in ref_shape):
|
|
196
|
-
raise
|
|
201
|
+
raise NgioValueError(
|
|
197
202
|
"Level shape must be at least 1 on all dimensions. "
|
|
198
203
|
f"Calculated shape: {ref_shape} at level {path}."
|
|
199
204
|
)
|
|
@@ -218,6 +223,6 @@ def init_empty_pyramid(
|
|
|
218
223
|
if chunks is None:
|
|
219
224
|
chunks = new_arr.chunks
|
|
220
225
|
if chunks is None:
|
|
221
|
-
raise
|
|
226
|
+
raise NgioValueError("Something went wrong with the chunks")
|
|
222
227
|
chunks = [min(c, s) for c, s in zip(chunks, ref_shape, strict=True)]
|
|
223
228
|
return None
|