Skip to content

Napari

Napari is an extensible framework for viewing, processing and manipulating images and we have developed a plugin to use AFMslicer in Napari, napari-afmslicer.

Installation

We publish napari-afmslicer to PyPI and in turn it appears in the Napari Hub. You can then install it from the Plugins > Install/Uninstall Plugins menu item of Napari.

Dependencies

We include a small selection of plugins as dependencies and these will have been installed automatically when following the installation instructions.

The napari-crop and napari-skimage plugins in particular may be of use to further pre-process images prior to slicing.

Usage

Launching

You can launch Napari from the command line within your Virtual Environment.

napari

You can automatically load the Napari AFMSlicer widgets using...

napari -w napari-afmslicer __all__

This will bring up the widgets on the right-hand side. At the bottom are three tabs allowing you to switch between the Filtering, Slicing and 3D Viewer components.

Screenshot of napari with the filter, slicing and 3D viewer plugins loaded as tabs.

Alternatively the widgets can be launched from the menu under Plugins > AFMSlicer > from which you can enable each components of the plugin. Currently there are three components, each of which can be enabled independently.

  • 3D Viewer
  • Filter
  • Slicing

The difference is that the options for each of the components are stacked on the right rather than being tabbed.

Screenshot of napari with the filter, slicing and 3D viewer plugins loaded individually.

A typical workflow will involve...

  1. Filtering an image and removing scars
  2. Running slicing.

Hovering over any of the text associated with the options will show a short explanation of what it does.

Opening Files

Open files using the menu item File > Open File(s) (accessible via the shortcut Ctrl + O).

Opening files in napari

For each image you have opened you are prompted to select the channel for which you wish to load data. This defaults to Height Sensor so unless you want a different channel just hit return and the dialogue box will disappear and the image will open.

Once opened each image is listed as its own "Layer" in the bottom left of Napari in the Layer List. You can toggle whether a given layer is shown by clicking on the "eye" icon next to it in the Layer List.

Plugins

Plugins, if not already loaded, can be accessed from the Plugins menu where each installed plugin has its own menu item. You can also Install/Uninstall Plugins if there is a particular plugin you want to use that is not available.

Filtering

The parameters for filtering can be configured easily. Unchecking Remove scars will prevent scar removal from running completely. Once you have adjusted the parameters to your preference click on the Filter button and the image will be filtered and a new layer will appear listed on the left and automatically selected showing the effects of filtering. It will have the original images name suffixed with _filtered

Screenshot of napari after filtering an image.

By filtering before cropping a region you will have a clearer view of the features to select.

Cropping

Plugins > napari_crop has three options for cropping, by Crop Regions is the one you are most likely to want to use which allows free hand selection of a region to crop.

Select the filtered layer in the Layer list on the bottom left of the image and click on the Shapes button at the top of the Layer List region (its a box with a trapezoid in).

Creating a Shapes layer

This creates a new layer and the Layer controls box on the left above the Layer List will change and have a number of buttons for selecting and drawing shapes in the image. In the example below we have selected a rectangular region (roughly square) from the image. This is automatically filled in in the Shapes layer of the Crop Regions plugin in the bottom-right of the screen.

Selecting a rectangular region

Once you've select the region you wish to crop click the Run button in the Crop Regions plugin and a new layer will be created.

Slicing

Under the Slicing widget select the filtered image from the pull-down list to the right of Image (typically it will be the layer with the _filtered suffix). Next select the number of Slices to create, the Segmentation method (label is the most common) and other options, in particular the Output directory should be explicitly set. When ready click the Slice Image and Summarise, the image will be sliced and summarised with the output saved to the parameter in the Output directory field.

Screenshot of napari after slicing an image.

3D Viewer

The 3D viewer can be used to view the images in three dimensions. Select the _filtered layer for the Image to be viewed and a number of slices to create this image with (it can be different to those the slicing was performed with).

Screenshot of napari showing a 3D view of an image.