This repo adds some support to use Spotiflow within QuPath through a Python virtual environment.
Warning
This extension is developed for QuPath 0.6.x
Please cite this extension by linking it to this GitHub or to the release you used, and feel free to give us a star ⭐️
As this code is neither novel nor entirely original, there is no linked publication, but you can use the following Zenodo entry:
Author: Rémy Dornier (1)
Contributors: Albert Dominguez Mantes (2), Olivier Burri (1), Nicolas Chiaruttini (1), Romain Guiet (1)
This code heavily mirrors functions and design implemented in QuPath Cellpose.
Affiliations
(1) EPFL BioImaging and Optics Platform (BIOP) (2) EPFL Weigert Lab
Dominguez Mantes, A., Herrera, A., Khven, I., Schlaeppi, A., Kyriacou, E., Tsissios, G., Skoufa, E., Santangeli, L., Buglakova, E., Berna Durmus, E., Manley, S., Kreshuk, A., Arendt, D., Aztekin, C., Lingner, J., La Manno, G., Weigert, M. Spotiflow: accurate and efficient spot detection for fluorescence microscopy with deep stereographic flow regression. bioRxiv 2024.02.01.578426. https://doi.org/10.1101/2024.02.01.578426
Bankhead, P. et al. QuPath: Open source software for digital pathology image analysis. Scientific Reports (2017). https://doi.org/10.1038/s41598-017-17204-5
You will need a Python virtual environment with Spotiflow working.
Please follow the instructions to install Spotiflow from the main Spotiflow repository.
This extension will then need to know the path (the location in your file system) to (at least) your Spotiflow environment. You will need to enter this information in the QuPath Preferences when configuring the QuPath Spotiflow extension.
Important
Make sure you activate your Spotiflow environment and then check the path!
For example, if you installed spotiflow
into a conda environment named spotiflow-biop
then you can get the path
to the Python executable using the command line or terminal using the following two commands to activate the conda environment
and locate the Python binary (the 3rd line is example output).
On Windows:
> mamba activate spotiflow-biop
> where python
F:\conda-envs\spotiflow-biop\python.exe
On macOS or Linux:
> mamba activate spotiflow-biop
> which python
{HOME}/conda/envs/spotiflow-biop/bin/python
where {HOME}
will be the location of your home directory, typically /Users/user-name/
on macOS or /home/user-name/
on Linux.
- Install and setup the qupath-biop-catalog first.
- Open the Extension Manager
- Follow steps described in the official documention to browse and install/update the latest version of QuPath Spotiflow extension from the QuPath BIOP catalog.
Note
If your extensions directory is unset, create a new empty folder somewhere on your computer. On QuPath, go under Edit -> Preferences -> Extensions
and browse the empty folder you've just created.
Extensions will then be added inside this folder.
- You might then need to restart QuPath (but not your computer).
Download the latest qupath-extension-spotiflow-[version].jar
file from releases and copy it into your extensions directory.
If your extensions directory is unset, drag & drop qupath-extension-spotiflow-[version].jar
onto the main QuPath window.
You'll be prompted to select a QuPath user directory. The extension will then be copied to a location inside that directory.
You finally need to restart QuPath.
Go to Edit > Preferences > Spotiflow
Complete the fields with the requested information by pasting the path(s) you obtained above.
Based on the mamba
installation above, this is what it should look like on Windows:
Note
Unless stated otherwise, this extension should work with the latest releases of both Spotiflow. If this is not the case, please open an issue on our GitHub or write a post on the Image.sc forum detailing the problem and the steps necessary to reproduce it.
Spotiflow needs to download the pretrained models the first time it is run. On some OSes, this does not work from within QuPath due to permission issues.
One trick is to run Spotiflow from the command line once with the model you want to use. The download should work from there, and you can then use it within the QuPath Extension Spotiflow.
spotiflow-predict path/to/your/image
or, to download a specific model, different from the general
one
spotiflow-predict path/to/your/image --pretrained-model hybiss
Running Spotiflow is done via a script and is very similar to the excellent QuPath Cellpose Extension
You can find a template in QuPath in
Extensions > Spotiflow > Spotiflow detection template
Or you can download the Spotiflow_detection_template.groovy script from this repo and open it in the QuPath script editor.
Important
Lines starting with //
are commented out and are not used. To enable those parameters, delete the //
. To disable a parameter, add //
at the start of the line.
Some exmaples as provided in the announcement forum post
All builder options that are implemented are documented in the Javadoc.
You can pass additional options to spotiflow
by adding .addParameter()
before the .build()
line.
To get the available additional arguments, call the help from the spotiflow
object using spotiflow.helpPredict()
def spotiflow = Spotiflow.builder()...build()
spotiflow.helpPredict()
To use a custom model or your own trained model, provide the path to the directory containing the model to the Spotiflow.builder
using .setModelDir()
def pathModel = 'C:/spotiflow-custom-models/my-nice-spotiflow-model'
def spotiflow = Spotiflow.builder()
.setModelDir(new File(pathModel))
To use a pre-trained model, different from the default one (general
), provide the name of this model to the Spotiflow.builder
using .setPretrainedModelName()
def pretrainedModel = 'hybiss'
def spotiflow = Spotiflow.builder()
.setPretrainedModelName(pretrainedModel)
You can build the QuPath Spotiflow extension from source with
gradlew clean build
The output will be under build/libs
.
clean
removes anything oldbuild
builds the QuPath extension as a .jar file and adds it tolibs