How to batch process stitching image tiles from Vectra Polaris?

We’ve been stitching the individual image tiles (component images) from the Vectra Polaris into a whole-slide image. Doing this in QuPath using the script from:

Currently we’re doing this one slide at a time.
Is there a script to batch process this? Or a modification to the above script to accomplish this?
That is, read in the image tiles for slide #1, stitch them together, save the resulting whole slide image file, then read in the image tiles for slide #2…etc.
Haven’t found anyone around here who knows Groovy scripting well enough to help with this.


1 Like

I happen to know that someone has… maybe @Colt_Egelston will be willing to share?

1 Like

Hi Michael and Mike,
Yes our lab solved this problem recently, and it runs great for us. You may find a few whole slide images that don’t end up loading correctly into Qupath. Those you’ll have to restitch, and they tend to me large images (>15GB). Otherwise the script below works almost all the time.

Of course, this a relatively small tweak of Pete’s whole slide stitching script that you referred to, so most credit to him.

Note, you’ll want to change line 34 to choose your folder directory of subfolders.
def rootdir = new File(“D:\test”)

As I say in the script you could also try the below line, but I haven’t tried it yet (@Mike_Nelson idea)
//alternatively could use rootdir = Dialogs.promptForDirectory(“Choose a directory”)//

Hope that helps!


I admit I kinda guessed at that - I like this example of it a little better since it includes an escape:

selectedDir = Dialogs.promptForDirectory(null)
//selectedDir = new File("Path/to/your/image/folder")

if (selectedDir == null)

From: Creating project from command line - #3 by EP.Zindy

One of the best question of the year !

I use this piece to free up memory after each dataset, not sure if it is necessary!!

    //Clear cache after each dataset
    def store =  QuPathGUI.getInstance().getViewer().getImageRegionStore()
    try {
        print "Clearing cache..."
    } catch (Exception e2) {

Thanks Colt and Mike.
This will really help streamline our workflow.