napari-n2v

Logo

A self-supervised denoising algorithm.

View the Project on GitHub juglab/napari-n2v

Documentation

napari-n2v is based on the original algorithm from the Jug lab Noise2Void, and uses CSBDeep. N2V is a self-supervised algorithm that allows denoising images by removing pixel-independent noise. It also comprises an extension to deal with structured noise, and checkboard artefacts with N2V2.

napari-n2v contains two different napari plugins: N2V train and N2V predict.

  1. N2V train
  2. N2V predict

N2V train

Anatomy

  1. GPU availability
  2. Data loading
  3. Training parameters
  4. Expert training parameters
  5. Training
  6. Training progress
  7. Prediction
  8. Model saving

1 - GPU availability

This small widget checks whether a GPU device is available to TensorFlow. If the GPU is available, then you will see the following:

gpu.png

If the GPU is not available, the widget will show a yellow CPU.

GPU availability does not ensure that the code will run on the GPU, but it is a necessary condition.

2 - Data loading

The data loading panel has two tabs: From layers and From disk :

  1. From layers: Choose among the available napari layers data for the Train and Val. Note that if Val is empty or equal to Train, a portion of the training data will be extracted as validation data.
  2. From disk: Use the choose button to point to folders containing images. The images can be of different dimensions but should have the same axes (e.g. TXY). Note that if Val is empty or equal to Train, a portion of the training data will be extracted as validation data. When selecting a folder for the Train set, the first image will be loaded as sample into napari to estimate the axes (see Axes in the next section).

3 - Training parameters

training_parameters.png

The training parameters are the basic settings you can use to tune your N2V training:

4 - Expert training parameters

The expert training parameters can be set by clicking on the gear button, modifying the relevant settings and closing the window.

expert settings

5 - Training

Depending on the stage of the training, the Training panel has different buttons:

train.png

During training, the log and the weights are saved to a hidden folder in your /home/, under .napari/N2V/models.

6 - Training progress

training_progress.png

The training progress panel shows the following:

7 - Prediction

prediction.png

Prediction is available after training. If you wish to predict on a different set of images or with a model saved to the disk, use the N2V - predict plugin.

The prediction is ran on the Train and Val data that were saved in memory before training. If the images where loaded directly from the disk and they have different dimensions (X, Y, Z), then the results are saved to the disk in a /result/ folder. Otherwise, the predicted images are added to napari.

After training, the panel contains the following elements:

Note: Prediction can take a while to start so be patient and check console outputs to make sure it is running correctly.

8 - Model saving

save.png

After training, the model can be saved to the location of your choice. Aside from saving the model weights, the plugin also saves a config.json file containing all the parameters of the training.. The model weights can be saved in two formats:

N2V predict

Anatomy

Multiple aspects of the N2V - predict plugin are similar to the N2V - train plugin, refer to the latter one for missing information.

  1. Data loading
  2. Parameters
  3. Tiling
  4. Prediction

1 - Data loading

Data can be loaded directly from napari layers or from the disk.

Note that if you select a training folder, the plugin will try to load the first image it finds in order to assert the axes.

2 - Parameters

The parameters Axes and Enable 3D are similar to the corresponding ones in N2V - Train. In addition, model weights should be loaded from the disk and should correspond to a config.json file in the same folder. The plugin throws an error if no configuration is found.

3 - Tiling

Refer to the description of tiling in N2V - Train.

4 - Predict

Apply the model to the images. See the previous sections for details about the prediction modalities.