Scripting .json classifiers in QuPath (0.2.0-m9)

I love the fluorescent colocalization capabilities of the newer QuPath releases, but I am not able to script the new classifiers.

How do you script the .json classifiers? \

Thank you!

//SET CHANNELS//
setChannelNames(
      'DAPI',
     'GFP',
     'NeuN')
selectAnnotations();
runPlugin('qupath.imagej.detect.cells.WatershedCellDetection', '{"detectionImage": "DAPI",  "requestedPixelSizeMicrons": 0.5,  "backgroundRadiusMicrons": 8.0,  "medianRadiusMicrons": 0.0,  "sigmaMicrons": 3.0,  "minAreaMicrons": 10.0,  "maxAreaMicrons": 400.0,  "threshold": 1000.0,  "watershedPostProcess": true,  "cellExpansionMicrons": 5.0,  "includeNuclei": true,  "smoothBoundaries": true,  "makeMeasurements": true}');

// [**INSERT**... Classifier scrip] //

//SAVE ANNOTATIONS //

def name = getProjectEntry().getImageName() + '.txt'
def path = buildFilePath(PROJECT_BASE_DIR, 'Colocalization')
mkdirs(path)
path = buildFilePath(path, name)
saveAnnotationMeasurements(path)

This remains a work in progress, but for now the following should work:

runObjectClassifier("My classifier name")

assuming that you have a classifier called My classifier name in the current project.

1 Like

Sorry to bring this up again!

But, on this note, is there any way to get a pixel or object classifier from a location external to the project? Say you had 50 patients/projects (and maybe we should be using metadata) using the same classifiers, and wanted to access them all from the same folder.

Especially handy if we decide later to change one classifier, and do not want to swap out all 50!

For the object classifiers this should be straightforward:

runObjectClassifier('/path/to/classifier.json')

The pixel classifier is more awkward, because it depends why you’re running it (e.g. to create objects) and that requires more information and parameters. It’s no doubt possible to hack together a solution that works for m9, but I’d rather not and creating proper way to do it remains on my todo list.

2 Likes

Ah, ok. We have 5 pixel classifiers and one object classifier, so I guess that’s it for now.

Well, if you have already got a script to run the pixel classifier for the project, you could add a few lines to copy the classifier file to the project first…

I just don’t want to encourage that kind of thing, so it becomes widely used even when the ‘proper’ way comes along :slight_smile:

1 Like

Oh right, good call!