Save images to different folders depending on class label?

cellprofiler

#1

Is there a way to classify an image and save the images to different folders depending on the class label? I know that it is possible to use FlagImage to skip the image set if flagged, and I could of course use one pipeline per class and only save if not flagged, but it would be nice to be able to do this within the same pipeline.


#2

I’m not aware of a way to save classified images into sub-folders with sub-folder names being generated on-the-go.
But what you can do is to use several SaveImages for each class, and in each module add a suffix accordingly.
For e.g. “__class1” , “__class2” suffixes
So in the end, although all images are saved in the same folder, they can be easily distinguished and moved around by command lines.

Probably there is a better way though.


#3

Hi Minh,
Thanks for the reply. Maybe I was a bit unclear. I want to classify the entire image into a specific class and save the image into a folder depending on the class label. Saving all images to the same folder with different suffixes might be an option, but I don’t think using several SaveImages is the way to save the image only once with the right suffix.
/Petter


#4

Hi Petter,

Yup, but it’s a little wonky and will require you renaming your folders later- you can use the “Default Output Folder sub-folder” option to save by a FlagImage class as a piece of Metadata- so if you had 3 classes you could set the option like this, and (assuming your images perfectly classify into their bins) you’ll end up with 3 subfolders- 100,010, and 001, which will correspond to your Class1, Class2, Class3.


#5

Thanks Beth, that’s a clever trick! I will give it a try. Hopefully, the collaborators will be satisfied with that.
/Petter


#6

Beth, How do I get CellProfiler to interpret the flag names as Metadata?


#7

Metadata is the default, but it’s based on the flag’s category


#8

The problem was that I tried to write the class labels instead of right-clicking and selecting. Now I have got it working. Thanks!