ImageJ SurfCut: a user-friendly pipeline for high-throughput extraction of cell contours from 3D image stacks

Background Many methods have been developed to quantify cell shape in 2D in tissues. For instance, the analysis of epithelial cells in Drosophila embryogenesis or jigsaw puzzle-shaped pavement cells in plant epidermis has led to the development of numerous quantification methods that are applied to 2D images. However, proper extraction of 2D cell contours from 3D confocal stacks for such analysis can be problematic. Results We developed a macro in ImageJ, SurfCut, with the goal to provide a user-friendly pipeline specifically designed to extract epidermal cell contour signals, segment cells in 2D and analyze cell shape. As a reference point, we compared our output to that obtained with MorphoGraphX (MGX). While both methods differ in the approach used to extract the layer of signal, they output comparable results for tissues with shallow curvature, such as pavement cell shape in cotyledon epidermis (as quantified with PaCeQuant). SurfCut was however not appropriate for cell or tissue samples with high curvature, as evidenced by a significant bias in shape and area quantification. Conclusion We provide a new ImageJ pipeline, SurfCut, that allows the extraction of cell contours from 3D confocal stacks. SurfCut and MGX have complementary advantages: MGX is well suited for curvy samples and more complex analyses, up to computational cell-based modeling on real templates; SurfCut is well suited for rather flat samples, is simple to use, and has the advantage to be easily automated for batch analysis of images in ImageJ. The combination of these two methods thus provides an ideal suite of tools for cell contour extraction in most biological samples, whether 3D precision or high-throughput analysis is the main priority. Electronic supplementary material The online version of this article (10.1186/s12915-019-0657-1) contains supplementary material, which is available to authorized users.

3. The macro will start and display the window below.
The macro has two modes: the first one, called "Calibrate", is to be used in order to manually find the proper settings for the signal layer extraction, but can also be used to process samples manually one by one. The second one, called "Batch", can then be used to run batch signal layer extraction on series of equivalent Z-stacks, using appropriate parameters as determined with the "Calibrate" mode. Go to section C. for the calibration mode and section D. for the batch mode.
C. Calibration mode 4. First, select the "Calibrate" mode and click OK. 5. A navigation window opens. Select the confocal stack that will be used for the calibration.
Remember that the stack should be in .tif and that the top of the stack should also be the top of the sample.
Note that in addition a log window will open. It will display information on the processing throughout the use of the macro.
6. The stack will open, and a pop-up window will ask you to define the input values for "Gaussian Blur" and "Threshold".
The Gaussian Blur is a mean to reduce the noise and smooth the signal. This is particularly important in order to obtain a smooth signal detection during the binarization of the signal. We found that a value of 3 µm works usually well for us. However, if your signal is very heterogeneous, e.g. for cortical microtubules, a higher value can help homogenize the signal and obtain a good surface detection.
The threshold value then depends on the intensity of the signal in your stack. You can start with the pre-set values and check the result 7. Click on "OK" to initiate the image processing: (1) Gaussian Blur, (2) signal binarization, (3) edge detection, and (4) output binarized image and 3D visualization of the output image in the 3D Viewer.
Note that you can follow the processing of the images in the log window. -If you are satisfied, tick the "Satisfied" box and click "OK". This will take you to the next step.
-If you are not satisfied simply don't tick the "Satisfied?" box and click "OK". This will take you back to step 6, where you will be able to test new values for the Gaussian Blur and the Threshold. You can repeat this as many times as necessary until you find the proper settings for edge detection.
10. When you proceed to the next step, a pop-up window will ask you to choose the depths between which the stack will be cropped relative to the detected surface. This value is in micrometers. The voxel properties of your image in micrometers, are automatically filled based on the metadata of the image. If no data is found these values will all be set to 1. You can modify these values if necessary.
11. Once you have entered all the required values and pressed "OK", the stack is processed, and the macro generates four images that can be useful to check the quality of the output: -Two orthogonal reslices in the X and Y axis, through the center of the stack showing an overlap of the raw signal (green) and the cropped stack (thin white line; The thickness of this line depends on the thickness of the cropped signal layer) - 13. Similarly to step 9, once you have checked the quality of the SurfCut output, click "OK" in the "Check SurfCut Result" pop up window. A new pop up window will appear and ask you whether you are satisfied with the SurfCut Output. You can repeat this step as many times as necessary until you find the proper settings.
14. If the cropped image is satisfying, you will then choose which files will be saved. You can add a suffix to the files to specify some characteristic of the parameter that you calibrated. e.g for cell contour of the L1 layer, outer cortical signal (see exemple in the next part).
You can choose to save the parameter file, containing all the parameters you have used to obtain the final SurfCut projection of this calibration step. You can also save the SurfCut projection as well as the original whole stack projection for comparison.
Then click OK.
15. At the end of this calibration step, you can find a folder named "SurfCutCalibrate" in the same directory as your confocal stack. This folder contains the files saved in step 14.
16. The macro will then ask you whether you are done or if you want to process additional image stacks. If you select "No" the macro will stop. If you select yes you will be taken back to the beginning of the macro where you can process additional images manually (in Calibration mode) or run a batch analysis.

D. Running the script in batch mode
17. This time choose the "Batch" mode and click OK.
18. A navigation window will appear. From this window select the folder containing the confocal stacks that you want to process in batch with SurfCut.

Note that it is preferable that this folder contains only the confocal stacks that you want to process with SurfCut. Remember that the stacks should be in .tif and that the top of the stack should also be the top of the sample.
19. A pop-up window will ask you to choose whether you want to load a parameter file or if you prefer to enter the parameter manually. If you load a parameter file made during the Calibration process described above, all the parameters will be pre-filled in the next step.
20. You can then further modify the parameters if necessary.
The SurfCut projections generated will be automatically saved, but you can also choose to save the SurfCut stack (3D stack of the signal layer extracted) if you wish to keep the 3D information, as well as the projection of the whole original stack, for comparison. Then click ok to run the batch processing.
Note that you can follow the processing in the log window.
21. The SurfCut macro creates a results folder in the working directory defined in step 3, named "SurfCutResults". It contains all the saved output (e.g SurfCut projection, SurfCut stack, Original projection) as .tif files, as well as a .txt file containing the input parameters and a log of the analysis.

Application example:
Semi-automated high-throughput cortical microtubule array analysis.
Because the method that we describe is a signal layer extraction method, it is not only limited to the extraction of cell contours and can, for instance, extend to extract outer epidermal cortex signal as well. This is particularly useful in the case of cortical microtubule (CMTs) organisation quantification, because multiple layers of CMT arrays overlap in a classical 2D projection, which affects the proper analysis of this signal. In addition, because the confocal signal acquired is anisotropic (different resolution in Z compared to X,Y) in many cases it remains preferable to carry out analyses in 2D (with a 2D projected image) in order to avoid such bias.

Left is the x,y view (from the top in Fiji 3D viewer) while right is the y,z view (from the side), showing the anisotropic nature of the confocal signal in epidermal cells of Arabidopsis thaliana hypocotyl expressing a marker for microtubules.
Here we describe the use of a pipeline that we have designed to semi-automatically quantify CMT arrays from 3D confocal stacks. The part of this pipeline after the SurfCut signal extraction (part C and D below) has already been reported in [17]  These three processes correspond to three successive Fiji macros ("SurfCut.ijm", "Segmentation4FTBatch.ijm" and "FibrilTool_Batch.ijm"; see prerequisites). Each of these macros can be used to process batch samples, making the analysis high-throughput.
-The "FibrilTool_BatchSeg.ijm" macro file (https://github.com/sverger/FibrilTool_Batch). B. Signal layer extraction with SurfCut 1. The first step is to extract both the cell contour and the outer epidermal CMT signal for all your images using SurfCut. You should first define the proper parameters for both type of extraction with one of your stacks, using the "Calibrate" mode.
For instance, in the images below, we have cropped the signal at a distance of 10 µm to 12 µm from the surface to extract the cell contours (left), and at a distance of 1 µm to 3 µm from the surface to extract the outer epidermal cortex (right).
2. Once you have adequate parameters, first run the batch signal extraction for the cell contours.
Note: It is important at this step to add in the SurfCut parameter window, a suffix for your images finishing with "_cells".
8. Next the generated ROIs are overlaid on the corresponding CMT image. At this step you can check whether the ROIs are properly positioned.
ROIs can be moved, deleted (see centre image) and created (see right image, blue ROI). You can for instance delete ROIs which are too much on the side of a curved sample since their analysis will be less meaningful. You can select individual ROIs by clicking on their label number, delete them with the backspace or del key, and create new ROIs with the Fiji "Polygon selections" tool.
The closed polygon can then be added to the ROI list by pressing Ctrl + T.
9. When satisfied with your ROI set click "OK" in the "Manage ROIs" window. This will save the ROI set in a .zip file with the suffix "..._MTs_RoiSet.zip" and proceed to the next sample.

D. FibrilTool Batch
Note that before running FibrilTool batch you should make sure that the log window is empty or close it. This will avoid pre-existing text in the log window to be saved in .txt output files of FibrilTool.