Skip to content

Commit

Permalink
Merge pull request #8 from haesleinhuepf/zoom
Browse files Browse the repository at this point in the history
Zoom, Insight, Documentation
  • Loading branch information
haesleinhuepf authored Dec 23, 2022
2 parents 7e0b0df + 96ca544 commit 3db7292
Show file tree
Hide file tree
Showing 11 changed files with 3,865 additions and 1,337 deletions.
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# stackview
# stackview 🧊👀
Interactive image stack viewing in jupyter notebooks based on
[ipycanvas](https://ipycanvas.readthedocs.io/) and
[ipywidgets](https://ipywidgets.readthedocs.io/en/latest/).
Expand Down Expand Up @@ -28,31 +28,62 @@ If you run the installation from within a notebook, you need to restart Jupyter
You can use `stackview` from within jupyter notebooks as shown below.
Also check out the demo in [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/haesleinhuepf/stackview/HEAD?filepath=docs%2Fdemo.ipynb)

There are also example notebooks in [this folder](https://github.com/haesleinhuepf/stackview/tree/main/docs).

Starting point is a 3D image dataset provided as numpy array.
```python
from skimage.io import imread
image = imread('data/Haase_MRT_tfl3d1.tif', plugin='tifffile')
```

### Slice view

You can then view it slice-by-slice:
```python
import stackview
stackview.slice(image, continuous_update=True)
```
![](https://raw.githubusercontent.com/haesleinhuepf/stackview/main/docs/images/demo_slice.gif)

### Static insight views

The `insight` function turns a numpy-array into a numpy-compatible array that has an image-display in jupyter notebooks.

```python
insight(image[60])
```

![img.png](https://raw.githubusercontent.com/haesleinhuepf/stackview/main/docs/images/insight_demo.png)

Images of 32-bit and 64-bit type integer are displayed as labels.

```python
blobs = imread('data/blobs.tif')
labels = label(blobs > 120)

insight(labels)
```

![img.png](https://raw.githubusercontent.com/haesleinhuepf/stackview/main/docs/images/labels_demo.png)

### Pick intensities

To read the intensity of pixels where the mouse is moving, use the picker.
```python
stackview.picker(image, continuous_update=True)
```
![](https://raw.githubusercontent.com/haesleinhuepf/stackview/main/docs/images/demo_picker.gif)

### Orthogonal view

Orthogonal views are also available:
```python
stackview.orthogonal(image, continuous_update=True)
```
![](https://raw.githubusercontent.com/haesleinhuepf/stackview/main/docs/images/demo_orthogonal.gif)

### Curtain

Furthermore, to visualize an original image in combination with a processed version, a curtain view may be helpful:
```python
stackview.curtain(image, modified_image * 65537, continuous_update=True)
Expand All @@ -77,13 +108,17 @@ stackview.curtain(slice_image, labels, continuous_update=True)

![](https://raw.githubusercontent.com/haesleinhuepf/stackview/main/docs/images/demo_curtain3.gif)

### Side-by-side view

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:
```python
stackview.side_by_side(image_stack[1:], image_stack[:-1], continuous_update=True, display_width=300)
```
![](https://raw.githubusercontent.com/haesleinhuepf/stackview/main/docs/images/demo_side_by_side.gif)

### Interact

Exploration of the parameter space of image processing functions is available using `interact`:
```python
from skimage.filters.rank import maximum
Expand Down Expand Up @@ -120,6 +155,18 @@ stackview.interact(gaussian, context=globals(), continuous_update=True)

![](https://raw.githubusercontent.com/haesleinhuepf/stackview/main/docs/images/demo_interact4.gif)

To add an `insight`-view automatically to results of functions, you can add this.

```python
@jupyter_displayable_output
def my_gaussian(image, sigma):
return gaussian(image, sigma)

my_gaussian(image[60], 2)
```

![img.png](https://raw.githubusercontent.com/haesleinhuepf/stackview/main/docs/images/jupyter_displayable_output.png)

## Contributing

Contributions, bug-reports and ideas for further development are very welcome.
Expand All @@ -135,6 +182,7 @@ If you encounter any problems, please create a thread on [image.sc] along with a

## See also
There are other libraries doing similar stuff
* [ipyannotations](https://github.com/janfreyberg/ipyannotations)
* [napari](https://github.com/napari/napari)
* [JNI's Volume Viewer based on Matplotlib](https://github.com/jni/mpl-volume-viewer)
* [Holoviz hvPlot](https://hvplot.holoviz.org/user_guide/Gridded_Data.html#n-d-plots)
Expand Down
2,855 changes: 1,565 additions & 1,290 deletions docs/demo.ipynb

Large diffs are not rendered by default.

Binary file added docs/images/insight_demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/jupyter_displayable_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/labels_demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
491 changes: 491 additions & 0 deletions docs/insight.ipynb

Large diffs are not rendered by default.

1,636 changes: 1,636 additions & 0 deletions docs/zoom.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="stackview",
version="0.3.7",
version="0.3.8",
author="Robert Haase",
author_email="[email protected]",
description="Interactive image stack viewing in jupyter notebooks",
Expand Down
Loading

0 comments on commit 3db7292

Please sign in to comment.