#!/usr/bin/env python # coding: utf-8 # # stackview on google colab # Interactive image stack viewing in jupyter notebooks based on # [ipycanvas](https://ipycanvas.readthedocs.io/) and # [ipywidgets](https://ipywidgets.readthedocs.io/en/latest/). # # In this notebook we demonstate its usage on google colab. # # [Run this notebook in google colab](https://colab.research.google.com/github/haesleinhuepf/stackview/blob/master/docs/colab_demo.ipynb) # # ## Installation # After starting a new session on google colab, you need to install stackview first. # # Also note: The make stackview work in google colab, you need to install ipycanvas==0.11 ([read why](https://github.com/martinRenou/ipycanvas/issues/170#issuecomment-1119200238)). # In[1]: get_ipython().system('pip install stackview==0.16.0 ipycanvas==0.11') # If you ran this for the first time, you need to restart your session. # # ## Usage # First we test the installation by importing the libraries we're going to use # In[2]: import stackview from imageio.v3 import imread from skimage.filters import gaussian # In[3]: # Activate widgets in google colab from google.colab import output output.enable_custom_widget_manager() # Starting point is a 3D image dataset provided as numpy array. # In[4]: image_stack = imread('https://github.com/clEsperanto/clesperanto_example_data/raw/main/Haase_MRT_tfl3d1.tif?raw=true') image_stack.shape # In[5]: stackview.insight(image_stack) # ## Slicing # # We can explore the dataset interactively using `stackview.slice`. # In[6]: stackview.slice(image_stack, zoom_factor=2) # In[7]: foggy_brain = gaussian(image_stack, sigma=1) stackview.curtain(image_stack, foggy_brain, zoom_factor=2) # In[ ]: