Automate estimate stain vectors by script in QuPath

scripting
qupath
#1

Hi Pete,

congratulations for the new version of QuPath. The new pixel classifier seems very promising.
I am looking forward for the time it is scriptable :slightly_smiling_face:

I have a questions concerning scripting the estimate stain vector function.

In case in a project are many rather small tiff files with snapshots from different tissue slides and there is an inherent staining variance it often helps to adapt the stain vectors by the estimate stain vector function.

These images are that small, that the function can run across the whole image - still taking only several seconds.

After createSelectAllObject(true); and selectAnnotations(),
it would save a lot manual time to script the estimate stain vector function.

Is that possible by script to extract the vectors from the automatically selected annotation?

Best
David

0 Likes

#2

I tried to find a work-around for this, but the ImageJ1 plugins I could find didn’t really give the kind of stain vectors I wanted in an automated way, and the newer FIJI plugins/classes are not compatible. It may not be doable right now, but Pete (@petebankhead) might have a better answer when he gets a chance.

1 Like

#3

It’s possible (I guess), but neither straightforward nor encouraged for the reasons given at https://groups.google.com/d/msg/qupath-users/vVNkzcn9V7U/vcI0x5TiAgAJ

The stain vector estimation is not terribly sophisticated, and can easily make bad mistakes if applied to regions containing other colors or artefacts. Also, if the image is large enough to require some downsampling (from a quick look at a code, that seems to be > 4000 x 4000 pixels) then it tends to result in vectors that are closer together than they really ought to be.

If you’d like to try it anyway, the link above should give some pointers. I admit I haven’t tried it myself.

0 Likes

#4

Let me add one comment. The way to do this properly is to use single dye images as Ruifrok and Johnston suggested in their original paper, and not from areas which look like there is only one dye localised. The reason for this is that very likely that stains colocalise a bit, so what one thinks is, let’s say only haematoxylin, it is not. That results in vectors that are not pure, and “closer together” like Pete mentions above.
So ideally the best automation one could aim to is to have a single-dye set of slides, on which you determine the vectors, then use those vectors for stain separation with the rest of the images.

1 Like