Skip to main content

Jupyter widgets to visualize images in 2D and 3D

Project description

License PyPI Build status https://mybinder.org/badge.svg

Interactive Jupyter widgets to visualize images in 2D and 3D.

itk-jupyter-widgets chest CT in JupyterLab

Key Features:

  • Exquisite volume rendering

  • Tri-plane volume slicing

  • Innovative, powerful opacity transfer function / window / level widget

  • Support for

    • NumPy Arrays

    • itk.Image

    • vtk.vtkImageData

    • Dask Arrays

    • ImageJ / Fiji / ImageJ2 images

    • Additional NumPy Array-like objects

  • Anisotropic voxel spacing supported

  • 3D and 2D image support

  • Line profiles

  • Combine with other ipywidgets to quickly create graphical interfaces to algorithms

itk-jupyter-widgets demo

These widgets are designed to support image analysis with the Insight Toolkit (ITK), but they also work with other spatial analysis tools in the scientific Python ecosystem.

These widgets are built on itk.js and vtk.js.

Examples on Binder

Data types:

Tasks:

Installation

To install the widgets for the Jupyter Notebook with pip:

pip install itkwidgets

or with conda:

conda install -c conda-forge itkwidgets

For Jupyter Lab, additionally run:

jupyter labextension install @jupyter-widgets/jupyterlab-manager itk-jupyter-widgets

Usage

In Jupyter, import the view function:

from itkwidgets import view

Then, call the view function at the end of a cell, passing in the image to examine:

view(image)

For information on additional options, see the view function docstring:

view?

Other available widgets:

  • itkwidgets.line_profile

Advanced Usage

The itk-jupyter-widgets are based on ipywidgets. As a consequence, widgets traits can be queried, assigned, or observed with the viewer object returned by the view function. itk-jupyter-widgets can be combined with other ipywidgets to quickly explore algorithm parameters, create graphical interfaces, or create data visualization dashboards.

Mouse Controls

Left click + drag

Rotate

Right click + drag or shift + left click + drag

Pan

Mouse wheel or control + left click + drag or pinch

Zoom

Alt + left click + drag left-right

Change color transfer function window

Shift + left click + drag top-bottom

Change color transfer function level

Shift + alt + left click + drag top-bottom

Change primary Gaussian volume opacity transfer function magnitude

Keyboard Shortcuts

Keyboard shortcuts take effect when the mouse is positioned inside the viewer. All shortcuts are prefixed with Alt+. Corresponding keys for the Dvorak keyboard layout have the same effect.

Alt + 1

X-plane mode

Alt + 2

Y-plane mode

Alt + 3

Z-plane mode

Alt + 4

Volume rendering mode

Alt + q

Toggle user interface

Alt + w

Toggle region of interest (ROI) selection widget

Alt + e

Reset ROI

Alt + r

Reset camera

Alt + s

Toggle slicing planes in volume rendering mode

Alt + f

Toggle fullscreen

Examples

After installation, try the following examples that demonstrate how to visualize:

or how to:

Troubleshooting

If you experience the notebook warning:

IOPub data rate exceeded.
The notebook server will temporarily stop sending output
to the client in order to avoid crashing it.
To change this limit, set the config variable
`--NotebookApp.iopub_data_rate_limit`.

Set the notebook configuration value:

jupyter notebook --NotebookApp.iopub_data_rate_limit=1e12

Hacking

Participation is welcome! For a development installation (requires Node.js):

git clone https://github.com/InsightSoftwareConsortium/itk-jupyter-widgets.git
cd itk-jupyter-widgets
python -m pip install -r requirements-dev.txt -r requirements.txt
python -m pip install -e .
jupyter nbextension install --py --symlink --sys-prefix itkwidgets
jupyter nbextension enable --py --sys-prefix itkwidgets
jupyter nbextension enable --py --sys-prefix widgetsnbextension
python -m pytest

The above commands will setup your system for development with the Jupyter Notebook. To develop for Jupyter Lab, additionally run:

jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install ./js

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

itkwidgets-0.15.2.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

itkwidgets-0.15.2-py2.py3-none-any.whl (3.8 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file itkwidgets-0.15.2.tar.gz.

File metadata

  • Download URL: itkwidgets-0.15.2.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for itkwidgets-0.15.2.tar.gz
Algorithm Hash digest
SHA256 3ff101ca4c909e9ebe1aeb4197002645cbe8ebd376a645c6362d55c82ffebf00
MD5 3b9514da49f0c3f077d16c2729644d89
BLAKE2b-256 810cad01c9a0e4cf07c9a5b85a7a6423dcbd941e4e18ef41dd0fcf942424ca23

See more details on using hashes here.

File details

Details for the file itkwidgets-0.15.2-py2.py3-none-any.whl.

File metadata

  • Download URL: itkwidgets-0.15.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for itkwidgets-0.15.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1e7731599050bd47979f4c5302cc2046c61714203455ad3806e487692dd6ea2f
MD5 014ab8bac54af68525a693bf6f2b6a43
BLAKE2b-256 1b4291890b48bd188f4400186db2311eb3e17e652181aa318fd7493967fc48b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page