Skip to content

Commit e7d8f71

Browse files
authored
Merge pull request #544 from thewtex/ngff-follow-ups
Ngff follow ups
2 parents ecaa868 + ebfcd8e commit e7d8f71

File tree

5 files changed

+36
-42
lines changed

5 files changed

+36
-42
lines changed

.github/workflows/notebook-test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ jobs:
2828
python3 -m pip install -e ".[test]"
2929
python3 -m pip install pyimagej
3030
python3 -c "import imagej; ij = imagej.init('2.5.0'); print(ij.getVersion())"
31+
python3 -m pip install --upgrade --pre itk
3132
3233
- name: Test notebooks
3334
run: |
34-
pytest --nbmake --nbmake-timeout=3000 examples/*.ipynb examples/integrations/dask/*.ipynb
35+
pytest --nbmake --nbmake-timeout=3000 examples/*.ipynb examples/integrations/dask/*.ipynb examples/integrations/itk/*.ipynb

examples/integrations/dask/DaskArray.ipynb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@
8282
},
8383
{
8484
"data": {
85-
"application/javascript": "window.connectPlugin && window.connectPlugin(\"f73b9611-a293-4994-8215-809777c33496\")",
85+
"application/javascript": [
86+
"window.connectPlugin && window.connectPlugin(\"f73b9611-a293-4994-8215-809777c33496\")"
87+
],
8688
"text/plain": [
8789
"<IPython.core.display.Javascript object>"
8890
]
@@ -288,7 +290,9 @@
288290
},
289291
{
290292
"data": {
291-
"application/javascript": "window.connectPlugin && window.connectPlugin(\"f73b9611-a293-4994-8215-809777c33496\")",
293+
"application/javascript": [
294+
"window.connectPlugin && window.connectPlugin(\"f73b9611-a293-4994-8215-809777c33496\")"
295+
],
292296
"text/plain": [
293297
"<IPython.core.display.Javascript object>"
294298
]
@@ -340,7 +344,7 @@
340344
"name": "python",
341345
"nbconvert_exporter": "python",
342346
"pygments_lexer": "ipython3",
343-
"version": "3.10.6"
347+
"version": "3.9.13"
344348
}
345349
},
346350
"nbformat": 4,

examples/integrations/itk/3DImage.ipynb

Lines changed: 14 additions & 27 deletions
Large diffs are not rendered by default.

itkwidgets/integrations/__init__.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ def _get_viewer_image(image, label=False):
4747
method = Methods.DASK_IMAGE_NEAREST
4848
else:
4949
method = Methods.DASK_IMAGE_GAUSSIAN
50-
50+
5151
store, chunk_store = _make_multiscale_store()
5252

5353
if HAVE_MULTISCALE_SPATIAL_IMAGE:
54+
from multiscale_spatial_image import MultiscaleSpatialImage
5455
if isinstance(image, MultiscaleSpatialImage):
5556
image.to_zarr(store, compute=True)
5657
return store
@@ -59,6 +60,7 @@ def _get_viewer_image(image, label=False):
5960
ngff_image = itk_image_to_ngff_image(image)
6061
multiscales = to_multiscales(ngff_image, method=method)
6162
to_ngff_zarr(store, multiscales, chunk_store=chunk_store)
63+
return store
6264

6365
if HAVE_ITK:
6466
import itk
@@ -152,10 +154,6 @@ def _detect_render_type(data, input_type) -> RenderType:
152154
return RenderType.IMAGE
153155
elif isinstance(data, itkwasm.PointSet):
154156
return RenderType.POINT_SET
155-
elif HAVE_MULTISCALE_SPATIAL_IMAGE:
156-
from multiscale_spatial_image import MultiscaleSpatialImage
157-
if isinstance(data, MultiscaleSpatialImage):
158-
return RenderType.IMAGE
159157
elif isinstance(data, (zarr.Array, zarr.Group)):
160158
# For now assume zarr.Group is an image
161159
# In the future, once NGFF supports point sets fully
@@ -175,6 +173,10 @@ def _detect_render_type(data, input_type) -> RenderType:
175173
import itk
176174
if isinstance(data, itk.Image):
177175
return RenderType.IMAGE
176+
if HAVE_MULTISCALE_SPATIAL_IMAGE:
177+
from multiscale_spatial_image import MultiscaleSpatialImage
178+
if isinstance(data, MultiscaleSpatialImage):
179+
return RenderType.IMAGE
178180
if HAVE_VTK:
179181
import vtk
180182
if isinstance(data, vtk.vtkImageData):
@@ -200,8 +202,8 @@ def _detect_render_type(data, input_type) -> RenderType:
200202
return RenderType.POINT_SET
201203
else:
202204
return RenderType.IMAGE
203-
if isinstance(data, xr.Dataset):
204-
if input_type == 'point_sets':
205-
return RenderType.POINT_SET
206-
else:
207-
return RenderType.IMAGE
205+
if isinstance(data, xr.Dataset):
206+
if input_type == 'point_sets':
207+
return RenderType.POINT_SET
208+
else:
209+
return RenderType.IMAGE

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dependencies = [
3838
"itkwasm >= 1.0b1",
3939
"imjoy-rpc >= 0.5.16",
4040
"imjoy-utils >= 0.1.2",
41-
"ngff-zarr[dask-image] >= 0.1.0",
41+
"ngff-zarr[dask-image] >= 0.1.2",
4242
"numcodecs",
4343
"zarr",
4444
]

0 commit comments

Comments
 (0)