BodenmillerGroup / steinbock

A toolkit for processing multiplexed tissue images
https://bodenmillergroup.github.io/steinbock
MIT License
49 stars 15 forks source link

Scaling and renormalisation during cell segmentation #189

Closed BonoC closed 1 year ago

BonoC commented 1 year ago

Hi,

Great work on the development of the Steinbock docker. This makes IMC data handling much easier! However, I am slightly confused with the overall concept of scaling and renormalisation during Ilastik pixel classification and CellProfiler segmentation.

According to the Steinbock documentation, cropped Ilastik images are by default scaled by a factor of 2. After training the random forest classifier, the probability maps are then renormalised before being exported (according to imcsegpipe). Finally, when probability maps are used to segment cells in CellProfiler, the default pipeline will down-scale the probability images by a factor of 2.

Here, I was wondering whether it is advised to transform the data as described above (scale - renormalise - down scale), and whether the data transformation on Ilastik images is completely and does not directly affect single cell quantification (ie. these transformations are only used for generating masks, hence subsequent quantification does not actually apply these transformations). Thanks for your help!

nilseling commented 1 year ago

Hi @BonoC

for IMC we up-scale the images by a factor of 2 to facilitate pixel labelling. I'm not quite sure what you mean by " the probability maps are then renormalised before being exported". The probability maps are down-scaled by a factor of 2 to match the initial image dimensions before segmentation - the segmentation masks should have the same dimensions as the images. And as you said, the operations only generate segmentation masks. Quantification is performed on the original images.

BonoC commented 1 year ago

Hi @nilseling,

Thanks for the reply. This has certainly cleared things up. In terms of the renormalisation that I was talking about, this is mentioned on the imcsegpipe website (https://bodenmillergroup.github.io/ImcSegmentationPipeline/ilastik.html). It is recommended to renormalize before exporting probability maps. I'm not too sure whether this will change the dimensions of the image on top of scaling, hence leading to inaccurate segmentation. Please see below for details about the renormalisation. Thank you for your help!

Prediction Export: Once the classifier is well trained, perform the following steps to export predictions: Source: Probabilities Choose Export Image Settings: Convert to Data Type: unsigned 16-bit check Renormalize Format: tiff

nilseling commented 1 year ago

The renormalization step does not change the dimension of the probability maps, just rescales the range of probability values

BonoC commented 1 year ago

Hi @nilseling,

Thank you for the prompt reply. Does that mean it would be ok to perform renormalisation on top of scaling and downscaling during pixel classification and cell segmentation?

nilseling commented 1 year ago

That's the default, right? I don't have the pipeline in front of me at the moment but if we wrote this in the documentation then renormalization should be done. Renormalization only relates to how the pixel probabilities are being written out so that cellprofiler correctly reads them in.

BonoC commented 1 year ago

Yup, that is written in the documentation as default. Once again, thanks for your help!