ngio 0.2.0a3__tar.gz → 0.2.0b2__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.0b2/.github/scripts/download_data.sh +97 -0
- ngio-0.2.0b2/.github/workflows/build_docs.yml +60 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/.github/workflows/ci.yml +25 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/.gitignore +3 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/PKG-INFO +6 -2
- {ngio-0.2.0a3 → ngio-0.2.0b2}/README.md +1 -1
- {ngio-0.2.0a3 → ngio-0.2.0b2}/docs/notebooks/basic_usage.ipynb +12 -40
- {ngio-0.2.0a3 → ngio-0.2.0b2}/docs/notebooks/image.ipynb +7 -1
- {ngio-0.2.0a3 → ngio-0.2.0b2}/docs/notebooks/processing.ipynb +7 -1
- {ngio-0.2.0a3 → ngio-0.2.0b2}/mkdocs.yml +2 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/pyproject.toml +11 -23
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/__init__.py +4 -4
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/common/__init__.py +12 -2
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/common/_array_pipe.py +106 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/common/_axes_transforms.py +3 -2
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/common/_dimensions.py +7 -0
- ngio-0.2.0b2/src/ngio/common/_masking_roi.py +158 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/common/_pyramid.py +16 -11
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/common/_roi.py +74 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/common/_slicer.py +1 -2
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/common/_zoom.py +5 -3
- ngio-0.2.0b2/src/ngio/hcs/__init__.py +5 -0
- ngio-0.2.0b2/src/ngio/hcs/plate.py +399 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/images/abstract_image.py +97 -28
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/images/create.py +48 -29
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/images/image.py +99 -46
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/images/label.py +109 -92
- ngio-0.2.0b2/src/ngio/images/masked_image.py +259 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/images/omezarr_container.py +201 -64
- ngio-0.2.0b2/src/ngio/ome_zarr_meta/__init__.py +47 -0
- ngio-0.2.0b2/src/ngio/ome_zarr_meta/_meta_handlers.py +791 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/ome_zarr_meta/ngio_specs/__init__.py +8 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/ome_zarr_meta/ngio_specs/_channels.py +11 -0
- ngio-0.2.0b2/src/ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py +377 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/ome_zarr_meta/ngio_specs/_ngio_image.py +169 -119
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/ome_zarr_meta/ngio_specs/_pixel_size.py +35 -3
- ngio-0.2.0b2/src/ngio/ome_zarr_meta/v04/__init__.py +23 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/ome_zarr_meta/v04/_v04_spec_utils.py +85 -12
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/__init__.py +2 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/_validators.py +2 -4
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/backends/_anndata_utils.py +5 -1
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/backends/_anndata_v1.py +2 -1
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/backends/_json_v1.py +1 -1
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/tables_container.py +12 -2
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/v1/__init__.py +1 -2
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/v1/_feature_table.py +7 -5
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/v1/_generic_table.py +65 -11
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/v1/_roi_table.py +145 -27
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/utils/_datasets.py +4 -2
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/utils/_fractal_fsspec_store.py +3 -2
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/utils/_logger.py +3 -1
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/utils/_zarr_utils.py +25 -2
- ngio-0.2.0b2/tests/conftest.py +40 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_c1yx.zarr/.zattrs +86 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_c1yx.zarr/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_c1yx.zarr/0/.zarray +27 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_c1yx.zarr/1/.zarray +27 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_c1yx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_c1yx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_c1yx.zarr/labels/label/.zattrs +59 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_c1yx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_c1yx.zarr/labels/label/0/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_c1yx.zarr/labels/label/1/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_cyx.zarr/.zattrs +79 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_cyx.zarr/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_cyx.zarr/0/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_cyx.zarr/1/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_cyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_cyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_cyx.zarr/labels/label/.zattrs +52 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_cyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_cyx.zarr/labels/label/0/.zarray +23 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_cyx.zarr/labels/label/1/.zarray +23 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_czyx.zarr/.zattrs +86 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_czyx.zarr/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_czyx.zarr/0/.zarray +27 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_czyx.zarr/1/.zarray +27 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_czyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_czyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_czyx.zarr/labels/label/.zattrs +59 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_czyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_czyx.zarr/labels/label/0/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_czyx.zarr/labels/label/1/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tcyx.zarr/.zattrs +86 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tcyx.zarr/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tcyx.zarr/0/.zarray +27 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tcyx.zarr/1/.zarray +27 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tcyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tcyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tcyx.zarr/labels/label/.zattrs +59 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tcyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tcyx.zarr/labels/label/0/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tcyx.zarr/labels/label/1/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tczyx.zarr/.zattrs +93 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tczyx.zarr/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tczyx.zarr/0/.zarray +29 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tczyx.zarr/1/.zarray +29 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tczyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tczyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tczyx.zarr/labels/label/.zattrs +66 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tczyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tczyx.zarr/labels/label/0/.zarray +27 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tczyx.zarr/labels/label/1/.zarray +27 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tyx.zarr/.zattrs +68 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tyx.zarr/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tyx.zarr/0/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tyx.zarr/1/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tyx.zarr/labels/label/.zattrs +59 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tyx.zarr/labels/label/0/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tyx.zarr/labels/label/1/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tzyx.zarr/.zattrs +75 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tzyx.zarr/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tzyx.zarr/0/.zarray +27 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tzyx.zarr/1/.zarray +27 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tzyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tzyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tzyx.zarr/labels/label/.zattrs +66 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tzyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tzyx.zarr/labels/label/0/.zarray +27 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_tzyx.zarr/labels/label/1/.zarray +27 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_yx.zarr/.zattrs +61 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_yx.zarr/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_yx.zarr/0/.zarray +23 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_yx.zarr/1/.zarray +23 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_yx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_yx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_yx.zarr/labels/label/.zattrs +52 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_yx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_yx.zarr/labels/label/0/.zarray +23 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_yx.zarr/labels/label/1/.zarray +23 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_zyx.zarr/.zattrs +68 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_zyx.zarr/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_zyx.zarr/0/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_zyx.zarr/1/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_zyx.zarr/labels/.zattrs +5 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_zyx.zarr/labels/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_zyx.zarr/labels/label/.zattrs +59 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_zyx.zarr/labels/label/.zgroup +3 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_zyx.zarr/labels/label/0/.zarray +25 -0
- ngio-0.2.0b2/tests/data/v04/images/test_image_zyx.zarr/labels/label/1/.zarray +25 -0
- ngio-0.2.0b2/tests/unit/hcs/test_plate.py +57 -0
- ngio-0.2.0b2/tests/unit/images/test_create.py +128 -0
- ngio-0.2.0b2/tests/unit/images/test_images.py +25 -0
- ngio-0.2.0b2/tests/unit/images/test_masked_images.py +73 -0
- ngio-0.2.0b2/tests/unit/images/test_omezarr_container.py +155 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/tests/unit/tables/test_backends.py +7 -5
- {ngio-0.2.0a3 → ngio-0.2.0b2}/tests/unit/tables/test_feature_table.py +1 -1
- ngio-0.2.0b2/tests/unit/tables/test_generic_table.py +56 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/tests/unit/tables/test_masking_roi_table_v1.py +1 -1
- ngio-0.2.0b2/tests/unit/tables/test_table_group.py +34 -0
- ngio-0.2.0b2/tests/unit/test_ome_zarr_meta/test_image_handler.py +15 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/tests/unit/test_ome_zarr_meta/test_unit_ngio_specs.py +12 -4
- {ngio-0.2.0a3 → ngio-0.2.0b2}/tests/unit/test_ome_zarr_meta/test_unit_v04_utils.py +2 -2
- ngio-0.2.0a3/.github/workflows/build_docs.yml +0 -39
- 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.0b2}/.copier-answers.yml +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/.gitattributes +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/.github/ISSUE_TEMPLATE.md +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/.github/TEST_FAIL_TEMPLATE.md +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/.github/dependabot.yml +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/.pre-commit-config.yaml +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/LICENSE +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/_typos.toml +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/docs/api/core.md +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/docs/getting-started.md +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/docs/index.md +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/common/_common_types.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/images/__init__.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/ome_zarr_meta/ngio_specs/_axes.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/ome_zarr_meta/ngio_specs/_dataset.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/backends/__init__.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/backends/_abstract_backend.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/tables/backends/_table_backends.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/utils/__init__.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/src/ngio/utils/_errors.py +0 -0
- {ngio-0.2.0a3/tests/data/meta_v04 → ngio-0.2.0b2/tests/data/v04/meta}/base_ome_zarr_image_meta.json +0 -0
- {ngio-0.2.0a3/tests/data/meta_v04 → ngio-0.2.0b2/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.0b2/tests/data/v04/meta}/base_ome_zarr_label_meta.json +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/tests/unit/common/test_dimensions.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/tests/unit/common/test_pyramid.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/tests/unit/common/test_roi.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/tests/unit/tables/test_roi_table_v1.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/tests/unit/tables/test_validators.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/tests/unit/utils/test_download_datasets.py +0 -0
- {ngio-0.2.0a3 → ngio-0.2.0b2}/tests/unit/utils/test_zarr_utils.py +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# filepath: download_zarr_datasets.sh
|
|
3
|
+
|
|
4
|
+
# Default download directory
|
|
5
|
+
DOWNLOAD_DIR="data"
|
|
6
|
+
|
|
7
|
+
# Create download directory if it doesn't exist
|
|
8
|
+
mkdir -p "$DOWNLOAD_DIR"
|
|
9
|
+
|
|
10
|
+
# Function to check MD5 hash
|
|
11
|
+
check_md5() {
|
|
12
|
+
local file="$1"
|
|
13
|
+
local expected="$2"
|
|
14
|
+
|
|
15
|
+
if [[ "$(uname)" == "Darwin" ]]; then
|
|
16
|
+
# macOS
|
|
17
|
+
actual=$(md5 -q "$file")
|
|
18
|
+
else
|
|
19
|
+
# Linux/Ubuntu
|
|
20
|
+
actual=$(md5sum "$file" | awk '{print $1}')
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
echo "Expected: $expected"
|
|
24
|
+
echo "Actual: $actual"
|
|
25
|
+
|
|
26
|
+
if [[ "$actual" == "$expected" ]]; then
|
|
27
|
+
return 0 # Success
|
|
28
|
+
else
|
|
29
|
+
return 1 # Failure
|
|
30
|
+
fi
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# Function to download a file
|
|
34
|
+
download_file() {
|
|
35
|
+
local url="$1"
|
|
36
|
+
local output="$2"
|
|
37
|
+
|
|
38
|
+
echo "Downloading $url to $output..."
|
|
39
|
+
|
|
40
|
+
if command -v curl &> /dev/null; then
|
|
41
|
+
curl -L -o "$output" "$url"
|
|
42
|
+
elif command -v wget &> /dev/null; then
|
|
43
|
+
wget -O "$output" "$url"
|
|
44
|
+
else
|
|
45
|
+
echo "Error: Neither curl nor wget is available. Please install one of them."
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# Function to process a dataset
|
|
51
|
+
process_dataset() {
|
|
52
|
+
local filename="$1"
|
|
53
|
+
local url="$2"
|
|
54
|
+
local expected_hash="$3"
|
|
55
|
+
|
|
56
|
+
local file_path="$DOWNLOAD_DIR/$filename"
|
|
57
|
+
|
|
58
|
+
echo "Processing $filename..."
|
|
59
|
+
|
|
60
|
+
# Check if file exists and has the correct hash
|
|
61
|
+
if [[ -f "$file_path" ]] && check_md5 "$file_path" "$expected_hash"; then
|
|
62
|
+
echo "File exists and has the correct hash."
|
|
63
|
+
else
|
|
64
|
+
# File doesn't exist or has incorrect hash
|
|
65
|
+
if [[ -f "$file_path" ]]; then
|
|
66
|
+
echo "File exists but has incorrect hash. Redownloading..."
|
|
67
|
+
else
|
|
68
|
+
echo "File doesn't exist. Downloading..."
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
download_file "$url" "$file_path"
|
|
72
|
+
|
|
73
|
+
# Verify the downloaded file
|
|
74
|
+
if check_md5 "$file_path" "$expected_hash"; then
|
|
75
|
+
echo "Download successful and hash verified."
|
|
76
|
+
else
|
|
77
|
+
echo "Error: Downloaded file has incorrect hash."
|
|
78
|
+
return 1
|
|
79
|
+
fi
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
echo "File is ready at $file_path"
|
|
83
|
+
return 0
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
# Process the CardioMyocyte dataset
|
|
87
|
+
process_dataset "20200812-CardiomyocyteDifferentiation14-Cycle1.zarr.zip" \
|
|
88
|
+
"https://zenodo.org/records/13305156/files/20200812-CardiomyocyteDifferentiation14-Cycle1.zarr.zip" \
|
|
89
|
+
"efc21fe8d4ea3abab76226d8c166452c"
|
|
90
|
+
|
|
91
|
+
process_dataset "20200812-CardiomyocyteDifferentiation14-Cycle1_mip.zarr.zip" \
|
|
92
|
+
"https://zenodo.org/records/13305316/files/20200812-CardiomyocyteDifferentiation14-Cycle1_mip.zarr.zip" \
|
|
93
|
+
"3ed3ea898e0ed42d397da2e1dbe40750"
|
|
94
|
+
# To add more datasets, add more calls to process_dataset like this:
|
|
95
|
+
# process_dataset "filename.zip" "download_url" "expected_md5_hash"
|
|
96
|
+
|
|
97
|
+
echo "All datasets processed."
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
name: Build Docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
tags:
|
|
8
|
+
- "v*"
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
download-test-ome-zarr:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- name: Check and Download Artifacts
|
|
16
|
+
run: |
|
|
17
|
+
bash .github/scripts/download_data.sh
|
|
18
|
+
|
|
19
|
+
deploy:
|
|
20
|
+
name: Deploy Docs
|
|
21
|
+
needs: download-test-ome-zarr
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
with:
|
|
27
|
+
fetch-depth: 0
|
|
28
|
+
|
|
29
|
+
- name: 🐍 Set up Python
|
|
30
|
+
uses: actions/setup-python@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: "3.13"
|
|
33
|
+
cache-dependency-path: "pyproject.toml"
|
|
34
|
+
cache: "pip"
|
|
35
|
+
|
|
36
|
+
- name: Install Dependencies
|
|
37
|
+
run: |
|
|
38
|
+
python -m pip install -U pip
|
|
39
|
+
python -m pip install .[dev]
|
|
40
|
+
python -m pip install .[docs]
|
|
41
|
+
|
|
42
|
+
- name: Configure Git user
|
|
43
|
+
run: |
|
|
44
|
+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
|
45
|
+
git config --local user.name "github-actions[bot]"
|
|
46
|
+
|
|
47
|
+
- name: Deploy docs
|
|
48
|
+
run: |
|
|
49
|
+
VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\///' | sed 's/refs\/heads\///')
|
|
50
|
+
echo "Deploying version $VERSION"
|
|
51
|
+
# Check if the version is a stable release
|
|
52
|
+
# Meaning that starts with "v" and contains only numbers and dots
|
|
53
|
+
if [[ $GITHUB_REF == refs/tags/* ]] && [[ $VERSION =~ ^v[0-9.]+$ ]]; then
|
|
54
|
+
mike deploy --push --update-aliases $VERSION stable
|
|
55
|
+
mike set-default --push stable
|
|
56
|
+
echo "Deployed stable version"
|
|
57
|
+
else
|
|
58
|
+
mike deploy --push dev
|
|
59
|
+
echo "Deployed development version"
|
|
60
|
+
fi
|
|
@@ -26,8 +26,24 @@ jobs:
|
|
|
26
26
|
- uses: actions/checkout@v4
|
|
27
27
|
- run: pipx run check-manifest
|
|
28
28
|
|
|
29
|
+
|
|
30
|
+
download-test-ome-zarr:
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v4
|
|
34
|
+
- name: Check and Download Artifacts
|
|
35
|
+
run: |
|
|
36
|
+
bash .github/scripts/download_data.sh
|
|
37
|
+
- name: Upload Artifacts
|
|
38
|
+
uses: actions/upload-artifact@v4
|
|
39
|
+
with:
|
|
40
|
+
name: data
|
|
41
|
+
path: data
|
|
42
|
+
|
|
43
|
+
|
|
29
44
|
test:
|
|
30
45
|
name: ${{ matrix.platform }} (${{ matrix.python-version }})
|
|
46
|
+
needs: download-test-ome-zarr
|
|
31
47
|
runs-on: ${{ matrix.platform }}
|
|
32
48
|
strategy:
|
|
33
49
|
fail-fast: false
|
|
@@ -44,6 +60,15 @@ jobs:
|
|
|
44
60
|
steps:
|
|
45
61
|
- uses: actions/checkout@v4
|
|
46
62
|
|
|
63
|
+
- uses: actions/download-artifact@v4
|
|
64
|
+
with:
|
|
65
|
+
name: data
|
|
66
|
+
path: data
|
|
67
|
+
|
|
68
|
+
- name: Check Artifacts
|
|
69
|
+
run: |
|
|
70
|
+
ls -l data
|
|
71
|
+
|
|
47
72
|
- name: 🐍 Set up Python ${{ matrix.python-version }}
|
|
48
73
|
uses: actions/setup-python@v5
|
|
49
74
|
with:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ngio
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.0b2
|
|
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,7 +39,9 @@ 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
|
|
44
|
+
Requires-Dist: mike; extra == 'docs'
|
|
42
45
|
Requires-Dist: mkdocs; extra == 'docs'
|
|
43
46
|
Requires-Dist: mkdocs-autorefs; extra == 'docs'
|
|
44
47
|
Requires-Dist: mkdocs-git-committers-plugin-2; extra == 'docs'
|
|
@@ -50,6 +53,7 @@ Requires-Dist: scikit-image; extra == 'docs'
|
|
|
50
53
|
Provides-Extra: test
|
|
51
54
|
Requires-Dist: pytest; extra == 'test'
|
|
52
55
|
Requires-Dist: pytest-cov; extra == 'test'
|
|
56
|
+
Requires-Dist: scikit-image; extra == 'test'
|
|
53
57
|
Description-Content-Type: text/markdown
|
|
54
58
|
|
|
55
59
|
# NGIO - Next Generation file format IO
|
|
@@ -57,7 +61,7 @@ Description-Content-Type: text/markdown
|
|
|
57
61
|
[](https://github.com/lorenzocerrone/ngio/raw/main/LICENSE)
|
|
58
62
|
[](https://pypi.org/project/ngio)
|
|
59
63
|
[](https://python.org)
|
|
60
|
-
[](https://github.com/
|
|
64
|
+
[](https://github.com/fractal-analytics-platform/ngio/actions/workflows/ci.yml)
|
|
61
65
|
[](https://codecov.io/gh/fractal-analytics-platform/ngio)
|
|
62
66
|
|
|
63
67
|
NGIO is a Python library to streamline OME-Zarr image analysis workflows.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://github.com/lorenzocerrone/ngio/raw/main/LICENSE)
|
|
4
4
|
[](https://pypi.org/project/ngio)
|
|
5
5
|
[](https://python.org)
|
|
6
|
-
[](https://github.com/
|
|
6
|
+
[](https://github.com/fractal-analytics-platform/ngio/actions/workflows/ci.yml)
|
|
7
7
|
[](https://codecov.io/gh/fractal-analytics-platform/ngio)
|
|
8
8
|
|
|
9
9
|
NGIO is a Python library to streamline OME-Zarr image analysis workflows.
|
|
@@ -22,11 +22,17 @@
|
|
|
22
22
|
"metadata": {},
|
|
23
23
|
"outputs": [],
|
|
24
24
|
"source": [
|
|
25
|
+
"from pathlib import Path\n",
|
|
26
|
+
"\n",
|
|
25
27
|
"from ngio import open_omezarr_container\n",
|
|
26
28
|
"from ngio.utils import download_ome_zarr_dataset\n",
|
|
27
29
|
"\n",
|
|
28
|
-
"
|
|
30
|
+
"# Download the dataset\n",
|
|
31
|
+
"download_dir = Path(\".\").absolute().parent.parent / \"data\"\n",
|
|
32
|
+
"hcs_path = download_ome_zarr_dataset(\"CardiomyocyteSmallMip\", download_dir=download_dir)\n",
|
|
29
33
|
"image_path = hcs_path / \"B\" / \"03\" / \"0\"\n",
|
|
34
|
+
"\n",
|
|
35
|
+
"# Open the ome-zarr container\n",
|
|
30
36
|
"omezarr_container = open_omezarr_container(image_path)"
|
|
31
37
|
]
|
|
32
38
|
},
|
|
@@ -86,10 +92,10 @@
|
|
|
86
92
|
"print(image)\n",
|
|
87
93
|
"\n",
|
|
88
94
|
"# 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)"
|
|
95
|
+
"# image = omezarr_container.get_image(\n",
|
|
96
|
+
"# pixel_size=PixelSize(x=0.65, y=0.65, z=1), strict=True\n",
|
|
97
|
+
"# )\n",
|
|
98
|
+
"print(image.pixel_size == PixelSize(x=0.325, y=0.325, z=1))"
|
|
93
99
|
]
|
|
94
100
|
},
|
|
95
101
|
{
|
|
@@ -287,6 +293,7 @@
|
|
|
287
293
|
"metadata": {},
|
|
288
294
|
"outputs": [],
|
|
289
295
|
"source": [
|
|
296
|
+
"import fsspec\n",
|
|
290
297
|
"import fsspec.implementations.http\n",
|
|
291
298
|
"\n",
|
|
292
299
|
"url = (\n",
|
|
@@ -298,7 +305,6 @@
|
|
|
298
305
|
"\n",
|
|
299
306
|
"fs = fsspec.implementations.http.HTTPFileSystem(client_kwargs={})\n",
|
|
300
307
|
"store = fs.get_mapper(url)\n",
|
|
301
|
-
"\n",
|
|
302
308
|
"omezarr = open_omezarr_container(store)\n",
|
|
303
309
|
"omezarr"
|
|
304
310
|
]
|
|
@@ -319,40 +325,6 @@
|
|
|
319
325
|
"omezarr\n",
|
|
320
326
|
"```"
|
|
321
327
|
]
|
|
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
328
|
}
|
|
357
329
|
],
|
|
358
330
|
"metadata": {
|
|
@@ -15,13 +15,19 @@
|
|
|
15
15
|
"metadata": {},
|
|
16
16
|
"outputs": [],
|
|
17
17
|
"source": [
|
|
18
|
+
"from pathlib import Path\n",
|
|
19
|
+
"\n",
|
|
18
20
|
"import matplotlib.pyplot as plt\n",
|
|
19
21
|
"\n",
|
|
20
22
|
"from ngio import open_omezarr_container\n",
|
|
21
23
|
"from ngio.utils import download_ome_zarr_dataset\n",
|
|
22
24
|
"\n",
|
|
23
|
-
"
|
|
25
|
+
"# Download the dataset\n",
|
|
26
|
+
"download_dir = Path(\".\").absolute().parent.parent / \"data\"\n",
|
|
27
|
+
"hcs_path = download_ome_zarr_dataset(\"CardiomyocyteSmallMip\", download_dir=download_dir)\n",
|
|
24
28
|
"image_path = hcs_path / \"B\" / \"03\" / \"0\"\n",
|
|
29
|
+
"\n",
|
|
30
|
+
"# Open the ome-zarr container\n",
|
|
25
31
|
"omezarr = open_omezarr_container(image_path)"
|
|
26
32
|
]
|
|
27
33
|
},
|
|
@@ -33,13 +33,19 @@
|
|
|
33
33
|
"metadata": {},
|
|
34
34
|
"outputs": [],
|
|
35
35
|
"source": [
|
|
36
|
+
"from pathlib import Path\n",
|
|
37
|
+
"\n",
|
|
36
38
|
"import matplotlib.pyplot as plt\n",
|
|
37
39
|
"\n",
|
|
38
40
|
"from ngio import open_omezarr_container\n",
|
|
39
41
|
"from ngio.utils import download_ome_zarr_dataset\n",
|
|
40
42
|
"\n",
|
|
41
|
-
"
|
|
43
|
+
"# Download the dataset\n",
|
|
44
|
+
"download_dir = Path(\".\").absolute().parent.parent / \"data\"\n",
|
|
45
|
+
"hcs_path = download_ome_zarr_dataset(\"CardiomyocyteTiny\", download_dir=download_dir)\n",
|
|
42
46
|
"image_path = hcs_path / \"B\" / \"03\" / \"0\"\n",
|
|
47
|
+
"\n",
|
|
48
|
+
"# Open the ome-zarr container\n",
|
|
43
49
|
"omezarr = open_omezarr_container(image_path)"
|
|
44
50
|
]
|
|
45
51
|
},
|
|
@@ -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 = [
|
|
@@ -74,6 +76,7 @@ docs = [
|
|
|
74
76
|
"mkdocs-git-revision-date-localized-plugin",
|
|
75
77
|
"mkdocs-git-committers-plugin-2",
|
|
76
78
|
"scikit-image",
|
|
79
|
+
"mike",
|
|
77
80
|
]
|
|
78
81
|
|
|
79
82
|
|
|
@@ -212,18 +215,12 @@ test13 = { features = ["py13", "test"], solve-group = "py13" }
|
|
|
212
215
|
# dev env
|
|
213
216
|
dev = { features = ["dev", "test"], solve-group = "py11" }
|
|
214
217
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
+
[tool.pixi.tasks]
|
|
219
|
+
serve_docs = "mkdocs serve"
|
|
220
|
+
run_tests = "pytest"
|
|
221
|
+
clean_nb_data = "rm -rf ./docs/notebooks/**/*.zarr"
|
|
218
222
|
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]
|
|
223
|
+
test = { depends-on = ["run_tests", "clean_nb_data", "test_nb"] }
|
|
227
224
|
pre_commit_install = "pre-commit install"
|
|
228
225
|
|
|
229
226
|
ruff-fix-imports = "ruff check --select I --fix"
|
|
@@ -233,12 +230,3 @@ pre-commit = { cmd = "pre-commit run --all-files", depends-on = [
|
|
|
233
230
|
"pre_commit_install",
|
|
234
231
|
"ruff-format",
|
|
235
232
|
] }
|
|
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
|
+
)
|