QuPath open and access multiple scenes image file

Sample image and/or code

I am working with multiple scenes image which I created an analysis pipeline in groovy, now I want to pass it to another in a ready to use pipeline without worrying about opening the image in QuPath UI and can run from the terminal with custom input
I am trying to open the file through scripting.
However either terminal script or groovy script only able to load the czi file and by default only open scene #0.

The file looks like this
Screen Shot 2020-10-14 at 2.06.10 pm

The goal is to open multiple Scenes .CZI image with QuPath terminal/scripts and custom input file.

With the terminal, I tried with other tiff format and it works well however when it come to multiple scenes image the script by default only opens the first scenes.
From the terminal
../QuPath-0.2.0-m11/bin/QuPath-0.2.0-m11 script /path/to/script/automate_open_czi.groovy -i /path/to/file.czi
Where the groovy file look like this:

def imageData = getCurrentImageData()
def server = imageData.getServer()
int imageWidth = server.getWidth()
int imageHeight = server.getHeight()
def path = server.getPath()
println(path)
println('----')
println(imageData)
println(imageData.getClass())
println(imageWidth + ' , ' + imageHeight)
println('-----')
for(int c=0; c< server.nChannels(); c++) {
    def channelName = server.getChannel(c)
    println(channelName)
}
print('Done')
// it is more below but I want to access the specific scene from the terminal 

I even try to manually set the path to image and open it with

ImageServer<BufferedImage> server = ImageServerProvider.buildServer(filename, BufferedImage.class)

imageData = new ImageData<>(server)

But there is no option to choose the scene from there.

Challenges

Is any API that allows me to customize the path to the image from the terminal script or from groovy script and let me open the scene of my choice? Thanks

1 Like

@petebankhead might have a better solution, but my first suggestion would be to split the files in Zen. It has an easy to use “Split scenes (Write files)” as one of the basic functions, then you could target whichever scenes you want. If you wanted to script that as well, I suspect you could with Zeiss’ python integration, or maybe an OAD macro.

Maybe you can use the sub-image path though? Not something I have played with.

1 Like

@minhtran1309 the easiest option is to create a project containing your difference scenes first, and run the script specifying the --project rather than the image. You can optionally specify a single image (by name) in the project.

The more awkward option is to try including a query like ?series=1 in the image URI and pass that instead. I haven’t tested it from the command line, so am not totally certain it works, but the relevant bit of the code that should parse this is here:

1 Like

Thanks for your suggestion. Using Zeen to split scenes was indeed what I thought of after spending hours with the scripting.

I tried to create the project and add the multiple scenes file to it. However, it can only run with the UI on. for example when I run the groovy script like this

def project = getProject()
print(project)
//for (entry in project.getImageList()) {
//    def imageData = entry.readImageData()
//    def server = imageData.getServer()
//    println(entry.getImageName())
//    println(server.getPath())
//}

execute the script from the terminal

../QuPath-0.2.0-m11/bin/QuPath-0.2.0-m11 script -p /path/to/Qupath/project/project.qpproj path/to/script/automated_scripts.groovy

it only print out null values.
but if I run it from QuPath script compiler, it can indeed print out the image name.

Try putting the script name before the project path. As mentioned in the command line section of the docs the order is important – see also Unexpected command line usage in 0.2.0-m10 and greater