Hi all! This is something I have been struggling with for a little while, and I suspect it is due to my lack of familiarity with how software in different environments is supposed to interact. I am hoping I am missing something obvious, or the answer is “you can’t get there from here.”
Goal: Use a command line function that works in an Anaconda virtual environment (to run CellPose on a batch of images) within QuPath/Groovy (Windows10).
TLDR: QuPath scripts can call Python scripts, but I am unable to run a command line function in an Anaconda virtual environment from within a QuPath script. And maybe I shouldn’t be?
What I can do:
Call general Python scripts using the Windows command line from QuPath, as seen here:
How to call python script from Groovy and the python script in turn calls another python script - #6 by Mike_Nelson
The scripts work, and I have one that can copy a file from one location to another; that works and can output text results to the QuPath log.
Run CellPose and batch process files with a command line like the following:
python -m cellpose --dir J:/CellPoseProcess/Treated/ --pretrained_model cyto --use_gpu --cellprob_threshold -4.0 flow_threshold 1.4 --diameter 17.9 --chan 0 --save_png --no_npy
This works within an Anaconda prompt while in the correct (with CellPose installed) virtual environment.
Less important, but my current workflow is:
Load base images into a QuPath project.
QP Script: Export images in a format that can be read by CellPose.
Target that folder with the command listed above in (2).
QP Script2: Import results of CellPose mask into QuPath as detections.
Being able call the that command line and adjust the variables within it would nicely condense everything into a single script that people could use to get CellPose results into QuPath.
I tried to set up CellPose in Python 3.7 rather than Anaconda according to the information here from @oburri
Which was very helpful in terms of getting the Anaconda environment to work, since I had massive problems with getting mxnet to work. I might be able to revisit that if it turns out CellPose within an Anaconda venv is problematic.
Appreciate any suggestions, and can, of course, add more info as requested, I just wanted to keep the initial posting short enough to not scare everyone off The end goal is a single script in QuPath that creates CellPose detections, but it might be that I have my environments set up in such a way that it cannot be done currently.
Example of CellPose results in QuPath: