stain vector estimation using autodetection in a script

291 views
Skip to first unread message

dnka...@gmail.com

unread,
Dec 30, 2016, 8:04:38 AM12/30/16
to QuPath users

Hi,

 

First of all let me thank you for sharing your program, I think it is very nice and promising.

 

I am trying to implement the stain vector estimation using autodetection in a script, but so far I only got it running with fixed values. I also want to set “Ignore extrema” in the script to a very low value, to catch all. Is this possible, which commands should I use for this?


Thanks a lot and a happy new year!

Daniel

Pete

unread,
Dec 30, 2016, 12:14:31 PM12/30/16
to QuPath users
Hi Daniel,

Currently, there is no easy way to do this in a script - by design (to some extent at least), since it would be risky to apply 'Estimate stain vectors' to an entire whole slide image directly.  Rather, the command is intended to be used interactively within a pre-selected, rectangular region of interest, as described here:
Once determined, these fixed stain values can then be applied across a set of similarly-stained images.

The danger of applying the stain vector estimate command in batch processing to the entire image is that, which it will still 'work' (in the sense that it will do its best to give a sensible result), it may need to downsample a large image very aggressively in order to do so.  This tends to result in stain vectors that are closer together than they should be, and sometimes vectors that are determined in error from regions of artefact (e.g. folds, pen marks).  This can be avoided most easily by requiring manual intervention to use the command interactively.

That said, more or less everything is possible through scripting... even if not necessarily very easily.

In this regard, the source for the 'Estimate stain vectors' command itself is here:

It is long mostly because of graphical considerations, but most of the hard work is performed by calling static methods in an EstimateStainVectors class:

Therefore if you were reasonably comfortable with writing code, it would be possible to write a script that calls the static methods that you want directly.

In the short term at least, I'm afraid that is likely to remain the only option.  There would definitely be value in writing a more sophisticated 'Estimate stain vectors' command that tries to robustly identify stains at a high resolution across all images, even with artefacts present... but it would be a challenging research problem to come up with such an algorithm.  However, if you or someone else would like to do so, that would be great - and we could certainly look at how to get it into the form of a QuPath extension for wider use.

Hope this helps, and happy new year to you too!

Pete
Reply all
Reply to author
Forward
0 new messages