Classify pixel module


hi all,

I only began using cell profiler a few weeks ago and it has been great. I have problems using the classify module. For a start, I loaded five different color images(later on I will increase the number of images to about 300) and I have exported the .hd5 file from ilastik (I had use ilastik to train and classify them). When in the classify pixel module, I import it the .h5 file. But it keeps giving me some funny error message I don’t understand whenever I run the pipe line. Please I need a step by step guide on how to analyize lots of images using the classify pixels module. I know I’m doing something wrong but can’t figure out what.

Another question, in the identify object module, is it the probability output map of the classify pixel module or the input image of the classify pixel module I’m to use as input to the identify object module? How can I identify objects in say 300 images using this method?

Kindly find attached the errors and my pipeline.

Thank you as I look forward to hearing from you guys…

Regards,

Raphael.
pipeline.cppipe (5.93 KB)




hi all,

I installed cellprofiler 2.0 (r11710) so that I would be able to use the classify pixel module on the .h5 file I exported from ilastik…I still get the same error. (I made sure it’s the same image I used for training and classification I use in the cell profiler too.) Please can someone kindly help me? It’s driving me nuts. Been trying to figure out what’s wrong but no success. Thanks.

Regards,
Raphael.

hi all,

On this page, cellprofiler.org/previousReleases.shtml, no such version exists(maybe didn’t check well). Can someone please help me? Thanks.

hi all,

I have figured it out. It’s working now. The problem I now have is how to use the .h5 file format from ilastik and the classify pixel module to analyze 300 hundred which I have trained in ilastik. The example on this page does it for one image alone ilastik.org/index.php?cat=Do … llprofiler. Thanks

The example shown on that page depicts just one example image, but the pipeline is meant to be run on however many images you have. ClassifyPixels will apply the classifier to each image in turn, and the downstream modules will do the rest, assuming your classifier is trained adequately.
-Mark

hi Mark,

Thanks a whole lot for the response :smile: Hope you don’t mind asking clarifying a few things… :smiley: Why is there an apply threshold module in the identify primary objects module? I could use the apply threshold module instead right? Is there some subtle difference between them?

Is it okay to apply a threshold using the apply threshold module before using the identify primary object module?

Thanks as I look forward to hearing from you.

First, what was the fix for your original problem? Are you using ilastik version 0.5? Any higher versions of ilastik will likely not work.

Can you specify what you mean here? ApplyThreshold and IdentifyPrimaryObjects are two independent modules. Sorry, maybe I’m misunderstanding.

The biggest difference is that the ApplyThreshold module produces and image, while IdentifyPrimaryObjects produces objects. Typically users want to segment, or find objects, so they use IdentifyPrimaryObjects. But if you want the output to simply be a background mask then I could see using ApplyThreshold would be ok. Note that the ilastik folks recommend using a simple manual thresholding method = 0.5 since the output of ilastik is a probability map.

Does that make sense?
David

IgnoringDust.cpproj (217 KB)



IgnoringDust.cpproj (217 KB)

hi Mark and David,

Thanks for the reply. Kindly find attached the screen shot of my cellprofiler window and the pipeline I’m currently using and also a sample of the image I work with. Since the objects(crystals) have almost the same pixel intensity as the background, I opted for the ClassifyPixels module bundled with ilastik…(It’s pretty good stuff…kudos to u guys for including it… :smile: …hoping newer versions of cell Profiler will work with ilastik too). I want to identify crystals. That is my aim. I applied a threshold using the ApplyThreshold module before using the identifyPrimaryObjects module where I applied another threshold. Primarily, my aim is to identify objects in the image. I want to know if it’s necessary to use the Apply Threshold module before the identifyPrimaryObjects Module. I messed a bit with a threshold of 0.4,0.5 and 0.6 in the identifyPrimaryObjects module, there was no reasonable change in the number of objects identified (This I expected though).

Thank you as I look forward to hearing from you.

Regards,
Raphael.



Hi Raphael,

You should have the input image in ClassifyPixels exactly the same as the image you classified in ilastik. So no, you should not do any pre-processing in CellProfiler before ClassifyPixels. Therefore your pipeline should look like:

(1) Images (or LoadImages if you really want)
(2) ClassifyPixels (on the color images)
(3) IdentifyPrimaryObjects with a Threshold Strategy = Manual (set to 0.5)
then any measurements and export.

Other things I noticed:

  • You have ImageMath > Invert of a color image (a little unusual in itself), but then you use ColorToGray > Combine, which just combines all the channels back together, which seems unproductive. In fact, if the crystals are the bright cyan colored spots in the original image, then you don’t want to invert the image at all since CellProfiler assumes that foreground is necessarily brighter than background.
    In any case, my suggestion would be to train on your raw color images in ilastik, and then drag your images into the Image module in CellProfiler and have the first module after the 4 Input modules be ClassifyPixels. The exported classifier from ilastik (the *.h5 file) is a set of weights that are strictly only useful on images in CP with the same characteristics, i.e. the same as used in ilastik.
  • You are using LoadImages, and not the input modules above. That is ok, but note that LoadImages is really only intended any more for legacy uses. It works, but we are recommending new users to use the input modules above.
  • The apparatus and shadow on the left should be cropped, and hopefully before ilastik sees it. It might work, but depending on your ilastik size ranges, it could throw off the classifier I suspect.

Cheers,
David

hi David,

Thanks for the reply.

. I’m not quite clear here :frowning: You saying here I should train my 300 hundred images in ilastik first and then load all trained images in the image module in Cell Profiler instead of using my original images?

. Supposing in the LoadImage or Images module, I loaded all the 300 hundred images I trained in ilastik, then at every cycle, one of them will serve as the input in the ClassifyPixels module right?

. I don’t quite understand what legacy uses means :frowning: . I’m currently running on a lower version of cell profiler (2.0 r11710) because the new version doesn’t support ilastik. I haven’t seen any input modules in this version but I have seen them in version 2.1.

Regards,
Raphael.

[quote]. I’m not quite clear here :frowning: You saying here I should train my 300 hundred images in ilastik first and then load all trained images in the image module in Cell Profiler instead of using my original images?
[/quote]

No, not at all. Briefly:
(1) Load in, say, 4 images in ilastik (you may need more or less, just an example)
(2) Train on 2 images in ilastik and get a classifier
(3) Test the ilastik classifier on the two untrained images by looking at the pixel segmentation
(4) Once you are satisfied with the performance on this small test/training set, load all your images into CellProfiler
(5) CP is designed as a pipeline tool that loops through all your images and then ClassifyPixels (loded with your exported ilastik classifier) applies the classifier to each image set for each cycle of the pipeline

No – I think my above answer addresses this misconception though.

OK, I’m confused now! You supplied a *.cpproj file which indicates you are using CP 2.1, not 2.0 ( v11710), no? Or did you rename the file?

By “legacy” I assumed you were using 2.1 and LodImages has been replaced by 4 input modules.

Also, ilastik 0.5 is indeed supported in 2.1 on Windows. What is the issue you are having?

David

hi David,

Thanks a lot for the reply. Most likely I was initially doing something wrong, because the classify pixel module now works on my cell profiler 2.1. I guess probably it happened because I wasn’t at the time using the legacy modules.

I have another question…please don’t get bored with my so many questions :frowning:

I trained ilastik with three labels on four images. For my analysis (counting of blobs/cells for statistics purposes), I need to have three labels in ilastik. One for background, the other for the very bright crystals, and the last one for the crystals that are not so bright…

If all only use two labels, one for background the other for both bright and not very bright crystals, the number of blobs/cells the idenfityPrimaryObjects module picks out is less by about a factor of 5.

Kindly find attached two samples of the images.

I want to to be able to identify as primary objects the blobs/cells from both classes(labels) which belong to the bright crystals and the crystals which are not so bright.

Kindly find attached the pipeline I have been messing around to achieve this. This doesn’t work well because the size of the blobs are way smaller than they should be.

Thanks David as I look forward to hearing from you.

Regards,
Raphael.

Kindly find attached my project and pipeline.

P.S My images have uneven illumination, I guess there is no need to apply any illumination correction module (which unfortunately have tried severally to implement in the past but failed) before ilastik since it takes care of all that right?
threelabels1.cpproj (333 KB)
threelabels.cpproj (333 KB)




Hi Raphael,

I cannot test ClassifyPixels without the exported ilastik classifier, but that is ok. One thing to note which might solve your issue is that the classes in ClassifyPixels are zero-based, i.e. if your ProbabilityMap1 corresponds to the top-most class in ilastik’s list, then it should be Class=0 (NOT 1) in ClassifyPixels. And then the second ilastik class would be Class=1 in ClassifyPixels. If, however, your background class is the topmost in ilastik, then your settings are correct – see below for more ideas.

You also want to minimize any ‘processing’ that goes on in IdentifyPrimaryObjects and just threshold the image. So that means that you should almost certainly turn off ‘declumping’ in IDPrimaryObjs:
(1) Set setting “Method to distinguish clumped objects” = “None”.
(2) Also set “Fill holes in identified objects” = “No”.

Does that help?
David

hi David,

Thanks for the reply. I tried your suggestions. The results looked better but if one looks closely the difference in size could still be observed. I tried uploading my classifier but the website pops out this message in red when I tried to do so. It says ‘The extension h5 is not allowed’. Is there a way I could send it to you? maybe via email or some other means?

Regards

Raphael.
threelabels1.cpproj (333 KB)

Try sharing with Dropbox, Google Drive, or any online sharing tool and paste the link here. You can zip up the file, too and it should upload ok.
David

hi David,

Here is the link. Thanks

drive.google.com/a/aims.ac.za/f … sp=sharing

Raphael.

hi David,

Is it possible to use the correct illumination module first on the images to correct for uneven illumination before using them as classifiers in ilastik?

Regards
Raphael

Hi Raphael,
I requested access to your shared file. You may want to make the access public for other Forum users.

I recommend using the same input images in ilastik as you do in CellProfiler’s ClassifyPixels. So if you want to correct illumination first and then train using the illumination corrected images in ilastik, that is ok. However note that most (all?) of ilastik’s filters work on local image differences (e.g. spatial derivatives, Laplacian of Gaussian, Hessian, etc) so that long-range spatial illumination artifacts typical in microscopy may not be that harmful to ilastik’s classifier. I have not tested this, but I see using ilastik before CP as one benefit that may mitigate the need for illumination correction (for veridical segmentation at least – if you really need to measure quantitative intensity differences, then you may need to correct illumination at some stage).

David

Hi David,

Thanks for the reply. Okay I will make(try to :smiley: ) it public. I’m not really very familar with google drive. I thought once the link is shared everyone will have access to it.

Is it possible to run three cell proflier projects simulatenously on the same computer? By this I mean, load say 300 images in cell profiler and while it is processing, start up another cell profiler project by clicking on the cell profiler short cut on my desktop, launch it, load the same set of images and process(also do the same for the third). In all the cell profiler projects, the only thing that will change is the threshold. My computer is a 64bit Dell product with 8GB RAM and 3MB cache memory. Do you think the computer will be able to handle it?

Usually, it takes about 90minutes to analyze 300images with the current pipeline I have.

Thanks.

Raphael.

hi David,

here is the link drive.google.com/folderview?id= … sp=sharing

Via drop box : dropbox.com/sh/lqxe819nj29l … 6c8TH0sYRa

My pipeline counts and returns the mean number of blobs in each image. It also calculates standard deviation of features such as intensity, Eccentricity etc…BUT it doesn’t calculate the standard deviation of the number of blobs (objects) counted. Is there a way I can do that?

Thanks alot for all your responses thus far. I really appreciate them all

Raphael.