Select an annotation by its name

Hi all,

I have several annotations on a single image.
I would like to run a different classifier for different annotations, which I have named “E1”, “E2” etc…

Usually I had “selectAnnotations()” at the beginning of the script and then would apply the classifier on all annotations. However I can’t figure out what line(s) of code needs to be written to select specifically classifier X on annotation “E1”, then classifier Y on annotation “E2” etc… would you have any idea?

Many thanks for your help

Are they trained classifiers you are using for runClassifier?

Yes, I have already a qpclassifier file which I need to use differently for each annotation

Ugh, I am 90% sure Pete posted how to do this somewhere, but I am not finding it right off. Maybe @petebankhead will remember. And whether it has changed with whatever version you are currently using.

But by default runClassifier will apply to the entire image or hierarchy, selecting objects doesn’t impact it at all.

It sounds suboptimal and perhaps there would be a better way of dealing with this @petebankhead?

I guess one way to dealing with that would be to do the analysis on the whole image for all annotations (they are small) and export the result of only the one I am interested in. Then delete all and repeat with the following classifier/matching annotation.

But even in this case, I am not sure how to export measurement for a single annotation?

Maybe. I tend to avoid the machine learning classifiers whenever possible, so I admit I haven’t really run into this problem. Manual classifiers (scripted) can be controlled more easily.

*And it also sounds dangerous from a data integrity standpoint :slight_smile:

@rmvl You can look in PathClassifierTools for clues.

In particular, note that if you script using the classifier directly then you can pass in whatever objects you want it to classify. But @Research_Associate is correct and in general if you don’t seize control in a script the classification is applied across all detections in the image.

As I wrote here, it’s on my todo list to rewrite the detection classifiers to reuse the new and improved code written for pixel classification, and so I don’t have any plans to further develop that code. But I haven’t got around to it yet… and ‘finishing’ the pixel classifier is a higher priority.

1 Like