Skip to content

DiSTNet2D

Maxime Deforet edited this page Jul 12, 2024 · 26 revisions

Segmentation and Tracking with DiSTNet2D

This tutorial is based on the work described in this publication. DiSTNet2D is a deep learning-based method that simultaneously segment and track bacteria, leveraging temporal information from neighboring frames.

We will see how to:

  1. Import trained weights and load a movie to analyze it with DiSTNet2D in BACMMAN
  2. Run the analysis
  3. Visualize and export results

If necessary, install bacmman, along with Tensorflow 2. Follow the Install From FIJI and the Tensorflow 2.x (CPU) or Tensorflow 2.x (GPU) instructions. If you do not know which option to choose between CPU and GPU, choose CPU.

This should work smoothly on Linux, Windows, and MacOS X with Intel CPU. Recent Apple computers (M1/M2/M3) are unsupported.

Launching Bacmman

  1. Start the BACMMAN plugin
  2. In Fiji, go to Plugins > BACMMAN > BACteria in Mother Machine ANalyzer
  3. Set Working directory (at the first use): Right-click on the Working directory area and select a folder where you want to store BACMMAN data.

Creating a new dataset

  1. Go to Dataset > New dataset from online library.
  2. Enter username: jeanollion
  3. Click Load Public Configuration.
  4. Select Distnet2D > PhC-C2DH-PA14 (or Fluo-C2DH-HBEC).
  5. Choose a local name for the dataset.
  6. Click OK.

Downloading sample video

  1. Go to Import/Export > Sample dataset > Cell tracking > Bacteria 2D (or Human Cells 2D).
  2. Choose a local folder to save the .tif file.
  3. Click Download.

Loading and processing a video

Load video into BACMMAN:

  1. Click on the Home tab.
  2. Right-click in the Position window area.
  3. Select Import/re-link image.
  4. Navigate to the folder where the .tif file is saved and select the file.

Test in simplified mode:

  1. Click on the Configuration test tab.
  2. Select Simplified in the Test mode area.
  3. Select Processing in the Step area.
  4. You can reduce the frame range to speed up computation: Right-click on the Frame range area and move the sliders.
  5. Right-click on DistNet2D > Test Segmentation and Tracking to launch the computation.
  6. The first time you launch, there may be a long initialization of the database (dozens of seconds).

CPU processing time for the bacterial sample dataset:

  • Macbook early 2015, with MacOS Mojave: 10 seconds/frame
  • PC with Intel Core i7-8559U and Windows 11: 3 seconds/frame
  • PC with Intel Core i7-8700 and Windows 11: 2 seconds/frame
  • AMD Ryzen 3 5425u with Ubuntu 22.04: 3 seconds/frame

The results are displayed in a "Hyperstack" window, where each color represents a track. The EDM and center map are displayed as well.

Test in advanced mode:

  1. Click on the Configuration test tab.
  2. Select Advanced in the Test mode area. The configuration tree now shows all available options for the Prediction, Segmentation, and Tracking stages. By default, all settings are adequate for processing the provided datasets, but you can adjust them as needed.
  3. Right-click on an option to explore the possible values (among a drop-down menu or a numerical value).
  4. Select Processing in the Step area.
  5. You can reduce the frame range to speed up computation: Right-click on the Frame range area and move the sliders.
  6. Right-click on DistNet2D > Test Segmentation and Tracking to launch the computation.
  7. In advanced mode, all predicted proxies are displayed along the result window (EDM, GDCM, centers, dX, dY). Feel free to explore all the proxies, change settings and see the effect on the results. For instance, if you increase the Tracker:DistNet2D > Segmentation > Min Max EDM Threshold, less cells will be detected.
  8. The post-processing stage can be turned off with the option Tracking>Post- Processing>NO_POST_PROCESSING.
  9. If you are satisfied with the current configuration, you can now process the entire movie.

Process the entire movie:

  1. Click the Home tab.
  2. Select the position you want to process in the Position window area, select Bacteria in the Objects area, select Segment and Track in the Tasks area.
  3. Go to menu Run > Run selected task.
  4. The result database is automatically saved on the hard drive in the subfolder corresponding to the position, within the folder defined as the working directory.

Visualizing and editing results

Visualize the results:

  1. After the processing is complete, go to the Data Browsing tab.
  2. Right-click on the position name corresponding to the position you analyzed in the Segmentation & Tracking Results area.
  3. Select Open Hyperstack > Bacteria.
  4. A window showing the analyzed movie opens. To display the results, press Ctrl+Q.
  5. In track mode, the contour of each cell is colored according to its track ID. Each press on Ctrl+Q randomizes the contour colors. In object mode, all contours are displayed in pink. To switch between modes, press S.
  6. All the shortcuts are listed in the Help window (F1).

Edit the results:

  • You can make edits to the results such as creating a cell, splitting a cell, merging multiple cells, and more.
  • You can create or delete links.
  • Refer to the Help windows (F1) for the complete lists of tools, and this page about data curation for further assistance.
  • All changes are automatically saved on the database file (unless the safe mode is activated, by pressing U).

Exporting data

Export as tabular data:

  1. Go to menu Options > Measurements > Extract by position. Select true.
  2. Click on the Home tab.
  3. Select the position you want to process in the Position window area, select Bacteria in the Objects area, select Measurements in the Task area.
  4. Go to menu Run > Run selected task.
  5. The software performs measurements on every track.
  6. Select the position you want to process in the Position window area, select Bacteria in the Objects area, select Extract measurements in the Task area.
  7. Select the menu Run > Run selected task.
  8. A .csv file is created in the dataset folder.

Export as label image:

  1. Click on the Data Browsing tab.
  2. Right-click on the position you want to process and select Create Selection > Viewfield.
  3. Click on the Home tab.
  4. Right-click in the Tasks to execute area and select Extract Dataset > Add new dataset extraction task to list.
  5. Click on Viewfield in the Selections area.
  6. Right-click on output file and enter a name for the file.
  7. Click on the arrow left to Features, then on the arrow next to Feature #0. Right-click on Feature and select Modules > Labels.
  8. Click OK. Then, right-click in the Tasks to execute area and select Run all tasks.
  9. A .hdf5 file is created in the dataset folder. This file contains the label images and can be opened within Fiji.