Skip to content

1. Choosing the right parameters

Pradeep Rajasekhar edited this page Mar 30, 2022 · 9 revisions

It is recommended to test the GAT segmentation on representative images of neurons first before running the entire workflow. These macros can be found under GAT->Tools and will have "Test" as a prefix. This is to ensure that the segmentation is accurate.

Rescaling factor

The StarDist models within GAT are trained to segment neurons of an area: 686.8 ± 371 pixel^2 or on images that have a pixel size of 0.568 microns/pixel. When processing an image within GAT for segmentation, it has to be rescaled so the cells are of a similar area to what the model/s have trained on. This is done by specifying a rescaling factor. By default, the rescaling factor within GAT is 1. However, you can test a range of values to ensure you use the most accurate value. If the rescaling factor is too big, it will split your cells, if it's too small, cells are merged. This is illustrated in the image below:

pixel_size_choice

  • yellow arrowheads: merges
  • white arrowheads: splits
  • asterisk: false positive

Recommended rescaling factors

  • Adult Mouse: 1
  • Adult Human: 0.63

As a rule of thumb,

  • if using the default of 1 is not detecting smaller neurons and ROIs are being merged, increase the rescaling factor.
  • if the default value is splitting cells, then decrease the rescaling factor.

If you used an earlier version of GAT, click here to see conversions from pixel size to rescaling factor.

Determining rescaling factor

To make testing easier, if you have a large image, you can crop it and test a small region.

  • Ensure your images are calibrated. Open your images in FIJI and go to Image -> Properties on the FIJI menu.

calibration

It should state the pixel width and height in microns. If not, please enter this manually. GAT will only work properly if this information is entered.

  • Go to GAT -> Tools -> Test neuron segmentation

calibration

For this example, one of the sample images will be: 181107_ms_distal_colon_nNOS_GFAP_Hu_40X.tif

Channel 3 is “Hu” labelling of the neuronal soma.

  • Click on Browse, navigate to the image and click OK.

Tip: If you already have an image open, you can tick the box Image_already_open.

test_seg

  • As a start, its recommended to test a rescaling factor of 1. Enter the same value for minimum and maximum value to test only one rescaling factor.
  • Keep the rest as shown in the image above.
  • Click OK and it will open the image. As it’s a multichannel image, it will ask you to verify the channels so you can choose your channel of interest in the subsequent prompt.

test_seg

  • Moving the slider on the bottom will cycle through the 3 channels. Hu is in channel 3.

  • Enter 3 in the next box and click OK.

test_seg

It will now perform segmentation of the neurons using the settings entered above. As we are only testing one rescaling factor, we will get one resulting image with ROIs overlaid on it.

test_seg

Keep in mind that this image has been resized and segmentation performed on this image to obtain the ROIs. Use this step to zoom into the image and verify the segmentation is working. If you’re not happy, you can test a range of values. If you’d like to test a range of values, close all the images and rerun “Test Segmentation”. In the dialog box, enter the minimum and max values. Here I’m testing 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3 and 1.4. For this, I’ve entered

  • Minimum value: 0.7
  • Maximum value: 1.4
  • Increment step/s: 0.1 Click OK and enter channel 3 as above in the next prompt.
  • This will yield a series of images with different pixel sizes and the resulting segmentation overlaid.

test_seg

  • The rescaling factor used will be in the image name. You can check the Log window to see the number of objects for each rescaling factor. It is recommended to test this on images you may have already counted or small regions manually analysed to verify the accuracy.

Testing segmentation on a tilescan/large image

  • Open a large tilescan image in FIJI. You can select Tilescan_GAT_ms_distal_colon_MP_hu.tif from the sample images. Select the rectangle tool and draw a rectangle around region you’d like to test the segmentation.

seg_large

  • Right click outside the ROI, click duplicate followed by OK and you will get just that region as a separate image.

  • Go to GAT -> Tools -> Test Neuron segmentation.

  • As the image is already open, tick Image_already_open.

  • Use the following settings:

seg_large

  • Click OK. It will ask you to select the image as we selected the image already open box. Select the cropped image and click OK.
  • It will now cycle through the rescaling factors, resize the images and run segmentation on them.
  • In the Log window, you will see the no of detected objects at each rescaling factor with corresponding pixel size:

seg_large

Determining Probability and Overlap Threshold

The other parameters that can be adjusted within GAT is the “Probability” and “Overlap Threshold” of the StarDist segmentation.

Probability (Default: 0.5)

Lowering this value will help in detecting low stained cells or dim areas. However, it can also pick up background or false positives. Increasing this value will reduce the number of detected cells and keep bright objects...

Overlap Threshold (Default: 0.3)

Lowering this value will increase detection of overlapping cells, but it may start detecting more cells where there aren’t. It is recommended to lower this if the tissue isn’t stretched well and cells are on top of each other. Increasing this will lower the number of overlapping cells detected.

The reality is that if the tissue is not stretched properly and you cannot differentiate between cells by eye, then it is unlikely that GAT will be able to detect cells accurately in a 2D image. This is particularly the case if the cells are overlapping heavily.

Tip: You can use QuPath for analyzing large tilescan images as well


Pixel size to rescaling factor

Earlier versions of GAT used pixel size for segmentation. This was confusing and instead we have introduced a rescaling factor. To convert from pixel size to rescaling factor you can divide pixel size by 0.568. Example conversions:

Pixel size (micron /pixel) Rescaling Factor
0.9 0.63
0.568 1
0.5 0.88
0.45 0.79

Keep in mind this is the pixel size you would like to rescale the image to so that the algorithm performs accurate segmentation. It is not the pixel size of your image.