Skip to content

DistNet

Jean Ollion edited this page Jul 17, 2024 · 14 revisions

EDIT 07/2024: DiSTNet is now deprecated. Please use DiSTNet2D, that performs much better event for mother machine data.

Deep Bacteria Segmentation and Tracking with DistNet: Bacmman Module

This tutorial is based on the work described in this publication. DiSTNet is a deep learning-based method that simultaneously segment and track bacteria.

We will see how to:

  1. Use the Online Configuration Library to use DiSTNet in BACMMAN
  2. Download the trained weights of DiSNet from the Online DL Model Library
  3. Perform pre-processing, segmentation & tracking of microchannels and visualize image and results
  4. Use DiSNet

If necessary, install bacmman, along with Tensorflow 2. If you do not know which option to choose between CPU and GPU, choose CPU.

Create a Dataset

Important: If using bacmman for the first time: choose a working directory through right-click on the panel below Working Directory. We will start by creating a dataset using the default template of BACMMAN: Choose menu command: Dataset > New Dataset from Online Library.

Set jeanollion as username in the Github Credentials panel, and select the configuration ExampleDatasets > dataset1

Click OK: this will create a new dataset and open it. In BACMMAN a dataset is a configuration associated to multi-position/multi-channel/muti-frame input images. The configuration can be checked in the Configuration tab.

Download Example Dataset and Import Images

A subset of 50 of the example dataset 1 can be downloaded directly from BACMMAN. To do so, choose menu command: Import > Sample Datasets > Mother Machine > Phase Contrast, and select the directory where it will be downloaded.

Import the downloaded images into the open dataset, by choosing the menu command Run > Import/re-link Images:

An element will appear in the Position panel. To visualize the images right click-on the position and choose Open Input Images

Run Pre-Processing and Microchannel Segmentation & Tracking:

In this case pre-processing consist of an automatic rotation of the images to have microchannels vertically aligned with the open end towards the lower part of the image. The images are also cropped to remove the bright line and useless area of the image.

To run pre-processing and microchannel segmentation & tracking,

  • Select the position (when no position is selected, all positions are processed)
  • Select the tasks: Pre-Processing and Segmentation & Tracking
  • Choose the menu command Run > Run Selected Tasks

To visualize the pre-processed images right-click on the position and choose Open Pre-Processed Images

To visualize the result of microchannel segmentation and tracking:

  • Go to the Data Browsing tab
  • Right-click on the position and choose Open Hyperstack > Microchannels

The pre-processed images will open as a interactive hyperstack (multi-channel & multi-frames image stack), on which microchannels can be selected.

  • To display all segmented microchannels object use the shortcut crtl + A
  • To display all microchannels tracks use the shortcut crtl + Q. Tracks will be displayed as colored contours, each colour corresponding to one track.
  • Note that the shortcut are available from the menu Help > Display Shortcut table and that a shortcut preset adapted for QWERTY keyboards can be chosen from the menu Help > Shortcut Presets

Configure DiSTNet

The configuration template we used do not use DiSTNet to segmente & track bacteria.

To configure DiSTNet:

  1. Open the Configuration Library from the menu Import > Online Configuration Library
  2. Set jeanollion as username if necessary
  3. Select the Step named Processing
  4. Select the following configuration ExampleDatasets > dataset1_distnet [Bacteria] in the Remote Configuration File panel
  5. In the Local object class panel, select Bacteria

The configuration associated to the Bacteria object class of the open dataset will be displayed in the Local Configuration panel, and the configuration loacted on the server in Remote Configuration panel, with differences displayed in blue.

Click on the Copy to Local button to copy the remote configuration (containing DiSTNet) to the open dataset.

Download Model Weights

As DiSTNet is a deep-learning based method, it requires trained weights of the model. To download them:

  1. Go to the Configuration Test tab
  2. In the Step pannel select Processing
  3. Select the Bacteria object class : it's configuration will be displayed below
  4. Unfold the parameters Tracker > Model > Tensorflow Model. The sub-parameter Model File appears in red if the model weights are not there. However it is possible to download them directly from BACMMAN.
  5. Right-click on Tensorflow Model and choose Download Model. The model weights will be downloaded at the path selected in the Model File parameter, that should not appear in red anymore after the download.

Test DiSTNet

  1. Set the Frame Range to 0-49
  2. Right-click on the parameter named Tracker and choose Test Segmentation and Tracking

Several interactive kymograph will be displayed, corresponding to the input image and intermediate images. Bacteria objects and Tracks can be displayed on those kymograph using the shortcuts.

Refer to the hint of the DiSTNet module to parametrize it using the intermediate kymographs.