Skip to main content

Interactive image stack viewing in jupyter notebooks

Project description

stackview

Interactive image stack viewing in jupyter notebooks based on ipycanvas and ipywidgets. TL;DR:

stackview.curtain(image, labels, continuous_update=True)

Installation

stackview can be installed using conda or pip.

conda install -c conda-forge stackview

OR

pip install stackview

If you run the installation from within a notebook, you need to restart Jupyter (not just the kernel), before you can use stackview.

Usage

You can use stackview from within jupyter notebooks as shown below. Also check out the demo notebook on google colab or in Binder

Starting point is a 3D image dataset provided as numpy array.

from skimage.io import imread
image = imread('data/Haase_MRT_tfl3d1.tif', plugin='tifffile')

You can then view it slice-by-slice:

import stackview
stackview.slice(image, continuous_update=True)

To read the intensity of pixels where the mouse is moving, use the picker.

stackview.picker(image, continuous_update=True)

Orthogonal views are also available:

stackview.orthogonal(image, continuous_update=True)

Furthermore, to visualize an original image in combination with a processed version, a curtain view may be helpful:

stackview.curtain(image, modified_image * 65537, continuous_update=True)

The curtain also works with 2D data. Btw. to visualize both images properly, you need adjust their grey value range yourself. For example, multiply a binary image with 255 so that it visualizes nicely side-by-side with the original image in 8-bit range:

binary = (slice_image > threshold_otsu(slice_image)) * 255
stackview.curtain(slice_image, binary, continuous_update=True)

The same also works with label images

from skimage.measure import label
labels = label(binary)
stackview.curtain(slice_image, labels, continuous_update=True)

A side-by-side view for colocalization visualization is also available. If you're working with time-lapse data, you can also use this view for visualizing differences between timepoints:

stackview.side_by_side(image_stack[1:], image_stack[:-1], continuous_update=True, display_width=300)

Exploration of the parameter space of image processing functions is available using interact:

from skimage.filters.rank import maximum
stackview.interact(maximum, slice_image)

This might be useful for custom functions implementing image processing workflows:

from skimage.filters import gaussian, threshold_otsu, sobel
def my_custom_code(image, sigma:float = 1, show_labels: bool = True):
    sigma = abs(sigma)
    blurred_image = gaussian(image, sigma=sigma)
    binary_image = blurred_image > threshold_otsu(blurred_image)
    edge_image = sobel(binary_image)
    
    if show_labels:
        return label(binary_image)
    else:
        return edge_image * 255 + image 

stackview.interact(my_custom_code, slice_image)

Contributing

Contributions, bug-reports and ideas for further development are very welcome.

License

Distributed under the terms of the BSD-3 license, "stackview" is free and open source software

Issues

If you encounter any problems, please create a thread on image.sc along with a detailed description and tag @haesleinhuepf.

See also

There are other libraries doing similar stuff

Project details


Download files

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

Source Distribution

stackview-0.3.3.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stackview-0.3.3-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file stackview-0.3.3.tar.gz.

File metadata

  • Download URL: stackview-0.3.3.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for stackview-0.3.3.tar.gz
Algorithm Hash digest
SHA256 4f7a279e3b6cd18bf7db3bd2dc447897296cfd416ce3c73ec66d5e84d38ae2c6
MD5 64530d1fffca59f314efd482ee876702
BLAKE2b-256 a1d144f4345abb3a36cbeeb6f7e8b7e17b7422b985562f6103a68708df7f0ec6

See more details on using hashes here.

File details

Details for the file stackview-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: stackview-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for stackview-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1c88ab048fc916227c5a61d14a089df6e42ec9e1ae5a8997914da21bdd681125
MD5 2a458daa0a2546fb961eac9322fb3675
BLAKE2b-256 1cd6112d419446a674cf5fad2c1a5e2b95b7fa9864f842b90917f39bdfb562d0

See more details on using hashes here.

Supported by

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