From 0c83dd26b3cad778abf28e9f1f90669fef19b815 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 4 Oct 2022 17:34:59 -0400 Subject: [PATCH 1/4] BUG: Additional fixes following python 3.7 backport --- itkwidgets/integrations/__init__.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/itkwidgets/integrations/__init__.py b/itkwidgets/integrations/__init__.py index 931d0c56..05c78880 100644 --- a/itkwidgets/integrations/__init__.py +++ b/itkwidgets/integrations/__init__.py @@ -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 @@ -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 @@ -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 @@ -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): @@ -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 From a2061e76e69d68bf14d1d8b1aef0e1037cb3cbda Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 4 Oct 2022 17:54:03 -0400 Subject: [PATCH 2/4] DOC: Update 3DImage example screenshot --- examples/integrations/itk/3DImage.ipynb | 41 +++++++++---------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/examples/integrations/itk/3DImage.ipynb b/examples/integrations/itk/3DImage.ipynb index 5b9779c6..7c218318 100644 --- a/examples/integrations/itk/3DImage.ipynb +++ b/examples/integrations/itk/3DImage.ipynb @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -41,24 +41,18 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", - " \n", - " \n", @@ -74,7 +68,7 @@ { "data": { "application/javascript": [ - "window.connectPlugin && window.connectPlugin(\"2977bbb5-0733-4fe0-9687-d5ff41603b9f\")" + "window.connectPlugin && window.connectPlugin(\"4ab312b3-0391-4860-9ae5-7bd12a9daa1d\")" ], "text/plain": [ "" @@ -86,7 +80,7 @@ { "data": { "text/html": [ - "
" + "
" ], "text/plain": [ "" @@ -98,25 +92,18 @@ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 4, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "image = itk.imread(file_name)\n", - "view(image, rotate=True, gradient_opacity=0.4)" + "view(image, rotate=True, gradient_opacity=0.55)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -135,7 +122,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.9.13" } }, "nbformat": 4, From c06089250fbb7dc08b27c41da354bfbd176ecd3f Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 4 Oct 2022 17:54:35 -0400 Subject: [PATCH 3/4] ENH: Add itk examples to notebook CI tests --- .github/workflows/notebook-test.yml | 3 ++- examples/integrations/dask/DaskArray.ipynb | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/notebook-test.yml b/.github/workflows/notebook-test.yml index 60c9c780..be417c2c 100644 --- a/.github/workflows/notebook-test.yml +++ b/.github/workflows/notebook-test.yml @@ -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 diff --git a/examples/integrations/dask/DaskArray.ipynb b/examples/integrations/dask/DaskArray.ipynb index 1535a0d1..5536a484 100644 --- a/examples/integrations/dask/DaskArray.ipynb +++ b/examples/integrations/dask/DaskArray.ipynb @@ -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": [ "" ] @@ -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": [ "" ] @@ -340,7 +344,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6" + "version": "3.9.13" } }, "nbformat": 4, From ebfcd8ee66e2518d370954d86cb5dde6ed13ae99 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 5 Oct 2022 10:18:08 -0400 Subject: [PATCH 4/4] BUG: Bump ngff-zarr required version to 0.1.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ac2edf8c..058b055a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", ]