BodenmillerGroup / ImcSegmentationPipeline

A pixel classification based multiplexed image segmentation pipeline
https://bodenmillergroup.github.io/ImcSegmentationPipeline/
MIT License
83 stars 35 forks source link

Index Error in 3_measure_mask.cppipe #40

Closed hfl112 closed 4 years ago

hfl112 commented 4 years ago

Encounter an error like this: Error while processing MeasureObjectNeighbors Multichannel: index 11 is out of bounds for axis 2 with size 11

seems like something wrong with the markers? cause I have only selected 11 markers in pannel.csv Any advices to solve this problems might be aprreciate. Thank you

votti commented 4 years ago

Hi, This is because at this time, the number of markers need to be adapted in the measurement modules. As described here: https://github.com/BodenmillerGroup/ImcSegmentationPipeline/blob/development/scripts/imc_preprocessing.ipynb section 'D) Cellprofiler: 3_measure_mask'

""" 5) Measure Object Intensity Multichannel: Adapt the channel numbers for 'Fullstack' and 'Fullstackfiltered'. 'Probabstack' remains at 3. Check the _full.csv files in the tiffs folder to see how many channels the stack have and adapt accordingly.

6) Measure Image Intensity Multichannel: Adapt the channel numbers for 'Fullstack' and 'Fullstackfiltered'. Check the _full.csv files in the tiffs folder to see how many channels the stack have and adapt accordingly.

""" Cheers!

hfl112 commented 4 years ago

Hi, This is because at this time, the number of markers need to be adapted in the measurement modules. As described here: https://github.com/BodenmillerGroup/ImcSegmentationPipeline/blob/development/scripts/imc_preprocessing.ipynb section 'D) Cellprofiler: 3_measure_mask'

""" 5) Measure Object Intensity Multichannel: Adapt the channel numbers for 'Fullstack' and 'Fullstackfiltered'. 'Probabstack' remains at 3. Check the _full.csv files in the tiffs folder to see how many channels the stack have and adapt accordingly.

  1. Measure Image Intensity Multichannel: Adapt the channel numbers for 'Fullstack' and 'Fullstackfiltered'. Check the _full.csv files in the tiffs folder to see how many channels the stack have and adapt accordingly.

""" Cheers!

Vito, Thank you so much for the patience. I have successfully run through the whole imc_seg_pipe. But I still have some questions remain:

  1. I found in your type II diabetes manuscript, you have did another segmentation to mask the blood vessel and islets in ilastik, and get the distance from cells to the rim. How to achieve this ? can you just briefly explain the steps?
  2. And I found you did the experiment to get the spillover matrix. Does this experiment have a great influence on the final results?
  3. And I found the results between using imc_seg_pipeline and using cellprofiler only is quiet different. For example, I got 400 cells from imc_seg_pipeline(ilastik+cellprofiler) and more than 600 from cellprofiler. I wanna know is this acceptable or normal under this pipeline? Actually using this pipeline helped me to solve the duplicate cellid problem and insufficient neighbouring cells, which derived from the bad mask. Thank you again for the help, Funan
votti commented 4 years ago

I answered question 1 separately in #41

At question 2: It is a bit hard to say a-priori if this will be an issue: The effect of spillover is only really strong if you have markers that are very high in a subset cells next to markers that are very low in the same subset of cells. Also if you want to look at marker correlations, the influence can be substantial, as spillover introduces artificial correlations.

In the end it also depends how much you want to interprete 'graded' expressions - if much of your analysis just looks at marker 'high' and 'low' cells, spillover might not be an issue.

At 3: Please always check if you think the segmentation looks 'reasonable': I always recommend to overlay masks using the 'OverlayOutlines' or 'OverlayObjects' cellprofiler modules. E.g. extract the 'Iridium' or a membrane channel from your 'full' stack with the 'ColorToGray' module and create & save these overlay images.

Please also note that it is very much advised to play around with the 'IdentifyPrimaryObjects' settings in Cellprofiler in both a basic and CP + Ilastik pipeline to improve your segmentation.

Finally my biggest advice would be to write down some 'biological expectations' you would have from your data. E.g. markers that should never co-occur biologically in your cells. This can be a good guide to judge segmentation quality.

hfl112 commented 4 years ago

I answered question 1 separately in #41

At question 2: It is a bit hard to say a-priori if this will be an issue: The effect of spillover is only really strong if you have markers that are very high in a subset cells next to markers that are very low in the same subset of cells. Also if you want to look at marker correlations, the influence can be substantial, as spillover introduces artificial correlations.

In the end it also depends how much you want to interprete 'graded' expressions - if much of your analysis just looks at marker 'high' and 'low' cells, spillover might not be an issue.

At 3: Please always check if you think the segmentation looks 'reasonable': I always recommend to overlay masks using the 'OverlayOutlines' or 'OverlayObjects' cellprofiler modules. E.g. extract the 'Iridium' or a membrane channel from your 'full' stack with the 'ColorToGray' module and create & save these overlay images.

Please also note that it is very much advised to play around with the 'IdentifyPrimaryObjects' settings in Cellprofiler in both a basic and CP + Ilastik pipeline to improve your segmentation.

Finally my biggest advice would be to write down some 'biological expectations' you would have from your data. E.g. markers that should never co-occur biologically in your cells. This can be a good guide to judge segmentation quality.

Hi Vito, I still got some questions in tissue-level mask. I have classified some blood vessel in ilastik, but I encounter an error in TransformBinary in Cellprofiler.

Error while processing Transform Binary:
tuple index out of range

In addition, I still can't figure out in which step to merge these 2 mask(cell segmentation & tissue-level segmentation) into a final one.

Thank you, Funan