The Segmentation tab allows you to set all parameters to extract 3D objects from the imported microscope data.
- Select one or several image file(s) in the Files-panel.
- Use the Selected image(s)-button in the Image range-panel to include the selection in the segmentation.
- Click on the tab 2. Segmentation-tab.
- Directly jump to 2.6 Object declumping and add a grid side length.
- Press button Segment cells to start the segmentation.
- Once the segmentation is finished, you can inspect the segmentation result by using the Overlay-button in the Image preview-panel.
This is only a minimal working example. Even though the default values will often produce reasonable results, you can improve the segmentation results by optimizing the segmentation parameters according to your input files.
We will explain the influences of each parameter in the following step-by-step explanation.
The following steps are organized according to the workflow for a general segmentation process.
With Select you can define a region of interest (ROI) (x, y, width, height) for the currently selected image.
For a long time series, this task can be very tedious. To speed up the cropping process, you can use the following functions:
- Use Apply to all images to use the current ROI for all images in the series.
- Manually select the ROI only at key frames of your time series and then use Interpolate crop rectangles to automatically-generate the cropping ROI in all frames in between the key frames. (This only make sense for time series data of growing biofilms).
The checkbox Interpolated crop range indicates whether the currently displayed cropping settings have been manually selected or are the result of the interpolation method.
In contrast to the ROI in \(x\) & \(y\), the maximal \(z\) height (Z-cropping) is used for all files in the current Experiment folder.
- When your time series exhibits a lot of drift between the single images, you should use Image alignment and enable Apply registration prior to the ROI selection.
- To delete all croppings of the time series, you can delete the crop definitions completely and press Apply to all images.
- If the selected cropping region is smaller, the segmentation will be computationally faster and the resulting data-files will be smaller.
Reference cropping will restrict your segmentation results to a fixed position and size. If individual ROIs are larger than the reference cropping, the offset will be cut off.
This feature is particularly useful if you want to create movies of a growing biofilm that is initially small. The initial crop frame can be small. This increases the processing speed. The final result will have a fixed size and position according to the reference cropping. This allows you to use the segmentation result directly as frames in a time-lapse movie.
If your biofilms were grown in a flow chamber, you may want to indicate the flow direction in the preview image. The text field Direction of flow changes the direction of the small flow indicator in the image preview.
By default BiofilmQ assumes that your biofilm grows from the bottom of the z-stack upwards. If due to your particular experimental setup the biofilms grow from top to bottom, you can enable Invert stack.
Correct tilted coverslide (experimental) if the checkbox is enabled, BiofilmQ tries to correct the orientation of the brightest plane to a perfect planar orientation.
Scale up/down change the image resolution by interpolation.
The biggest obstacle for threshold-based segmentation is a low signal-to-noise ratio. We implemented three different filters which can reduce the noise in your image z-stacks significantly.
Reduces salt-and-pepper noise by averaging each pixel with the values of the surrounding pixels. The kernel size indicates how large the used region for the averaging operation will be. This option is highly recommended and the default value works well in most scenarios.
Median filter along z¶
Fast moving or floating cells that are not part of a biofilm are in most cases only captured in a single slice during the image acquisition. By applying a median filter in \(z\) direction, the signal of floating cell is strongly suppressed such that most floating cells will not be detected by the thresholding method anymore.
Reduces low frequency noise. This option is particularly useful for reducing the background (out-of-focus) fluorescence in confocal microscope images or for correcting inhomogeneous lighting conditions. The given pixel size should be larger than the largest expected cell size, otherwise information about the sample is destroyed. (Example)
At the moment there are five different thresholding approaches available (four automated thresholding algorithms, and one manual thresholding workflow):
- Otsu: The Otsu thresholding method is the most widely used thresholding method for images and works reasonably well for biofilm image data.
- Ridler-Calvard: The Ridler-Calvard thresholding is an iterative application of the Otsu thresholding method.
- MCT: The abbreviation MCT stands for maximum correlation thresholding
- RobustBackground: Discards the all values outside the 5-95% intensity range. The threshold value is set to \(\mu + 2\sigma\) of a gaussian approximation of the remaining values, where \(\mu\) is the mean value, and \(\sigma\) is the the standard deviation of the gaussian distribution.
- Manual: Manually selecting an intensity threshold value for every image in the Experiment folder.
If you choose the Otsu thresholding method you have to specify how many intensity classes you expect in the image stack and in which classes you expect cells. Usually 2-class thresholding is sufficient. In some cases 3-class thresholding can be beneficial:
- If you have a small coverage of the substrate with biofilms, class 2 should be assigned to the background.
- If you have large biofilms, class 2 should be assigned to the foreground (i.e. it should also be added to the biofilm biovolume).
- If you are using a fluorescent reporter or stain which results in some cells being extremely bright while the major fraction is much dimmer, 2 intensity classes should be reserved for cells to avoid detection of only very bright cells.
- Crosstalk might lead to a situation where two classes are useful to fully cover the background and one class remains for the actual cells.
In case the selected automatic thresholding methods always result in a threshold being a bit too low or too high, the result can be adjusted with the sensitivity value which acts as a scaling factor for the automatic threshold.
With the prominent button Open ortho view of selected stack for threshold determination you can manually change the threshold value for the manual background determination interactively. For each update the influence on the segmentation is visualized in an ortho-view representation of your input stack. If you selected an automatic thresholding approach, the button allows you to interactively modify the sensitivity value.
With the drop-down menu Determine threshold visually you can select whether the images should go through all previously defined noise reduction steps, or whether you determine the threshold based on the raw input images (faster but less accurate).
Dissecting the biofilm into cubes: Object Declumping¶
In general a threshold-based segmentation approach results in one large 3D biofilm volume. To analyse properties inside this volume with spatial resolution, the idea of a cube-based segmentation comes into play. We can dissect a large biofilm volume of a connected biomass into small cubic volumes. If the biofilm is reasonably large and the cube grid size is the same as the average cell size within the biofilm, we can assume that each cube volume contains only a few cells (i.e. on average, just one cell volume). For these pseudo-cell cubes we can perform many Parameter Calculations.
However, note that the cube-based object declumping does not make sense in case the size distribution of connected clusters is of interest. In this case, the Dissection method should be set to None, so that no cubes will be generated.
Based on the segmentation results, we can try to filter out debris as well as artefact objects, which are too small to represent a living cell.
- 3D Median of binary image polishes the volumes such that sharp edges are suppressed and the segmentation results look more like biological samples.
- Remove small voxel cluster erases any debris which is smaller than the defined voxel size (= volume in pixel).
Make sure that the given voxel size is smaller than the given cube grid edge length in Object Declumping. Otherwise you delete all objects!
- Remove bottom deletes the given number of slices at the bottom of each image stack. This can be used to remove slices which only contain images of the substrate below your biofilm.
Merge channels merges two or more already segmented channels into each other. This is only useful if you have two signals and want to calculate an overall statistic of both channels.
This function works differently for cubed and non-cubed biofilms:
- For cubed biofilms the biovolumes of all channels will be merged and cubed again. Now, each cube will contain information about the relative abundance of biomass in the underlying channels:
- Cube_RelativeAbundance_chX Relative abundance of biomass in the channel indicated (in %)
- Cube_Overlap3D_chX_chY 3D overlap between biomass in the channels indicated
- For non-cubed biofilms the objects in all channels will be put into one results file (or one scene in the VTK-format for 3D rendering), independent of whether there is a physical overlap among objects in different channels.
If non-cubed data is merged, only the measurements which are present in both channels will remain.
During merging a backup of the original ch1_data.mat and ch2_data.mat files are created inside /data/non-merged-data. To undo the merging simply copy these files back into the original folder and replace the file containing the merged data.
After the segmentation you can proceed with the Parameter Calculation.