Generating workflows with napari¶
This page describes how to generate custom workflows using napari using the calculator-like interface from napari-assistant
. In many ways, this should be reminiscent of using the Macro Recorder
in FIJI/ImageJ, but you will hopefully find it has more flexibility and advantages. Ultimately, our goal is to easily reproduce image processing steps with a napari-workflows
.yaml
file and utilize it for batch processing with napari-ndev:Workflow Widget
.
napari-assistant¶
In order to generate workflows with napari, you may like to pip install napari-ndev[extra-plugins]
to install the napari-assistant and other cooperating plugins. You can then access the assistant via the Plugins menu -> Assistant (clesperanto)
A thorough tutorial on how to use napari-assistant, including video, can be found here. The assistant is quite flexible and both functions and parameters are modifiable on-the-fly, but can be overall quirky at times.
import napari
from napari.utils import nbscreenshot
viewer = napari.Viewer()
viewer.window.resize(1000, 700) # w x h
viewer.window.add_plugin_dock_widget('napari-assistant')
viewer.open_sample('napari', 'human_mitosis')
nbscreenshot(viewer)
2024-09-15 23:13:22.581 | INFO | napari_assistant._gui._category_widget:call_op:178 - gaussian_blur (clesperanto)(..., 1.0, 1.0, 0.0) 2024-09-15 23:13:25.405 | INFO | napari_assistant._gui._category_widget:call_op:178 - median_sphere (clesperanto)(..., 1.0, 1.0, 0.0) 2024-09-15 23:13:26.324 | INFO | napari_assistant._gui._category_widget:call_op:178 - top_hat_box (clesperanto)(..., 10.0, 10.0, 0.0) 2024-09-15 23:13:27.501 | INFO | napari_assistant._gui._category_widget:call_op:178 - voronoi_otsu_labeling (clesperanto)(..., 2.0, 2.0)
Apply processing steps¶
With the napari-assistant, I've selected the 'nuclei' layer and do a few processing steps to label the image. This is flexible for 3D images as well, because napari-workflow will save the 2D or 3D parameters as necessary.
nbscreenshot(viewer)
Save the workflow file¶
Using the 2nd from the lower right button, save and load workflows
-> export workflow to file. I have named this viewer-segment-nuclei-sample.yaml
into the resources folder in the docs library, but you should save it wherever you want to keep it in your project.