BodenmillerGroup / ImcSegmentationPipeline

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

Export Scaling_FullStackFiltered #72

Closed nilseling closed 2 years ago

nilseling commented 3 years ago

Hi @votti,

this is just to be complete: I can't figure out why CellProfiler (v4.0.7) won't export Scaling_FullStackFiltered in addition to Scaling_FullStack. It would facilitate reading in the data if a scaling factor is provided for each measured image set. I ran the exact same pipelines on our test dataset here. Just checking if you had an idea what could be the reason for this. Cheers,

Nils

votti commented 3 years ago

Hi @nilseling ,

This is because the way CP handles images: Scaling is something done while loading images. Scaling_FullStackFiltered is an image derived from Scaling_FullStack. As there is no additional scaling done during the transformation between Scaling_FullStack -> Scaling_FullStackFiltered no scaling factor is recorded.

This is the reason why eg in my Spherpro Processing I had a manual configuration file tracking the lineage of processed images: https://github.com/BodenmillerGroup/analysis_spheroid/blob/master/config/spherpro/stackrelations.csv

I think there are couple of ways to deal with or improve the situation: 1) Clean separation of image processing and measurement: Make sure no additional image processing is done in the CP measurement pipeline. Eg all the filtered images being temporarily written out in some previous pre-processing pipeline and the measurement pipeline simply loads these images and measures them. -> Easiest workaround

2) Add a CP module to output the lineage of images as metadata: seems feasible as the Image objects in CP record their parents: https://github.com/CellProfiler/core/blob/6b1f04a716967e561c704004a784a03adb13287f/cellprofiler_core/image/_image.py#L18 -> Could be added in the form of a module "Add Image Lineage" -> Downstream software would need to suport this kind of metadata

3) Add/modify a CP module to add a measurement that represents the "root scale", ie. the scale of the root parent of a given image: Again easy to do, as parent-child relations are preserved in the Image objects -> Module would just need to follow the parents until the root Image is found and report the scale of this image.

4) Request that CP is modified that child Images inherit the scale property of parents: This would be again rather straight forward to implement, but would definitely be a change in core behaviour of CP. -> Would require raising an issue with CP.

nilseling commented 3 years ago

Hey @votti

sorry, I completely missed you answer! Thanks for the explanation! I'll play around with this once I get back to the pipeline. But I like the idea of separating pre-processing/filtering and measurement. I'll leave this issue open for now. Best,

Nils

nilseling commented 2 years ago

Hey @votti do you remember if you ever had issues using CellProfiler to read in 16-bit multi-channel images exported by CellProfiler. It seems like once they are written out after pre-processing CellProfiler only reads in the first 3 channels as RGB. Cheers, Nils

nilseling commented 2 years ago

Done in #87