Skip to content

5. Workflows (Interactive: no coding)

Pradeep Rajasekhar edited this page Sep 28, 2022 · 4 revisions

Workflow

When analyzing images, the goal is apply a sequence of image processing operations to extract quantitative information. The end result can be images or a bunch of tables describing the morphology, cell counts, neighbourhood relationships etc. It is common to generate plenty of intermediate images during analysis, but considering how big Lattice Lightsheet (LLS) data or most Oblique Plane Microscopy (OPM) data can be, this can take up a lot of space. Most of the time, it ends up being cheaper to reanalyze or process the data than to store the processed results. This is not a generalized statement and there are of course exceptions, however, we find that true for most of our use cases. The main goal for a workflow would be to apply a bunch of algorithms sequentially and the workflow should be flexible enough to run most use cases. The Workflow component of napari-lattice enables this by using napar-workflows to process LLS and/or OPM data. The examples here will focus on LLS data.

The two ways to go about it are to generate workflows either:


overview

Overview of using napari-workflows for processing LLS data


You can download some sample datasets from here: https://doi.org/10.5281/zenodo.7117784

Interactive

For this, you should install napari-assistant and napari-pyclesperanto-assistant via napari using Plugins -> Install/Uninstall Plugins. These two plugins allow access to a large ecosystem of image processing algorithms.

For example, we'd like to apply a general image processing workflow:

  • Gaussian Blur (Smoothing)
  • Voronoi Otsu Labelling (Thresholding and Binarise)

You could use the Crop Preview option under Crop and Deskew tab in napari-lattice to crop some LLS data for testing the workflows. It is recommended to start with small cropped volumes as its faster to process.

Once you have your image layer of interest, go to Plugins -> clesperanto-Assistant.

low detection

This may cause the window to open under napari-lattice plugin. You can pop the window out by clicking on the square icon (float this panel)

float

Click on Remove Noise which will create a new image layer and also a box on the right side where you can choose the Operation and the radii of the kernel in x,y and z. In this case, we'll select 1,1 and 1. Note that the layer Result of gaussian_blur is also updated live as you change the parameters. If your image is large, it may take more time. This interactive image analysis is a key feature in clesperanto-assistant and makes it a favourite tool of mine!

gaussian

Next, click on Binarize in the clesperanto: Assistant window, which will bring up the thresholding window You can select threshold_otsu, which will apply an otsu threshold to create a binary image.

img

Follow this up by clicking on Label and using Connected component labeling (clesperanto) which will give each cell a unique id.

labelling

You can view this as a workflow by going to Plugins -> napari-workflow-inspector: Workflow Widget

workflow inspector

You can see that the segmentation is not perfect. So, we can try another method to optimize the labelling. You can delete the threshold and labelling layers. Instead of using a threshold, we can use the Voronoi-Otsu Labelling method.

voronoi_otsu

The workflow inspector will also be updated as you delete and add operations

workflow inspector

It can become crowded, so its worth popping windows out and rearranging things.

workflow inspector

Once we are happy with the workflow, under clesperanto-assistant, we can export the workflow, using Save and load workflows button. Click on the button and Export to workflow file, which will save a file with ymlextension

Save workflow

Apply Workflow to LLS data

This will save the workflow file containing information about the sequence of image processing operations.

Now, you can apply this image processing workflow to any timepoint or channel of interest in your raw lattice lightsheet data.

To do this, delete the layers we just generated and keep only the LLS data layer and cropped data (if any). Alternatively, you can delete all layers, open LLS data again and re-initialize the napari-lattice plugin.

Save lattice-workflow

Go to the Workflow tab in napari-lattice and you can test the workflow on any time/channel of interest under Preview Workflow. In this case, I'm going to run it on timepoint 0 and channel 0.

Select the workflow file we saved by going to Load custom workflow and selecting the yaml file.

Click `Apply and Preview Workflow'.

In the terminal, when you see Workflow complete, a new image layer will be added. This is the label image generated from the image processing workflow we designed earlier.

Save workflow preview

If you want to only try this on an ROI crop, make sure you tick Crop Data and highlight the ROI you're interested in. It will then get the bounding box from the shapes layer under roi layer list.

Save workflow crop roi
Save workflow crop roi_result

Apply Workflow and save output

If you are happy with the workflow, we can now apply to the entire raw data or a range of time and channels, and then save the output either as h5 or tiff.

Save workflow section

For this example, I'm opening a timeseries dataset and will be applying the workflow to the first 3 timepoints and for channel 1.

When clicking Apply Workflow and Save Result, the processing will initiate and you can view the progress in the terminal.

progress

This will save the label images as the output in the specified destination.

When using the workflow option, deskewing and deconvolution does not need to be specified in the workflow. It will be automatically applied by napari-lattice. Deconvolution will have to be selected in the GUI and PSFs provided.