Git Product home page Git Product logo

Comments (10)

votti avatar votti commented on June 9, 2024 1

Cool that it finally worked!
"Intensity_MaxIntensityEdge_DistanceImage are the actually minimal distance of any pixel of a specific cell to the blood vessel, and vice versa?"
That sounds correct!

"""Beside, I also curious about the cellid problem, would the cellid/number of a specific image change in different cellprofiler mask with identical parameter?""
Hm if I understand you right, your question is, if the 'Image number' are linked to the 'ObjectNumber'.
In CellProfiler each image is given a number before anything is processed. Given you load the same mask/process the data with the same parameters, Object numbers should not change. The Object number should not depend on the 'Image Number' an image is given but really just on the input images.

from imcsegmentationpipeline.

votti avatar votti commented on June 9, 2024

This would be achieved by:

  1. Adapt the jupyter notebook (around : 'Other Input (only change if really necessary and you know what your doing)' )
'suffix_isletseg = '_isletseg'
csv_pannel_isletseg = 'isletseg;
list_analysis_stacks =[
    (csv_pannel_ilastik, suffix_ilastik, 1),
    (csv_pannel_full, suffix_full, 0),
   (csv_pannel_isletseg, suffix_isletseg, 1)
]

and add 'isletseg' in your panel as a 0/1 column indicating which channels to use.

  1. Add create a cellprofiler pipeline similar to '1_prepare_ilastik.cppipe` that takes the '_isletseg' stack and exports it as .h5 for ilastik.
    -> For tissue level segmentation I would rather not take crops as blood vessels etc might be rare
    -> I also would not scale the images 2x, as for tissue level segmentation the additional accuracy is not required

  2. create an ilastik pixel classifier with classes 'blood vessel', 'islets', 'other', train and export the probability maps.

  3. Import the probability map in cellprofiler.:

  • Use 'ColorToGray' to e.g. get the Islets probability (e.g. channel 2)

  • Use the 'Threshold' module to threshold the 'islet' probability into a binary mask

  • Use our 'Transform Binary' module on this thresholded image ('https://github.com/BodenmillerGroup/ImcPluginsCP/blob/master/plugins/transformbinary.py)
    -> This will create an image where 'The distance to a nonzero pixel will be positive, while the distance to a zero pixel will be a negative number'
    -> This gives you the 'distance to the 'islet' border

  • Measure this new image using your mask to get the quantifications in your Cellprofiler output.

Does this make sense?

from imcsegmentationpipeline.

hfl112 avatar hfl112 commented on June 9, 2024

I tried to use ilastik to do pixel classification as you mentioned. But after I have skip the 'resize' and 'crop bb' model of '1_prepare_ilastik.cppipe', I found the image in ilastik just changed, for example, in the first pixel classification figure a blood vessel was in the bottom, while it moved to the middle of the figure this time. Does this influence the further mask?

Besides, I was still confused why you separately mask the islets or blood vessel, and in which step and how to merge the 2 masks into one.

And about the 4th part you mentioned, is it similar to 2_segment_ilastik & 3_measure_mask_basic pipeline, can I just revise to adjust the islets segmentation or have to construct a brand new pipeline to deal with it. Did you have such a pipeline public or online? an example should be appreciatd.

Thank you,
Funan

from imcsegmentationpipeline.

votti avatar votti commented on June 9, 2024

Sorry for not being more responsive, I am running against a deadline for a paper submission before going for holidays.

Sorry for this erorr, this is because I havent adapted the visualization for this module to Cellprofiler 3 - the solution is simply to close the 'eye', such that Cellprofiler doesnt try to show the results

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.

You wouldn't merge the masks, but you would either:

  1. Measure the binary image after tresholding the probabilities and 'Measure' the intensity of this image -> this will show you if the cells are inside or outside the mask
  2. Measure the distance transformed image -
    (Either do the distance transform directly in the 'Measure mask pipline' or save it out.
    Note that for saving you need to use the rescale intensity module with a manual value of '65535` and save a floating point image -> the distances will then be allways scaled by 65535
    -> Also measure this image, positive Mean Intensiy = cell inside the mask, negative intensity = cell outside the mask
  3. Identify real masks for vessels using 'identify primary objects' and use 'relate objects' to relate your cells to these maks. (would be saved in the object realtions.csv)

At your Histocat question (https://github.com/BodenmillerGroup/histoCAT/issues/55#issuecomment-641672284):
Not tested but I think for histocat you would simply save the distance transformed/binary image in the same naming format as your images - histocat should then also quantify these and again the Intensity value will be indicative if a cell is inside/outside of a tissue level mask.
Using the gating functionality, you could then easily identify cells inside these tissue level maks).

Here also a rough example how to achieve this:
(note this needs ImcPluginsCP)
distance_to_mask_example.zip

Also answers question from #40

from imcsegmentationpipeline.

hfl112 avatar hfl112 commented on June 9, 2024

Sorry for not being more responsive, I am running against a deadline for a paper submission before going for holidays.

Sorry for this erorr, this is because I havent adapted the visualization for this module to Cellprofiler 3 - the solution is simply to close the 'eye', such that Cellprofiler doesnt try to show the results

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.

You wouldn't merge the masks, but you would either:

  1. Measure the binary image after tresholding the probabilities and 'Measure' the intensity of this image -> this will show you if the cells are inside or outside the mask
  2. Measure the distance transformed image -
    (Either do the distance transform directly in the 'Measure mask pipline' or save it out.
    Note that for saving you need to use the rescale intensity module with a manual value of '65535` and save a floating point image -> the distances will then be allways scaled by 65535
    -> Also measure this image, positive Mean Intensiy = cell inside the mask, negative intensity = cell outside the mask
  3. Identify real masks for vessels using 'identify primary objects' and use 'relate objects' to relate your cells to these maks. (would be saved in the object realtions.csv)

At your Histocat question (BodenmillerGroup/histoCAT#55 (comment)):
Not tested but I think for histocat you would simply save the distance transformed/binary image in the same naming format as your images - histocat should then also quantify these and again the Intensity value will be indicative if a cell is inside/outside of a tissue level mask.
Using the gating functionality, you could then easily identify cells inside these tissue level maks).

Here also a rough example how to achieve this:
(note this needs ImcPluginsCP)
distance_to_mask_example.zip

Also answers question from #40

Hi Vito,
Thank you for your reply.
I have tried several methods before, like using MaskImage to mask RescaledCell (from 2_segment_ilastik) on the intensity image of the Transform Binary, actually it can't save as a distance from cell to BV. As you mentioned above, I tried to identify Vessel object using rescaledintensity and calculate the minimum distance between 2 objects(Vessel object [parent] & previous identified RescaledCell [child] ). An error occurred here:
Error while processing RelateObjects: u'None'
seems like many cells can't calculate the distance?
It's also weird that in the final cells.csv, only a small amount of cells have a minimun distance to BV even in a image that identified as least 1 blood vessel.

Beside, I also curious about the cellid problem, would the cellid/number of a specific image change in different cellprofiler mask with identical parameter?

Anyway, thank you again, helped me a lot. Good luck to your submission,
Funan

from imcsegmentationpipeline.

votti avatar votti commented on June 9, 2024

The Intensity Image from Transform Binary gives you an image where the value of each pixel is the distance to the border Blood Vessel/background.

As said you can either:

  1. save this image and use it as an additional channel image for HistoCAT
  2. measure your 'RescaledCell' with the Measure Object Intensity module, you will get a table where the 'MeanIntensity' of the 'Transformed' image corresponds to the distance to the interface.
    This can be saved with 'ExportToSpreadsheet'.

Hope this helps

from imcsegmentationpipeline.

hfl112 avatar hfl112 commented on June 9, 2024

The Intensity Image from Transform Binary gives you an image where the value of each pixel is the distance to the border Blood Vessel/background.

As said you can either:

  1. save this image and use it as an additional channel image for HistoCAT
  2. measure your 'RescaledCell' with the Measure Intensity module, you will get a table where the 'MeanIntensity' of the 'Transformed' image corresponds to the distance to the interface.
    This can be saved with 'ExportToSpreadsheet'.

Hope this helps

But the MeanIntensity isn't what I want. Actually I'd hope to calculate the distance of each cells to the blood vessel surface. I thought the RelateObjects might be more appropriate.
And after 'ExportToSpreadsheet', the rescaledcells.csv only got 5 columns like this ,didn't include the 'distance' column

from imcsegmentationpipeline.

votti avatar votti commented on June 9, 2024

You need to take the MeasureObjectIntensity module to measure the image (the one from 'Transform Binary') in the objects (eg Rescaled Cells):
http://d1zymp9ayga15t.cloudfront.net/content/Documentation/cp2.1_2.2manual/MeasureObjectIntensity.html

"distance of each cells" is not an precise term, that's why it makes sense to not only have a single distance measurement.

Measuring the 'transformed' image, where each pixel represents the distance to the bloodvessel border, allows you to get:

  • average distance of all the pixels to the bloodvessel border (=MeanIntensity)
  • minimal distance of any pixel to the bloodvessel border
  • maximum distance of any pixel
  • median distance of any pixel (=MedianIntensity)

from imcsegmentationpipeline.

hfl112 avatar hfl112 commented on June 9, 2024

You need to take the MeasureObjectIntensity module to measure the image (the one from 'Transform Binary') in the objects (eg Rescaled Cells):
http://d1zymp9ayga15t.cloudfront.net/content/Documentation/cp2.1_2.2manual/MeasureObjectIntensity.html

"distance of each cells" is not an precise term, that's why it makes sense to not only have a single distance measurement.

Measuring the 'transformed' image, where each pixel represents the distance to the bloodvessel border, allows you to get:

  • average distance of all the pixels to the bloodvessel border (=MeanIntensity)
  • minimal distance of any pixel to the bloodvessel border
  • maximum distance of any pixel
  • median distance of any pixel (=MedianIntensity)

Sorry for I confused the MeasureObjectIntensity and MeasureImageIntensity .
And I have got the mean/minIntensity to the edge using the right module. As negative score mean outside the mask, so the Intensity_MaxIntensityEdge_DistanceImage are the actually minimal distance of any pixel of a specific cell to the blood vessel, and vice versa?
Thank you

from imcsegmentationpipeline.

hfl112 avatar hfl112 commented on June 9, 2024

Cool that it finally worked!
"Intensity_MaxIntensityEdge_DistanceImage are the actually minimal distance of any pixel of a specific cell to the blood vessel, and vice versa?"
That sounds correct!

"""Beside, I also curious about the cellid problem, would the cellid/number of a specific image change in different cellprofiler mask with identical parameter?""
Hm if I understand you right, your question is, if the 'Image number' are linked to the 'ObjectNumber'.
In CellProfiler each image is given a number before anything is processed. Given you load the same mask/process the data with the same parameters, Object numbers should not change. The Object number should not depend on the 'Image Number' an image is given but really just on the input images.

THANKS A LOT!!!!

from imcsegmentationpipeline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.