diff --git a/examples/integrations/itk/ThinPlateSpline.ipynb b/examples/integrations/itk/ThinPlateSpline.ipynb
index 71965937..8509bcab 100644
--- a/examples/integrations/itk/ThinPlateSpline.ipynb
+++ b/examples/integrations/itk/ThinPlateSpline.ipynb
@@ -1,397 +1,399 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "e301a0a8-f895-41e9-a4f8-dc89537d4b56",
- "metadata": {},
- "source": [
- "### Try this notebook in Google Colab, Binder or SageMaker!\n",
- "\n",
- "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/InsightSoftwareConsortium/itkwidgets/blob/main/examples/integrations/itk/ThinPlateSpline.ipynb)\n",
- "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/HEAD?labpath=examples%2Fintegrations%2Fitk%2FThinPlateSpline.ipynb)\n",
- "[![Open In SageMaker Studio Lab](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github.com/InsightSoftwareConsortium/itkwidgets/blob/main/examples/integrations/itk/ThinPlateSpline.ipynb)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "id": "d3191936-191e-4d8d-b797-4b5376f7caa9",
- "metadata": {},
- "outputs": [],
- "source": [
- "import sys, os\n",
- "\n",
- "!{sys.executable} -m pip install -q tqdm pooch \"itk>=5.3.0\" \"itkwidgets[all]>=1.0a29\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "id": "67df7916-4a81-4880-b575-f65dfab17bd5",
- "metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "0.1.43ubuntu1 is an invalid version and will not be supported in a future release\n",
- "1.1build1 is an invalid version and will not be supported in a future release\n",
- "1.12.1-git20200711.33e2d80-dfsg1-0.6 is an invalid version and will not be supported in a future release\n"
- ]
- }
- ],
- "source": [
- "import itk\n",
- "import pooch\n",
- "import numpy as np\n",
- "from itkwidgets import view, compare_images"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "id": "dca03164-73f6-41fb-abd2-bb9b76f2fa74",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Download data\n",
- "files = pooch.retrieve(\n",
- " url='https://bafybeidii6e4zhuswkhw7tm3dalmfw5yt4mja5yf3gb7t4jur3rdgdecve.ipfs.w3s.link/ipfs/bafybeidii6e4zhuswkhw7tm3dalmfw5yt4mja5yf3gb7t4jur3rdgdecve/DeformAVolumeWithAThinPlateSpline.zip',\n",
- " known_hash='sha256:d267f9216d11c3f953b3a2601f38d1434ab97c17834dca0ad1b3ff558226c9c1',\n",
- " processor=pooch.Unzip(), path=\"./\", fname=\"ThinPlateSpline\", progressbar=True)\n",
- "file_path = os.path.commonpath(files)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "id": "53b5b965-497e-46b7-8c14-d157ff5fed4f",
- "metadata": {},
- "outputs": [],
- "source": [
- "source_landmarks = os.path.join(file_path, \"SourceLandmarks.vtk\")\n",
- "target_landmarks = os.path.join(file_path, \"TargetLandmarks.vtk\")\n",
- "input_image = os.path.join(file_path, \"brainweb165a10f17.mha\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "id": "2b3e6002-73f1-4971-8d43-b4a20681635b",
- "metadata": {},
- "outputs": [],
- "source": [
- "Dimension = 3\n",
- "thin_plate_spline = itk.ThinPlateSplineKernelTransform[itk.D, Dimension].New()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "id": "f9bcdbb3-6140-4a0e-b654-446438761356",
- "metadata": {},
- "outputs": [],
- "source": [
- "source_landmarks_mesh = itk.meshread(source_landmarks)\n",
- "# Cast points from float32 to float64\n",
- "points = itk.array_from_vector_container(source_landmarks_mesh.GetPoints())\n",
- "points = points.astype(np.float64)\n",
- "source_landmarks = thin_plate_spline.GetSourceLandmarks()\n",
- "source_landmarks.SetPoints(itk.vector_container_from_array(points.flatten()))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "id": "43d2f0b2-8268-424c-83c2-cc932e3ea598",
- "metadata": {},
- "outputs": [],
- "source": [
- "target_landmarks_mesh = itk.meshread(target_landmarks)\n",
- "# Cast points from float32 to float64\n",
- "points = itk.array_from_vector_container(target_landmarks_mesh.GetPoints())\n",
- "points = points.astype(np.float64)\n",
- "target_landmarks = thin_plate_spline.GetTargetLandmarks()\n",
- "target_landmarks.SetPoints(itk.vector_container_from_array(points.flatten()))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "id": "717e7802-99a8-4b18-8335-6f753153286a",
- "metadata": {},
- "outputs": [],
- "source": [
- "thin_plate_spline.ComputeWMatrix()\n",
- "\n",
- "input_image = itk.imread(input_image)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 9,
- "id": "290df31a-3397-40da-9449-fea1b2b0da40",
- "metadata": {},
- "outputs": [],
- "source": [
- "deformed = itk.resample_image_filter(\n",
- " input_image,\n",
- " use_reference_image=True,\n",
- " reference_image=input_image,\n",
- " transform=thin_plate_spline,\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 13,
- "id": "5c4666c9",
- "metadata": {
- "scrolled": false
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- " \n",
- " \n",
- " "
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/javascript": [
- "window.connectPlugin && window.connectPlugin(\"59b59642-a9fa-4b5b-987b-dbb723b5de64\")"
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- ""
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/plain": [
- ""
- ]
- },
- "execution_count": 13,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "compare_images(fixed_image=input_image, moving_image=deformed, method='checkerboard', pattern=(5, 5, 2), swap_image_order=False)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "c24dc51f",
- "metadata": {},
- "source": [
- "Besides `checkerboard`, method can be `green-magenta`, `cyan-red`, `cyan-magenta` or `blend`. If the method is `green-magenta` or `cyan-red`, matching images would be grayish white."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 18,
- "id": "4389eba3",
- "metadata": {
- "scrolled": false
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- " \n",
- " \n",
- " "
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/javascript": [
- "window.connectPlugin && window.connectPlugin(\"59b59642-a9fa-4b5b-987b-dbb723b5de64\")"
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- ""
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/plain": [
- ""
- ]
- },
- "execution_count": 18,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "compare_images(input_image, deformed, method='cyan-red')"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "6d4bcac0",
- "metadata": {},
- "source": [
- "If the viewer already has loaded images, you can give the image names to `compare_images`. The moving image must be the last added image. "
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 16,
- "id": "089c6db1",
- "metadata": {
- "scrolled": false
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- " \n",
- " \n",
- " "
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/javascript": [
- "window.connectPlugin && window.connectPlugin(\"59b59642-a9fa-4b5b-987b-dbb723b5de64\")"
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- ""
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "viewer = view(image=input_image)\n",
- "viewer.set_image(deformed, 'deformed')\n",
- "viewer.compare_images('Image', 'deformed', image_mix=.4)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "38133552",
- "metadata": {},
- "source": [
- "Stop comparing image by setting `method='disabled'` or use hamburger menu next to image name in graphical user interface."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "cc71d7ce",
- "metadata": {},
- "outputs": [],
- "source": [
- "# viewer.compare_images(fixed_image='Image', moving_image='deformed', method='disabled')"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3 (ipykernel)",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.10.6"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "e301a0a8-f895-41e9-a4f8-dc89537d4b56",
+ "metadata": {},
+ "source": [
+ "### Try this notebook in Google Colab, Binder or SageMaker!\n",
+ "\n",
+ "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/InsightSoftwareConsortium/itkwidgets/blob/main/examples/integrations/itk/ThinPlateSpline.ipynb)\n",
+ "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/HEAD?labpath=examples%2Fintegrations%2Fitk%2FThinPlateSpline.ipynb)\n",
+ "[![Open In SageMaker Studio Lab](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github.com/InsightSoftwareConsortium/itkwidgets/blob/main/examples/integrations/itk/ThinPlateSpline.ipynb)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "d3191936-191e-4d8d-b797-4b5376f7caa9",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import sys, os\n",
+ "\n",
+ "!{sys.executable} -m pip install -q tqdm pooch \"itk>=5.3.0\" \"itkwidgets[all]>=1.0a29\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "67df7916-4a81-4880-b575-f65dfab17bd5",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "0.1.43ubuntu1 is an invalid version and will not be supported in a future release\n",
+ "1.1build1 is an invalid version and will not be supported in a future release\n",
+ "1.12.1-git20200711.33e2d80-dfsg1-0.6 is an invalid version and will not be supported in a future release\n"
+ ]
+ }
+ ],
+ "source": [
+ "import itk\n",
+ "import pooch\n",
+ "import numpy as np\n",
+ "from itkwidgets import view, compare_images"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "dca03164-73f6-41fb-abd2-bb9b76f2fa74",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Download data\n",
+ "files = pooch.retrieve(\n",
+ " url='https://bafybeidii6e4zhuswkhw7tm3dalmfw5yt4mja5yf3gb7t4jur3rdgdecve.ipfs.w3s.link/ipfs/bafybeidii6e4zhuswkhw7tm3dalmfw5yt4mja5yf3gb7t4jur3rdgdecve/DeformAVolumeWithAThinPlateSpline.zip',\n",
+ " known_hash='sha256:d267f9216d11c3f953b3a2601f38d1434ab97c17834dca0ad1b3ff558226c9c1',\n",
+ " processor=pooch.Unzip(), path=\"./\", fname=\"ThinPlateSpline\", progressbar=True)\n",
+ "file_path = os.path.commonpath(files)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "53b5b965-497e-46b7-8c14-d157ff5fed4f",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "source_landmarks = os.path.join(file_path, \"SourceLandmarks.vtk\")\n",
+ "target_landmarks = os.path.join(file_path, \"TargetLandmarks.vtk\")\n",
+ "input_image = os.path.join(file_path, \"brainweb165a10f17.mha\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "2b3e6002-73f1-4971-8d43-b4a20681635b",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "Dimension = 3\n",
+ "thin_plate_spline = itk.ThinPlateSplineKernelTransform[itk.D, Dimension].New()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "f9bcdbb3-6140-4a0e-b654-446438761356",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "source_landmarks_mesh = itk.meshread(source_landmarks)\n",
+ "# Cast points from float32 to float64\n",
+ "points = itk.array_from_vector_container(source_landmarks_mesh.GetPoints())\n",
+ "points = points.astype(np.float64)\n",
+ "source_landmarks = thin_plate_spline.GetSourceLandmarks()\n",
+ "source_landmarks.SetPoints(itk.vector_container_from_array(points.flatten()))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "43d2f0b2-8268-424c-83c2-cc932e3ea598",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "target_landmarks_mesh = itk.meshread(target_landmarks)\n",
+ "# Cast points from float32 to float64\n",
+ "points = itk.array_from_vector_container(target_landmarks_mesh.GetPoints())\n",
+ "points = points.astype(np.float64)\n",
+ "target_landmarks = thin_plate_spline.GetTargetLandmarks()\n",
+ "target_landmarks.SetPoints(itk.vector_container_from_array(points.flatten()))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "id": "717e7802-99a8-4b18-8335-6f753153286a",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "thin_plate_spline.ComputeWMatrix()\n",
+ "\n",
+ "input_image = itk.imread(input_image)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "id": "290df31a-3397-40da-9449-fea1b2b0da40",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "deformed = itk.resample_image_filter(\n",
+ " input_image,\n",
+ " use_reference_image=True,\n",
+ " reference_image=input_image,\n",
+ " transform=thin_plate_spline,\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "id": "5c4666c9",
+ "metadata": {
+ "scrolled": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ " \n",
+ " \n",
+ " "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/javascript": "window.connectPlugin && window.connectPlugin(\"59b59642-a9fa-4b5b-987b-dbb723b5de64\")",
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 13,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "compare_images(fixed_image=input_image, moving_image=deformed, method='checkerboard', pattern=(5, 5, 2), swap_image_order=False)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "c24dc51f",
+ "metadata": {},
+ "source": [
+ "Besides `checkerboard`, method can be `green-magenta`, `cyan-red`, `cyan-magenta` or `blend`. If the method is `green-magenta` or `cyan-red`, matching images would be grayish white."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "id": "4389eba3",
+ "metadata": {
+ "scrolled": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ " \n",
+ " \n",
+ " "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/javascript": "window.connectPlugin && window.connectPlugin(\"59b59642-a9fa-4b5b-987b-dbb723b5de64\")",
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 18,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "compare_images(input_image, deformed, method='cyan-red')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "6d4bcac0",
+ "metadata": {},
+ "source": [
+ "If the viewer already has loaded images, you can give the image names to `compare_images`. The moving image must be the last added image. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "id": "089c6db1",
+ "metadata": {
+ "scrolled": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ " \n",
+ " \n",
+ " "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/javascript": "window.connectPlugin && window.connectPlugin(\"59b59642-a9fa-4b5b-987b-dbb723b5de64\")",
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "viewer = view(image=input_image)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "viewer.set_image(deformed, 'deformed')\n",
+ "viewer.compare_images('Image', 'deformed', image_mix=.4)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "38133552",
+ "metadata": {},
+ "source": [
+ "Stop comparing image by setting `method='disabled'` or use hamburger menu next to image name in graphical user interface."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "cc71d7ce",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# viewer.compare_images(fixed_image='Image', moving_image='deformed', method='disabled')"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.10.6"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/itkwidgets/_initialization_params.py b/itkwidgets/_initialization_params.py
index 7dc571a2..f98a36fe 100644
--- a/itkwidgets/_initialization_params.py
+++ b/itkwidgets/_initialization_params.py
@@ -4,8 +4,8 @@
from itkwidgets.viewer_config import MUI_HREF, PYDATA_SPHINX_HREF
-INPUT_OPTIONS = ["image", "label_image", "point_set", "data"]
-
+DATA_OPTIONS = ["image", "label_image", "point_set", "data", "fixed_image"]
+INPUT_OPTIONS = [*DATA_OPTIONS, "compare"]
def init_params_dict(itk_viewer):
return {
@@ -75,7 +75,7 @@ def parse_input_data(init_data_kwargs):
def build_init_data(input_data):
result= None
- for input_type in INPUT_OPTIONS:
+ for input_type in DATA_OPTIONS:
data = input_data.pop(input_type, None)
if data is None:
continue
@@ -84,6 +84,9 @@ def build_init_data(input_data):
if input_type == 'label_image':
result = _get_viewer_image(data, label=True)
render_type = RenderType.LABELIMAGE
+ elif input_type == 'fixed_image':
+ result = _get_viewer_image(data)
+ render_type = RenderType.FIXEDIMAGE
else:
result = _get_viewer_image(data, label=False)
elif render_type is RenderType.POINT_SET:
@@ -95,5 +98,5 @@ def build_init_data(input_data):
def defer_for_data_render(init_data):
- deferred_keys = ['image', 'labelImage']
+ deferred_keys = ['image', 'labelImage', 'fixedImage']
return any([k in init_data.keys() for k in deferred_keys])
diff --git a/itkwidgets/integrations/__init__.py b/itkwidgets/integrations/__init__.py
index a0b0cdd3..8176db50 100644
--- a/itkwidgets/integrations/__init__.py
+++ b/itkwidgets/integrations/__init__.py
@@ -163,7 +163,9 @@ def _get_viewer_point_set(point_set):
def _detect_render_type(data, input_type) -> RenderType:
- if input_type == 'image' or input_type == 'label_image':
+ if (input_type == 'image' or
+ input_type == 'label_image' or
+ input_type == 'fixed_image'):
return RenderType.IMAGE
elif input_type == 'point_set':
return RenderType.POINT_SET
diff --git a/itkwidgets/render_types.py b/itkwidgets/render_types.py
index 0dfd2b7b..21c129c3 100644
--- a/itkwidgets/render_types.py
+++ b/itkwidgets/render_types.py
@@ -6,3 +6,4 @@ class RenderType(Enum):
LABELIMAGE = "labelImage"
GEOMETRY = "geometry"
POINT_SET = "pointSets"
+ FIXEDIMAGE = "fixedImage"
diff --git a/itkwidgets/standalone_server.py b/itkwidgets/standalone_server.py
index f52b3ac7..9ca2117b 100644
--- a/itkwidgets/standalone_server.py
+++ b/itkwidgets/standalone_server.py
@@ -22,7 +22,7 @@
build_config,
build_init_data,
init_params_dict,
- INPUT_OPTIONS,
+ DATA_OPTIONS,
)
from itkwidgets.viewer import view
from ngff_zarr import detect_cli_io_backend, cli_input_to_ngff_image, ConversionBackend
@@ -88,7 +88,7 @@ def input_dict(viewer_options):
def read_files(viewer_options):
user_input = vars(viewer_options)
reader = user_input.get("reader", None)
- for param in INPUT_OPTIONS:
+ for param in DATA_OPTIONS:
input = user_input.get(param, None)
if input:
if reader:
diff --git a/itkwidgets/viewer.py b/itkwidgets/viewer.py
index 1f7ebe25..9f13b354 100644
--- a/itkwidgets/viewer.py
+++ b/itkwidgets/viewer.py
@@ -138,6 +138,8 @@ def __init__(
self.name = self.__str__()
input_data = parse_input_data(add_data_kwargs)
data = build_init_data(input_data)
+ if compare := input_data.get('compare'):
+ data['compare'] = compare
if ENVIRONMENT is not Env.HYPHA:
self.viewer_rpc = ViewerRPC(
ui_collapsed=ui_collapsed, rotate=rotate, ui=ui, init_data=data, parent=self.name, **add_data_kwargs
@@ -615,7 +617,19 @@ def compare_images(fixed_image: Union[str, Image], moving_image: Union[str, Imag
:return: viewer, display by placing at the end of a Jupyter or Colab cell. Query or set properties on the object to change the visualization.
:rtype: Viewer
"""
- viewer = view()
- viewer.compare_images(fixed_image=fixed_image, moving_image=moving_image, method=method, image_mix=image_mix, checkerboard=checkerboard, pattern=pattern, swap_image_order=swap_image_order)
+ options = {}
+ # if None let viewer use defaults or last value.
+ if method is not None:
+ options['method'] = method
+ if image_mix is not None:
+ options['imageMix'] = image_mix
+ if checkerboard is not None:
+ options['checkerboard'] = checkerboard
+ if pattern is not None:
+ options['pattern'] = pattern
+ if swap_image_order is not None:
+ options['swapImageOrder'] = swap_image_order
+
+ viewer = Viewer(data=None, image=moving_image, fixed_image=fixed_image, compare=options)
return viewer