Segmentation of cells is creating masks the represent their shapes based on whole cell dyes, and sometimes nuclear dyes. These masks can be used to analyse morphology parameters such as area, shape etc. The masks can also be overlayed onto other channels of the image to measure intensities or other parameters.
Open Cell.tif and Sample.tif from the Demo Images\Widefield\Segmentation folder. Create a duplicate of Cell.tif.
2. Select the duplicated Cell.tif image (usually Cell-1.tif). Go to Process 🡪 Find Maxima…
3. In the Find Maxima dialog box leave Noise Tolerance at 10, set Output Type: to Segmented Particles. Check the Exclude edge maxima and Preview point selection. Don’t press OK yet.
The point is to get one maxima point per cell, to change the sensitivity the Noise Tolerance value needs to be increased.
4. Change the Noise Tolerance value until you get one maxima per cell. A value of 400 works well for this image. Press OK.
5. The result is a watershed binary mask of the cell image. The lines between the “cells” represent the lowest intensity point between each of the cells based on the seed point of the maxima point set before.
6. This mask can be used to create outlines of the individual cells. To be able to do this we need to also create a binary mask that represents the stain for the whole cells.
Select the duplicated cell image and set a threshold on it but do not apply it yet
7. You will notice that the threshold is a little “shaggy” in places. For good quality cell segmentation it is better to have a smooth mask. The easiest way to do this is to smooth the cell image.
Go to Process 🡪 Smooth
The result smooths out some of the noise in the image and makes the threshold cleaner.
8. Apply the threshold to give a binary image of all the cell stain.
9. To get masks that resemble cell all we need to do is some simple Boolean logic between the two binary images. To do this go to Process 🡪 Image Calculator…
10. In the Image Calculator window set Image 1: and Image 2: to the two binary masks. Set the operation to AND. Tick the Create new window box and press OK.
11. The resulting image is now looking like the outlines of cells but still needs to be cleaned up some.
12. To clean up the cell masks use the Analyse Particles… module.
13. To remove the smaller chunks in the image set the Size to 250-Infinity, set the Show: value to Masks, tick the Exclude on edges box and press OK.
14. The resulting mask will look a bit funny. This is because the LUT is inverted.
15. To turn the LUT inversion off go to Image 🡪 Lookup Tables 🡪 Invert LUT
16 If you look at some of the cells you will notice that they have small black holes in them. These can be filled by going to Process 🡪 Binary 🡪 Fill Holes
17. This final mask can be used for further analysis. The cell shapes should correspond to the outlines of the cells, how to check this will be shown later.
To analyse the Sample.tif image we need to redirect the measurement to use the mask on the Sample.tif image as we did previously.
Go to Analyse 🡪 Set Measurements… and configure it as below and press OK
2. Use the Analyse Particles… module as below to measure the cells.
3. The results will be displayed as the outline image, summary table and detailed results table. Each of these can be saved for further analysis and presentation.
Save the image and the two tables as we will be using these for comparison to another data set.
4. Re run the mask creation and analysis on Cell 02.tif and Sample 02.tif from the Demo Images\Widefield Images\Segmentation and compare the results.
You will notice when looking at the summary data that in general the samples are the same. But the average size of the cells in Sample 02 is a little bit bigger and the average intensity is lower.
After the last analysis you should have quite a few windows open. Close all of them except for the final binary mask of the cells. We can use this mask to create outlines to check if the segmentation is accurate.
There are two methods for doing this. One involves overlaying the measurement ROIs onto the image and check them. This will also give you a list of ROIs that can be saved for other uses but can be a bit cluttered and not amenable to presentation. The second is to make an outline of the cell based on the mask and create a composite colour image of the outline and cell stain. This methods gives a picture that is easier to present or show people what has happened.
Re open Cell 02.tif from the Demo Images\Widefield\Segmentation folder.
2. Go into Set Measurements and make sure the Redirect to: option is set to None and press OK.
3. Select the binary mask image and go to Analyse Particles again. This time configure it as below and press OK.
4. The result will be yellow outlines around each of the objects in the mask and a list will open up in the ROI Manager.
5. The ROIs can be saved and reapplied to another image, say the Cell 02.tif image. To save the ROIs click the More> button in the ROI Manager and select Save.
6. Save the ROI file somewhere you can find it again.
7. We don’t need the ROIs on the mask image anymore so they can be deleted by pressing the Delete button in the ROI Manager.
8. Now select the Cells 02.tif image, press the More>> button in the ROI Manager and Open the ROI set you just saved.
9. You will now have the ROIs loaded onto the cell stain image. You can now zoom in and see if the lines match up with the edge of the cells. You also have these regions saved if you ever need them again for other analyses.
Alternatively you can not save and delete the ROIs but instead select the image you want to have ROIs on and tick the show all box on the ROI manager
Delete the ROIs from the Cell 02.tif image. Select the binary mask image, duplicate it and go to Process 🡪 Binary 🡪 Erode
2. The result will be a version of the binary mask that has been eroded around the edges. This can now be used with the other binary mask to create outlines.
3. Use the Image Calculator to Subtract the eroded image from the original mask.
NOTE: Make sure you have the original mask image (the “bigger” one) set as Image 1 otherwise the subtraction will not work.
4. The result is rings that represent the outside of the cell mask.
NOTE: This mask could be used as a measurement mask to analyse membrane expression.
5. Convert Cell 02.tif to a 8 bit image and use the merge channels function to combine the cell stain image and the rings.
6. You now have a colour composite image of the result for display and other uses.
Using what was shown in the above example and in the cell counting example it is possible to create masks that represent different cellular compartments.
Using the cell counting example we can create a mask of the nuclei
We can create a mask of the membrane of the cell using the ring method above
Now if we subtract the nuclei mask from the eroded mask used to create the rings above we are left with a mask that represents the cytoplasm of the image.
We now have three separate masks that can be used to measure the membrane, cytoplasm and nuclei of the sample image, for example to measure nuclear translocation.
If you look at the above final mask set example there are two things wrong with it. One, there are nuclei around the edge of the image that are not associated with a cell mask. This is because the step to remove objects in the analyse particles module has removed the edge cell masks. Secondly if you look very closely there are some bits of nuclear mask that overlap with membrane mask. When used to measure the final image these masks would result in some pixels being measure twice and being classified as both membrane and nuclear.
Both of these problems can be easily fixed.
Removing Extra Nuclear Masks
This is simple enough to do but it does require an extra plugin that is not part of the Fiji default set. This plugin is already installed on the computers you are using and there are instructions in the front of this manual that tell you how to add it to your own copy.
All we need to do is reconstruct the nuclei mask to keep only the nuclei associated with cell masks.
To do this go to Plugins → Morphology → Binary Reconstruction…
2. Configure the Binary Reconstruction window as below and press OK.
3. The result is a nuclei mask with only nuclei that overlapped with a cell being kept.
4. This mask can then be subtracted from the ring mask to remove any double measurements leaving you with a more accurate set of masks.
Sometimes the dyes used are not the best for doing cell segmentation but it is possible to combine several dyes to achieve a good result.
Open Cell.tif and Nuclei.tif form the Demo Images\Widefield\Segmentation\Cytoplasm
2. If you try to use the Find Maxima water shedding on the Cell image you will find that it will not work very well as each cell has multiple bright points in it. There will be a few broken chunks of cell and the edge detection may not be very accurate.
3. This can be easily fixed by combining the nuclear and whole cell stains together to give a more complete image for segmentation.
To avoid issues with oversaturation it is best to use the MAX command in the image calculator and not the Add command.
4. The resulting image won’t look very much different to the original nuclei image as the cell stain image is not as bright. But if you boost the brightness you will be able to see whole cell stain with the nuclear stain.
5. The resulting image can now be used like the previous examples to generate masks for further analysis.
Like the StarDist AI method for segmenting nuclei another AI system for cell segmentation called CellPose can give amazing results compared to the more traditional approach outlined above. The full process of getting this going on a large batch of images is beyond the scope of this current edition of the training manual but an example of what can be achieved can be easily shown.
NOTE: The current pipeline for producing batch analysis using CellPose involves preprocessing the imagines in Fiji, running those images through a Google Colab notebook or Napari plugin, then running the resulting masks back through Fiji.
Open a web browser and go to www.cellpose.org
There are example images you can click on to see the potential results but we will use the image from the first part of this module
2. Drag and Drop Cell Pose Test.png from the Demo Images\Widefiled\Segmentation folder into the box on the CellPose site
3. Set the configuration as follows and press submit.
4. The results will be returned showing the outlines, coloured intensity image and flow image used to predict the CellPose outlines
5. You can download the masks generated using the Download masks as PNG link. The resulting image is an RGB image that can be converted to grey scale by going to Image 🡪 Type 🡪 8 Bit. Each object is given a unique intensity value. Due to the limitation of 8 bit only having 256 grey levels and image that has more than 256 objects in it will have some cells assigned the same intensity value. This issue does not occur when running CellPose using other methods. Once made 8-bit the masks can be used to create objects or false coloured, in this example with the glasbey_inverted LUT.