Can I use the same tissue classifier on different projects?

I am analyzing a set slides for 3 different markers done on consecutive sections. I built a project for each marker. I want to use the same tissue classifier (tumor vs stroma) in all three projects, but each marker has it’s own intensity feature and threshold. What is the best way to go about it?

Thanks!

Paula

Not 100% sure I am clear on the setup here, but it really sounds like you don’t want to use the same classifier, if the stains are all different. The classifier is essentially a threshold based on the stain and intensity, so if that is changing in every sample the whole classifier is changing.

If the analysis is being done on IF stained sections and you have a specific channel for a tumor marker, you could use that channel independent of the others to segment/classify the tissue, but if it is brightfield, there isn’t likely to be a way around classifying the tissue differently each time (would have to see the sample to be sure). Even using texture features to differentiate tumor and stroma, the texture in any given channel (or OD sum even) will change as the stains change. Deep learning models may at some point give slightly more flexibility in such cases, but even they generally need to have been trained on each different stain type (so essentially you are merging the three different classifiers).

You could try the pixel classifier to see how well it does on any given image, but for now it is not scriptable, and you can’t transfer it between images or projects. Might be worth the wait though, depending on your project and time line.

@paulage adding to @Research_Associate’s comments, I’m also quite unclear on important details, e.g.

  • What do you mean by ‘tissue classifier’? Is this a classifier applied after cell detection (which I’d call a ‘cell classifier’) or are you approaching this some other way?
  • Are the images brightfield?
  • Are the images TMAs, biopsies, whole face sections or something else?
  • Approximately how many images do you have for each marker?
  • How different are the markers, e.g. all nuclear and similar-looking, or quite distinct?
  • Which version of QuPath are you using? v0.1.2 is the stable version and is the one I’d recommend for any analysis that should be done soon… there are many new things in v0.2.0-m2 but they aren’t yet complete.

@petebankhead and @Research_Associate,

I am using v0.2.0-m2, the images are brightfield TMAs, but I extracted each core as a separate images.

As a separate issue: I could open the TMA image without extracting each scene first, since QuPath opens each scene as an individual images/series, but the name of each core I imported when scanning is not shown in QuPath (see image), which may be a Zeiss issue and not a QuPath one.

There are 3 TMAs contaning a total of 341 cores.
The markers are nuclear, cytoplasm and cell (nuclear, cytoplasm and membrane).
The classifier is a detection classifier to classify into tumor and stroma. I understand the texture changes with each stain, but I did not use DAB features for the classifier and it’s the same set of images, so I figured I could use the same classifier for tumor vs stroma for all markers, and not have to train it with multiple images 3 times.
I did:
setColorDeconvolutionStains
SimpleTissueDetection
selectAnnotations();
Cell detection or PositiveCellDetection
SmoothFeatures
runClassifier

Can you use one classifier for tissue vs stroma and then another to say what cell is positive for each marker?

I tried ruining the classifier with “none” on intensity features and then running the positive cell detection, but it didn’t quite work.

I now get an error when loading the classifier, I’ll try going back to the stable version.

Thanks,

Paula

If you want to extract core names you put in in Zen, you might want to try Split Scenes (Write Files) in the Processing menu. It will give you a ton of files, but if you labeled specific tiles/positions/etc, there should be a checkbox to include that information in the file name.

Ah, I suppose you could do two different cell-based classifiers, and if they work, great! It hasn’t been my experience that those sorts of things are reliable between stains (due to variability in fixation, staining, bleedthrough between stains, etc), so definitely do a lot of double checking.

That said, the two ways to go about it would be to use one classifier for tumor vs stroma. If it is one of the machine learning classifiers, you can just use the runClassifier(“path here”) command to run an initial command, and then possibly use derived classes (read more here) to differentiate between positive and negative for each of the tumor/stroma types.

Another way would be to use a more granular approach (my preference) and after classifying an object, set a new variable. For example, after running the tumor/stroma classifier (which you would just access the same file path in every project), you would use putMeasurement to create a new “Tumor” measurement that would be “1” for tumor or “0” for stroma. Or maybe -1 if you have some criteria for excluding cells. Then run the second classifier. The cell’s “class” would hold the marker classification information, and the Tumor variable would determine whether that cell was considered to be in the tumor.
More on adding measurements here. And maybe specifically this one as an example, where you would check the cell’s class, and then put the new measurement within the loop.
I prefer that type of method, because if you later decide you want to rerun a classifier, you can pick which half of the classification to target independently (though if you redo the tumor/stroma, you would want to create another putMeasurement for the other marker classes).

@paulage QuPath doesn’t really support training multiple classifiers, e.g. one for tumor vs. stroma and a second to distinguish positive vs. negative. There are almost always elaborate workarounds (using scripting) for things that aren’t directly supported but I don’t know if you want to get into that or not. If you do, @Research_Associate is definitely the authority on elaborate workarounds to get past current limitations :wink:

I tried ruining the classifier with “none” on intensity features and then running the positive cell detection, but it didn’t quite work.

Running positive cell detection again should just replace the existing cells. You need instead to run a one-line script, e.g.

setCellIntensityClassifications('Nucleus: DAB OD mean', 0.2, 0.4, 0.6)

See https://petebankhead.github.io/qupath/tips/2018/03/22/setting-positive.html for more detail on this.

Thanks for the suugestions @petebankhead and @Research_Associate. You were correct, though, it is better a run a classification for each stain.
Paula