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

Ngff follow ups #544

Merged
merged 4 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/notebook-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ jobs:
python3 -m pip install -e ".[test]"
python3 -m pip install pyimagej
python3 -c "import imagej; ij = imagej.init('2.5.0'); print(ij.getVersion())"
python3 -m pip install --upgrade --pre itk

- name: Test notebooks
run: |
pytest --nbmake --nbmake-timeout=3000 examples/*.ipynb examples/integrations/dask/*.ipynb
pytest --nbmake --nbmake-timeout=3000 examples/*.ipynb examples/integrations/dask/*.ipynb examples/integrations/itk/*.ipynb
10 changes: 7 additions & 3 deletions examples/integrations/dask/DaskArray.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@
},
{
"data": {
"application/javascript": "window.connectPlugin && window.connectPlugin(\"f73b9611-a293-4994-8215-809777c33496\")",
"application/javascript": [
"window.connectPlugin && window.connectPlugin(\"f73b9611-a293-4994-8215-809777c33496\")"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
Expand Down Expand Up @@ -288,7 +290,9 @@
},
{
"data": {
"application/javascript": "window.connectPlugin && window.connectPlugin(\"f73b9611-a293-4994-8215-809777c33496\")",
"application/javascript": [
"window.connectPlugin && window.connectPlugin(\"f73b9611-a293-4994-8215-809777c33496\")"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
Expand Down Expand Up @@ -340,7 +344,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.9.13"
}
},
"nbformat": 4,
Expand Down
41 changes: 14 additions & 27 deletions examples/integrations/itk/3DImage.ipynb

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions itkwidgets/integrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ def _get_viewer_image(image, label=False):
method = Methods.DASK_IMAGE_NEAREST
else:
method = Methods.DASK_IMAGE_GAUSSIAN

store, chunk_store = _make_multiscale_store()

if HAVE_MULTISCALE_SPATIAL_IMAGE:
from multiscale_spatial_image import MultiscaleSpatialImage
if isinstance(image, MultiscaleSpatialImage):
image.to_zarr(store, compute=True)
return store
Expand All @@ -59,6 +60,7 @@ def _get_viewer_image(image, label=False):
ngff_image = itk_image_to_ngff_image(image)
multiscales = to_multiscales(ngff_image, method=method)
to_ngff_zarr(store, multiscales, chunk_store=chunk_store)
return store

if HAVE_ITK:
import itk
Expand Down Expand Up @@ -152,10 +154,6 @@ def _detect_render_type(data, input_type) -> RenderType:
return RenderType.IMAGE
elif isinstance(data, itkwasm.PointSet):
return RenderType.POINT_SET
elif HAVE_MULTISCALE_SPATIAL_IMAGE:
from multiscale_spatial_image import MultiscaleSpatialImage
if isinstance(data, MultiscaleSpatialImage):
return RenderType.IMAGE
elif isinstance(data, (zarr.Array, zarr.Group)):
# For now assume zarr.Group is an image
# In the future, once NGFF supports point sets fully
Expand All @@ -175,6 +173,10 @@ def _detect_render_type(data, input_type) -> RenderType:
import itk
if isinstance(data, itk.Image):
return RenderType.IMAGE
if HAVE_MULTISCALE_SPATIAL_IMAGE:
from multiscale_spatial_image import MultiscaleSpatialImage
if isinstance(data, MultiscaleSpatialImage):
return RenderType.IMAGE
if HAVE_VTK:
import vtk
if isinstance(data, vtk.vtkImageData):
Expand All @@ -200,8 +202,8 @@ def _detect_render_type(data, input_type) -> RenderType:
return RenderType.POINT_SET
else:
return RenderType.IMAGE
if isinstance(data, xr.Dataset):
if input_type == 'point_sets':
return RenderType.POINT_SET
else:
return RenderType.IMAGE
if isinstance(data, xr.Dataset):
if input_type == 'point_sets':
return RenderType.POINT_SET
else:
return RenderType.IMAGE
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies = [
"itkwasm >= 1.0b1",
"imjoy-rpc >= 0.5.16",
"imjoy-utils >= 0.1.2",
"ngff-zarr[dask-image] >= 0.1.0",
"ngff-zarr[dask-image] >= 0.1.2",
"numcodecs",
"zarr",
]
Expand Down