Enter coordinates for ROI rectangle and file name to run cell detection from command line

441 views
Skip to first unread message

Adit Sanghvi

unread,
Aug 4, 2017, 3:33:51 PM8/4/17
to QuPath users

Hi,
I want to run basic cell detection in QuPath, from the command line.


Is it possible to enter coordinates from a user and a specified image, and then have QuPath run any script on that image?

eg. groovy detect.groovy -x 2,2 -y 3,3 ~/image.svc

This should open up image.svc, draw a rectangle from 2,3 to 2,3 and run default cell detection code in QuPath.

I've seen some posts on creating a ROI from coordinates, but how do I run this from the command lane and not the QuPath script GUI? Should I include the QuPath code in the same code that handles parsing of command line arguments?

In essence, how do I link up the command line and QuPath?

Pete

unread,
Aug 5, 2017, 4:59:24 AM8/5/17
to QuPath users
There is some information about running QuPath from the command line at https://groups.google.com/d/msg/qupath-users/7cdsBsdy4HQ/faFXwPN3BgAJ

Hopefully that helps.  It isn't something I have needed myself to date.  The 'Run for project' option allows me to run scripts across multiple images from the script editor, or else I could write a more elaborate Groovy script that takes care of file handling itself.  But in this second case I'd still run my script directly from the script editor, since that way I do not need to bother with setting the classpath etc. manually.
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Adit Sanghvi

unread,
Aug 7, 2017, 1:28:12 PM8/7/17
to QuPath users
I am planning on running QuPath in a pipeline, where running it from the GUI would be a lot more troublesome than running it through the command line..

I tried the above method. However, the image isn't being passed into the script - can you test the same? I am using a JPG image, that loads into QuPath GUI and does the annotation. Using command history, i tried the same script on the commandline but it says "Image not found". 

Using the command line, can you try passing an image to a script and running any basic analysis via the script? This will really help me in my project.

QuPath is my first choice and I love the functionality - would really want to integrate it into my workflow. 

Thanks again!

micros...@gmail.com

unread,
Aug 7, 2017, 4:07:46 PM8/7/17
to QuPath users
This is also a bit outside my wheelhouse, but is there any chance that you are only loading the image, but not actually setting it as "active" or something like that?  For example, with the GUI, you load all of your images and they show up on the left bar, but you need to set one of them as active (open in the main viewing area) or else running a script fails, short of pointing the script at each image/datafile through the Run for Project command.

Again, I don't know, but I am guessing there is a missing step actually pointing the script to the image/.qpdata file associated with it.

Also, there are few script and GUI commands that will fail with JPG/JPEG unless you have pixel size data integrated into them somehow.  I figure you have already checked the script within the GUI, but just in case you haven't you may want to check that!

micros...@gmail.com

unread,
Aug 7, 2017, 4:08:22 PM8/7/17
to QuPath users
Oh, nevermind, I see this was handled in the above thread!

Adit Sanghvi

unread,
Aug 9, 2017, 10:37:13 AM8/9/17
to QuPath users
Is there any way to access the image path from the groovy script that is being run using the command line (java -jar -image -script)?
  
What I can see is that in the main class, QuPath.java, you set the image data using QP.setBatchImageData(imageData); 
I'm assuming this is called via the script which makes me lose sense of where the "path" is exactly.

I can use QP.getCurrentImageData() in the groovy script to get the file name that has been passed in, but it seems like more of a "hack" than anything.

Gives me the following output : ImageData: Not set, image_name

This causes me to lose the entire filepath and just have the image name.. I need to use the filepath to access a similar file in the groovy script, image_name.XML, that contains coordinates for ROI.

Hope this makes sense.

Thanks,
Adit

Pete

unread,
Aug 9, 2017, 1:19:18 PM8/9/17
to QuPath users
You should be able to access the 'ImageServer' from within the 'ImageData', and request the path from that.

So, for example, this should work:

print getCurrentImageData().getServer().getPath()

Adit Sanghvi

unread,
Aug 9, 2017, 3:31:15 PM8/9/17
to QuPath users
Wow thank you for being so responsive!! It works
Reply all
Reply to author
Forward
0 new messages