Cell/stalk segmentation

BacStalk is not a tool for segmentation of dense bacterial colonies. For that purpose there are already several tools available such as MicrobeJ or Oufti.

The cell/stalk segmentation view provides tools for cell detection, cell tracking, visualization and object manipulation. Each image is only loaded once it is requested to save memory.

Segmentation view

A typical workflow involves:

  1. Define a region of interest (ROI) by clicking Set at the upper left in the panel Parameters. A draggable and resizeable rectangle appears, whose coordinates are stored in the ROI-field.
    • To unselect the ROI click somewhere in the image with no specific cursor (panning or zooming) selected.
    • To remove the ROI, click Clear.
    • To modify an existing unselected ROI, either click Set again or click on the border of the ROI rectangle to make it editable again.
    • To apply the ROI to all images loaded, click Apply to all.
  2. Setup the Segmentation parameters
    • Adapt the parameter Cell size to the diameter of typical cell in the images.
    • Use Tools ‣ Measure distance to display an interactive ruler.
    • Change the other parameters as needed.
  3. Click Process image to process the current image or Process all images to process the entire data set.
If the Parallel Computing Toolbox is available and Parallel processing is enabled at Parameters ‣ Other, as many images are processed in parallel as many workers are set up in the toolbox preferences. Parallel processing greatly reduces the required processing time.
If an image is reprocessed, the current segmentation result (including manual edits) will be lost!
  1. Click Track cells to track cells among all processed frames (see Cell tracking parameters).
  2. Clicking on an entry in the Cell list, zooms in on and highlights the selected cell.
    • Deselect the Zoom or Pan tool to display a normal mouse pointer for cell/stalk manipulation.
    • To delete a cell, either click on the cell outline, the number displayed next to the cell or check CellDeleted in the cell list. This will change the color of the cell outline and line style to dashed - -.
    • To remove a stalk, click on the stalk in the image. This will change the stalk color and line style to dashed - -.
    • To undo a deletion, click on the dashed line to revert the last operation.
    • To reverse the orientation of a medial axis, click on the medial axis or on the circular marker indicating the pole (set to broadest by default).
If a cell/stalk is manually deleted, the analysis table in the Analysis-view is not automatically updated. Please press the Refresh button above the table.
  1. By clicking on an entry in the Track list the cell with the selected TrackID in the last frame of the corresponding trajectory is displayed and the trajectory is overlayed.


Segmentation parameters

  • Cell size: Typical cell size in pixels. Prior to cell segmentation, the images are enhanced by bandpass-filtering. Cell size defines the size of the filter kernel.
  • Min cell size: Minimum cell size in pixels. Cells below this size threshold are automatically marked as CellDeleted=1 and can be included by clicking on them or deselect CellDeleted in the Cell list.

The following parameters are only available if My cells… … have stalks is checked in the image input tab (see Image input).

  • Cell expansion width: Prior to stalk detection, cells are expanded (dilated) by the indicated number of pixels to search for the stalk attachment point. If the cells are surrounded by a bright ring, increasing this value might increase the stalk detection frequency.
  • Stalk screening length: Maximum stalk search length in pixels.
  • Min stalk length: Minimum stalk length in pixels. Stalks below this length threshold are ignored.
  • Max stalk flexibility: Maximum stalk flexibility. Stalks with flexibility above this value are ignored. The flexibility is defined as stalk contour length / stalk end-to-end distance. Hence, a straight stalk has a flexibility of 1.
  • Stalk screening width: Step size for stalk propagation in pixels. A higher values reduces the stalk contour resolution but increases the tolerance for gaps in the stalk signal.
  • Stalk sensitivity: Stalk detection sensitivity, based on the intensity difference between the pixels belonging to the stalk and pixels in the background. Low values increase the probability for false detections.
  • Exclude cells close by: If checked, cells which are closer together than Cell expansion width are marked as CellDeleted=1.

Cell tracking parameters

  • Search radius: Cells are tracked by comparing the spatial overlap along consecutive frames. To avoid calculating the overlap between all cells an to therefore speed up the tracking process, only neighboring cells within the Search radius are considered.
  • Dilation width: Prior to determining the spatial overlap, cells can be enlarged. If cells are moving, it can help to increase this value if otherwise no overlap is present in considered frames.

Display parameters

  • Overlay font size: Font size (in points) of overlay text in the image display.
  • Line width: Line width (in points) of cell outlines and stalks.
  • Plot resolution: Plotting resolution of cell outlines and stalks.
  • Show trackID: Displays the TrackID of each cell next to the CellID.

Advanced parameters

  • Parallel processing: Use multiple CPU-cores for parallel image processing (requires the Matlab Parallel Computing Toolbox). The number of workers is set up in the preferences of the Parallel Computing Toolbox.
  • Debugging: Output debugging information during cell/stalk segmentation (requires Parallel processing=0).
  • Image background: Select the image background type (usually ‘bright’ for phase contrast images and ‘dark’ for fluorescence images).
  • Cell channel: Input channel including the cell images.
  • Stalk channel: Input channel including the stalk images. If the cells are imaged in phase contrast usually the stalks are present in the same channel as the cells. This option might be useful if cells and stalks where labelled with different fluorescent probes.

Stalk detection algorithm

The general principle of the stalk detection algorithm is illustrated in the Figure below.

Stalk detection algorithm
  • (1) The cell of interest is expanded by the amount of pixels set in Cell expansion width to generate the shell shown in magenta.
  • (2) The intensity profile along the shell generated in (1) is measured. The pixel of lowest intensity which is below the Z-score (dependent on the value set for the Stalk sensitivity), is considered to be the attachment point of a stalk.
  • (3-6) The stalk is propagated by dilating the stalk attachment point by the set Stalk screening width. Previously processed regions are excluded from the dilation result and the intensity values of the remaining pixels are analyzed. The pixel of lowest intensity is added to the stalk backbone (if its intensity is below the Z-score (of value Stalk sensitivity); if not, the stalk ends).
  • (7) If the stalk hits a pixel of another cell, both cells are linked to each other and the cell with the largest area is flagged as “mother cell” and the other cell as “bud”.