Excluding certain results

cellprofiler

#1

Hi all,

I’m wondering if CP can exlude certain results regarding object counts.
My pipeline measures insulin within the boundaries of the IdentifySecondary, however 10-20% of all cells counted contain less than 20 insulin granules. Is there a way of exluding these results? (Is it something for CP analyst to do)?

Also, I’m trying to figure out the best way to identify cell boundaries. Does anyone know of any whole cell marker that ultimately allows CP to effectively discern boundaries? (I’ve tried wheat germ agglutinin, with no success)
How about taking a direct transmitted light channel of my images and apply IdentifySecondary? and then use maskimage to count the speckles (insulin)

For my images/pipeline, while CP identifies all the the insulin speckles, it simply cannot identify and separate all clumped nuclei, therefore results will be skewed.

Anyone tried these sorts of things?

Kind Regards,
Tim


#2

Hi Tim,

It turns out that you can actually exclude results based on a particular measurement by using the (aptly-named) FilterBuObjectMeasurement module. However, the means by which to make it exclude based on the measurements you want is not that intuitive and we didn’t document it that well. Also keep in mind that these comments apply to our newest release 5811, where we updated how measurements are handled:

(1) Add a Relate module to match the insulin (which I’ll refer to as Speckles) to the boundaries of the IdentifySecondary (which I’ll call Cells). The result of the Relate module is that each Speckle is counted as a “child” to a parent Cell.

(2) Add a FilterByObjectMeasurement module. Our Help on its use is reasonably self-explanatory for other measurements, but what is not clear is that the Speckle count per parent Cell is also a measurement created by Relate and can be used to filter objects as well.

For the “Object to filter by” enter “Cells” and for “Category to filter by” enter “Children”. Where it gets tricky is that for “Feature to use”, you enter “Speckles” and it will know to look for the children count as the measurement. Then for “Minimum value”, you can enter “20” (or whatever criteria you want).

In this way, all Cells with a Speckle count of less than 20 will be excluded. These remaining Cells can be used for other purposes downstream in the pipeline.

For your issues with clumped nuclei, have you experimented with the various thresholding settings to try to get an optimal result?

Hope this helps!
-Mark


#3

Hello

Thanks for your advice. What you said makes sense, but I cannot get it to work.
For my pipeline, I have 2 images, one is dapi/nuclei and the other is insulin granules. Through my pipeline my identify modules are IdentifyPrimAutomatic, nuclei and granules (insulin granules) and IdentifySecondary called insulin (the cell cytoplasm using the same image used to process granules).

I get this error

There was a problem running the analysis module FilterByObjectMeasurement which is number 20.

No measurement with name “Children_Granules_CorrRed” found. Image processing was canceled in the FilterByObjectMeasurement module (#20) because an error ocurred when retrieving the data. Likely the category of measurement you chose, Children, was not available for Insulin with feature Granules, possibly specific to image ‘CorrRed’ and/or Texture Scale = 1.

Stack:
FilterByObjectMeasurement in /Users/t.pan/Applications/CompiledCellProfiler/CellProfiler_mcr/Modules/FilterByObjectMeasurement.m (123)
AnalyzeImagesButton_Callback in /Users/t.pan/Applications/CompiledCellProfiler/CellProfiler_mcr/CellProfiler/CellProfiler.m (10424)
gui_mainfcn in /Users/t.pan/Applications/CompiledCellProfiler/CellProfiler_mcr/CellProfiler/CellProfiler.m (12164)
CellProfiler in /Users/t.pan/Applications/CompiledCellProfiler/CellProfiler_mcr/CellProfiler/CellProfiler.m (57)

So, this is what I used in the filterbyobjectmeasurement parameters=:

“Object to filter by” = Insulin (parent cell)
“Category to filter by” = Children (called granules in my Identify module)
“Feature to use” = Granules

The problem I think is happening, the filterbyobjectmeasurement is not calling the correct measurement from the relate module, and instead calling the “insulin” from the identify module.

I’m not sure if my assumption is right, but I have uploaded a sample data set plus my pipeline (including the filterbyobjectmeasurement), if this helps.

http://rcpt.yousendit.com/619344951/e80bb221534e518f3197c270d97c145c

Regarding the nuclei identify, I don’t think it’s accurate because some nuclei are overlaying each other, so it would appear merged. Perhaps you can take a look at my nuclei settings as well

Thanks so much - appreciate it

Regards,
Tim


#4

Hi Tim,

I managed to replicate your results. There was a bug in the latest release of CP which affects how children are processed from Relate, which we’ve fixed but haven’t released yet. So my earlier comments don’t apply (yet), which is my mistake.

In the meantime, here is an alternate way to do the same thing:
(1) ExpandOrShrink on the granule image with “Inf” as the number of pixels to shrink by. This will take the granules and shrink them to points (I’ll call them Points hereafter)
(2) ConvertToImage on Points with binary as the output color (I’ll call the binary image PointImage)
(3) MeasureObjectIntensity on the Insulin objects using PointImage as the input image
(4) Relate to match Points as children to the Insulin parent objects
(5) Finally, use FilterByObjectMeasurement with Insulin as the object, Intensity as the category and PointImage as the image for measurements. Choose feature #1 (IntegratedIntensity) as the feature to filter by.

What this does is basically convert the granules to single pixels, each of which has an intensity of 1. The IntegratedIntensity of the Points sums these intensities for each Insulin object, which is effectively the same as counting the points in the object. By filtering on the basis of IntegratedIntensity, you can then exclude Insulin objects which have less than a certain number of Points (i.e., Granules).

Re: nuclei clumping - For the IdentifyPrimAutomatic module which identifies the nuclei, have you looked at the last parameter, running in Test mode, where you can see the different combinations of segmentation options and results? If you do this, oftentimes it may help to adjust the smoothing/downsampling parameters for a particular test run and see if that changes the results.

Regards,
-Mark


#5

Hi Mark,

This shrinking techniques seems interesting. I’ve yet to try it, but I have some follow up questions about it.

Would shrinking my granules preceeded with correctIllumination modules help CP detect the granules with more accuracy?
The confocal microscope I’m using is spinning disk and though it’s meant to get rid of out-of-focus fluorescence, it still isn’t 100% effective.

Would this technique shrink the object/pixels to say, the maxima, not caring of the intensity or size?

Thanks for your help!

Regards,
Tim


#6

Hi Tim,

Unfortunately, this shrinking technique basically erodes a binary blob until it’s a point, and doesn’t take other information into account. Furthermore, it presumes that you’ve detected the granules accurately already; it’s meant as a post-processing step.
-Mark


#7

HI mark,

I’ve tried your technique just now, well for a while now and I can’t seem to get it working.
If you try out the pipeline with my sample data, you will know what I mean.

http://www.yousendit.com/download/Y2orQk0wQXB0NjgwTVE9PQ

Specifically:
Insulin=cell boundary
Granule=insulin granules

Maybe something to do with the relate module again?

Thanks so much for your help!

Tim


#8

One last thing: I don’t have the border.tif image loaded in with the LoadSingleImage command. Could you upload that as well?
-Mark


#9

Hi Mark,

Sorry about that.

Here it is, http://www.yousendit.com/download/Y2o5MFh1UzdlcEx2Wmc9PQ
You’ll need to redefine location of border.tif

Also, just noticed the new version of CP. Did this version include a fix for this topic? Regarding calling the relate modules and exluding children values?

Cheers,
Tim


#10

Hi Mark,

I’ve just answered my own question. Yes, it does work now.
I followed your instructions as per your previous reply

quote Add a Relate module to match the insulin (which I’ll refer to as Speckles) to the boundaries of the IdentifySecondary (which I’ll call Cells). The result of the Relate module is that each Speckle is counted as a “child” to a parent Cell.

(2) Add a FilterByObjectMeasurement module. Our Help on its use is reasonably self-explanatory for other measurements, but what is not clear is that the Speckle count per parent Cell is also a measurement created by Relate and can be used to filter objects as well.

For the “Object to filter by” enter “Cells” and for “Category to filter by” enter “Children”. Where it gets tricky is that for “Feature to use”, you enter “Speckles” and it will know to look for the children count as the measurement. Then for “Minimum value”, you can enter “20” (or whatever criteria you want).[/quote]

And it works! However I found that I needed to do another relate module, on the filtered cells that has more than 20 insulin granules. BUT, CP gives me an error, saying that I cannot calculate something that has been already been calculated. Here is the error

[code]There was a problem running the analysis module Relate which is number 22.
Image processing was canceled because you are attempting to recreate the same measurements, please remove redundant module (#22).

Stack:
CPaddmeasurements in /Users/t.pan/Applications/CompiledCellProfiler/CellProfiler_mcr/CPsubfunctions/CPaddmeasurements.m (38)
Relate in /Users/t.pan/Applications/CompiledCellProfiler/CellProfiler_mcr/Modules/Relate.m (119)
AnalyzeImagesButton_Callback in /Users/t.pan/Applications/CompiledCellProfiler/CellProfiler_mcr/CellProfiler/CellProfiler.m (10442)
gui_mainfcn in /Users/t.pan/Applications/CompiledCellProfiler/CellProfiler_mcr/CellProfiler/CellProfiler.m (12182)
CellProfiler in /Users/t.pan/Applications/CompiledCellProfiler/CellProfiler_mcr/CellProfiler/CellProfiler.m (57)
[/code]

So to overcome this problem, I had to do an IdentifyPrimAutomatic (again) on my granules images. So there is a duplicate of this, but with different names, so that I can use the filteredInsulin (cells) and relate that to my duplicate granules image to only include cells with more than X number of granules. This had to be done because the output files do not contain any data, hence the need for another relate module.

Anyway, it’s all good. It’s just adding in another 15-20seconds per cycle, which is quite a lot when I’m running lots of images.
Here’s the pipeline and necessary files to replicate my results.

http://www.yousendit.com/download/Y2orcXluTmE4NVZFQlE9PQ

So now, it looks like I can filter out odd shaped nuclei (which are probably not singled nuclei), nuclei that are too close to the border and filter out too little number of granules! Hooray! This takes away a lot of manual work. So now it’s truly high-throughput! Thanks heaps guys!

Kind Regards,
Tim

PS. I guess no need to look into the other method you suggested, that didn’t work for me


#11

We just released a bugfix version of CP, which can now be downloaded. My comments from Oct 27 should be applicable, if you wish to try it.
-Mark


#12

Hi Mark,

Yes, I found that out after trying the new version. My comments about it is posted in my previous reply.
If the relate module could be used without needing me to do another IdentifyPrimAutomatic, that would be super.

Kind Regards,


#13

Hi Tim,

In the second Relate module, try reversing the relationship of the objects as compared to the first Relate module (Children -> Parent or vice versa). This is kludgy, but I think it should work (for two Relate modules, at least).

David


#14

Hi Mark,

I’ve just tried this. Relate module seem to take a fairly long time, to the point I was thinking CP crashed or something… but it went on to completion.
However, I find no such measurement like (mean, insulin, granule_children_count) apart from the original relate.

Sorry, but didn’t seem to work. I’ll just stick to having another IdentifyPrimAutomatic, and hopefully there might be a fix?
Thanks for your hard work

Regards,


New Modules and Help with Further Development