Skip to content

Consider adding support for multiscale images (e.g. OME-Zarr) #1

@uermel

Description

@uermel

Hi nninteractive team, thank you for this awesome model and plugin!

I tried using it with an OME-Zarr image (Zarr v2, OME-Zarr v0.4) like this:

napari pda2021-02-12-10.zarr -w napari-nninteractive

You can download it from here: s3://cryoet-data-portal-public/10014/pda2021-02-12-10/Reconstructions/VoxelSpacing13.496/Tomograms/100/pda2021-02-12-10.zarr/ (info on the content here)

When pressing "Initialize" I unfortunately ran into an error related to group vs. array indexing (full trace below).

I think OME-Zarr/Zarr would be great formats to support in the biomedical space!

Full trace
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File redacted/anaconda/23.1.0-3/x86_64/envs/nninteractive/lib/python3.12/site-packages/napari_nninteractive/widget_main.py:77, in nnInteractiveWidget.on_init(self=, *args=(False,), **kwargs={})
     70     self.session.initialize_from_trained_model_folder(
     71         self.checkpoint_path,
     72         0,
     73         "checkpoint_final.pth",
     74     )
     76 _data = self._viewer.layers[self.session_cfg["name"]].data
---> 77 _data = _data[np.newaxis, ...]
        _data = 
        np.newaxis, ... = (None, Ellipsis)
        np.newaxis = None
        np =      79 if self.session_cfg["ndim_source"] == 2:
     80     _data = _data[np.newaxis, ...]

File redacted/anaconda/23.1.0-3/x86_64/envs/nninteractive/lib/python3.12/site-packages/napari/utils/_proxies.py:150, in PublicOnlyProxy.getitem(self=<MultiScaleData at 0x14ae68d4c7d0. 3 levels, 'fl...(175, 720, 511), (88, 360, 256), (44, 180, 128))>, key=(None, Ellipsis))
149 def getitem(self, key: Any) -> Any:
--> 150 return self.create(super().getitem(key))
self = <MultiScaleData at 0x14ae68d4c7d0. 3 levels, 'float32', shapes: ((175, 720, 511), (88, 360, 256), (44, 180, 128))>
key = (None, Ellipsis)
File redacted/anaconda/23.1.0-3/x86_64/envs/nninteractive/lib/python3.12/site-packages/napari/layers/_multiscale_data.py:76, in MultiScaleData.getitem(self=<MultiScaleData at 0x14ae68d4c7d0. 3 levels, 'fl...(175, 720, 511), (88, 360, 256), (44, 180, 128))>, key=(None, Ellipsis))
72 def getitem( # type: ignore [override]
73 self, key: Union[int, tuple[slice, ...]]
74 ) -> LayerDataProtocol:
75 """Multiscale indexing."""
---> 76 return self._data[key]
self._data = [dask.array<from-zarr, shape=(175, 720, 511), dtype=float32, chunksize=(175, 256, 256), chunktype=numpy.ndarray>, dask.array<from-zarr, shape=(88, 360, 256), dtype=float32, chunksize=(88, 256, 256), chunktype=numpy.ndarray>, dask.array<from-zarr, shape=(44, 180, 128), dtype=float32, chunksize=(44, 180, 128), chunktype=numpy.ndarray>]
key = (None, Ellipsis)
self = <MultiScaleData at 0x14ae68d4c7d0. 3 levels, 'float32', shapes: ((175, 720, 511), (88, 360, 256), (44, 180, 128))>
TypeError: list indices must be integers or slices, not tuple

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions