Calculating object property statistics per image

Is there a way that I can calculate statistics ( mean and standard deviation for instance) for an object property I have measured (intensity) in a pipeline for use within that pipeline?

For instance, if I wanted CP to calculate a Z-score for a particular measurement for each object in that image (as a way of flagging potential outliers), I would need to calculate the mean and SD for the objects in that image.

And a related question: what’s the easiest way to calculate the sum of the properties of multiple daughter objects for each parent object. For instance: we are counting and calculating the areas of structures in the nucleus and we would like to calculate the total pixel area covered by these structures for each nucleus.

Thanks in advance

Is it possible to use the metadata module to import the image mean and SD’s from a previous pipeline as image metadata in the pipeline that will calculate the object z-scores? Will the calculatemath module recognize the means/SDs as values with which to perform calculations with?

And if relateobjects allows me to calculate per parent child measurement means does the identifyprimaryobject module I used to identify the nuclear structures (the child objects) output their count number as a parent property I can use in the calculatemath module?

Your line of questioning explores a strategy where the analysis of your objects is performed in a pipeline. This is possible in general, but, as you have already seen, an in-depth analysis requires a complex arrangement of modules and metadata.

It sounds like you are already content with the identification and quantification of objects within your data, which is great to hear; CellProfiler excels at this task. Based on the description of your workflow, you could be ready to use separate tools that use CellProfiler object and feature data as an input. If your goal is to classify objects or filter out outliers, then you might find CellProfiler Analyst helpful. Analyst has tools to train machine learning algorithms and visualize CellProfiler feature data.

Alternatively, the profiling and statistical analysis you describe could be performed in a language like R, Matlab, or Python.

I agree with @karhohs’ analysis that you can definitely do this in CP, but that it may not be the best or easiest tools for the job:

Just to get at your specific questions though-

Is there a way that I can calculate statistics ( mean and standard deviation for instance) for an object property I have measured (intensity) in a pipeline for use within that pipeline?
For instance, if I wanted CP to calculate a Z-score for a particular measurement for each object in that image (as a way of flagging potential outliers), I would need to calculate the mean and SD for the objects in that image.

You can ask CP to calculate per image means, medians, and standard deviations of any measurements in the ExportToSpreadsheet module; I don’t think there’s any way to have it calculate that value and return it to you within the pipeline, but you can indeed export it.

And a related question: what’s the easiest way to calculate the sum of the properties of multiple daughter objects for each parent object. For instance: we are counting and calculating the areas of structures in the nucleus and we would like to calculate the total pixel area covered by these structures for each nucleus.

Since you can have RelateObjects calculate the mean child object area, and RelateObjects will also give you the child count, to obtain the sum you could just multiply the two; you can do this in either a CalculateMath module downstream of the RelateObjects module or after the fact in whatever downstream analysis you do.

Is it possible to use the metadata module to import the image mean and SD’s from a previous pipeline as image metadata in the pipeline that will calculate the object z-scores? Will the calculatemath module recognize the means/SDs as values with which to perform calculations with?

Yes, you should be able to do this by exporting measurements from the first pipeline as a CSV and then using the Metadata->Import metadata from file option in a second pipeline. You may need to mess with the column headings to make sure they’re imported properly, but this seems in principle doable.

And if relateobjects allows me to calculate per parent child measurement means does the identifyprimaryobject module I used to identify the nuclear structures (the child objects) output their count number as a parent property I can use in the calculatemath module?

Yes- after performing the RelateObjects, you should have a Nuclei_Children_NuclearStructure_Count measurement.

Thanks guys, and yes I’ve been looking more and more at how I could use CPA!