Skip to main content

Accurate and efficient spot detection for microscopy data

Project description

License: BSD-3 PyPI Python Version PyPI Downloads tests


Spotiflow - accurate and efficient spot detection with stereographic flow

Spotiflow is a deep learning-based, threshold-agnostic, subpixel-accurate 2D and 3D spot detection method for fluorescence microscopy. It is primarily developed for spatial transcriptomics workflows that require transcript detection in large, multiplexed FISH-images, although it can also be used to detect spot-like structures in general fluorescence microscopy images and volumes. A more detailed description of the method can be found in the publication and the preprint.

The documentation of the software can be found here.

Installation (pip, recommended)

Create and activate a fresh conda environment (we currently support Python 3.9 to 3.14):

conda create -n spotiflow python=3.12
conda activate spotiflow

Then install PyTorch using pip:

pip install torch

Note (for Linux/Windows users with a CUDA-capable GPU): one might need to change the torch installation command depending on the CUDA version. Please refer to the PyTorch website for more information.

Note (for Windows users): if using Windows, please install the latest Build Tools for Visual Studio (make sure to select the C++ build tools during installation) before proceeding to install Spotiflow.

Finally, install spotiflow:

pip install spotiflow

Installation (conda)

For Linux/MacOS users, you can also install Spotiflow using conda through the conda-forge channel:

conda install -c conda-forge spotiflow

Note that the conda-forge Spotiflow version might be outdated w.r.t. the version in pip. We recommend using pip to install Spotiflow if available.

Usage

Training

The CLI is the easiest way to train (or fine-tune) a model. To train a model, you can use the following command:

spotiflow-train INPUT_DIR -o OUTPUT_DIR

where INPUT_DIR is the path to the directory containing the data in the format described here and OUTPUT_DIR is the directory where the trained model will be saved. You can also pass other parameters to the training, such as the number of epochs, the learning rate, etc. For more information, including examples, please refer to the training documentation or run the command spotiflow-train --help.

For training with the API, please check the training example notebook. For finetuning an already pretrained model, please refer to the finetuning example notebook.

3D models

3D models can also be trained with the CLI by adding the --is-3d True flag, as shown below:

spotiflow-train INPUT_DIR -o OUTPUT_DIR --3d True

See the example 3D training script for an API example. For more information, please refer to the 3D training example notebook. Fine-tuning a 3D model can be done by following the same workflow as to the 2D case.

Inference (CLI)

You can use the CLI to run inference on an image or folder containing several images. To do that, you can use the following command:

spotiflow-predict PATH

where PATH can be either an image or a folder. By default, the command will use the general pretrained model. You can specify a different model by using the --pretrained-model flag. Moreover, spots are saved to a subfolder spotiflow_results created inside the input folder (this can be changed with the --out-dir flag). For more information, please refer to the help message of the CLI ($ spotiflow-predict -h).

Inference (API)

The API allows detecting spots in a new image in a few lines of code! Please check the corresponding example notebook and the documentation for a more in-depth explanation. The same procedure can be followed for 3D volumes.

from spotiflow.model import Spotiflow
from spotiflow.sample_data import test_image_hybiss_2d

# Load sample image
img = test_image_hybiss_2d()
# Or any other image
# img = tifffile.imread("myimage.tif")

# Load a pretrained model
model = Spotiflow.from_pretrained("general")
# Or load your own trained model from folder
# model = Spotiflow.from_folder("./mymodel")

# Predict
points, details = model.predict(img) # points contains the coordinates of the detected spots, the attributes 'heatmap' and 'flow' of `details` contain the predicted full resolution heatmap and the prediction of the stereographic flow respectively (access them by `details.heatmap` or `details.flow`). Retrieved spot intensities are found in `details.intens`.

Inference (Docker)

Alternatively to installing Spotiflow as a command line tool on your operating system, you can also use it directly from a Docker container (thanks to @migueLib for the contribution!). To do so, you should:

  1. Pull the Docker container from Dockerhub:
docker pull weigertlab/spotiflow:main
  1. Run spotiflow-predict in the container with:
docker run -it -v [/local/input/folder]:/spotiflow/input weigertlab/spotiflow:main spotiflow-predict input/your_file.tif -o .

Where -v is the volume flag, which allows you to mount a folder from your local machine to the container. [/local/input/folder] should be the path to the folder containing the image(s) you want to analyze.

Note that the current implementation of Spotiflow in Docker only supports CPU inference.

Napari plugin

Our napari plugin allows detecting spots in 2D and 3D directly with an easy-to-use UI. See napari-spotiflow for more information.

QuPath extension

Rémy Dornier and colleagues at the BIOP built an extension to run Spotiflow (prediction only) in QuPath. Please check their repository for documentation and installation instructions.

Fiji/TrackMate

Jean-Yves Tinevez integrated Spotiflow in the v8 release of TrackMate! To use it you must install Spotiflow in a conda environment as described above, and then follow these instructions to configure TrackMate to use that conda environment.

Available pre-trained models

We provide several pre-trained models that may be used out-of-the-box. The available models are: general, hybiss, synth_complex, fluo_live, synth_3d and smfish_3d. For more information on these pre-trained models, please refer to the article and the documentation.

Changing the cache directory

The default cache directory root folder (where pre-trained models and datasets are stored) is, by default, ~/.spotiflow. If you want to change it for your use case, you can either set the environment variable SPOTIFLOW_CACHE_DIR to the path you want or directly pass the desired folder as an argument (cache_dir) to the Spotiflow.from_pretrained() method (note that if the latter is chosen, the path stored in the environment variable will be ignored).

Starfish integration

Spotiflow can be seamlessly integrated in existing Starfish pipelines using our spotiflow.starfish.SpotiflowDetector as a spot detection method instead of the BlobDetection classes shipped with Starfish, requiring minimal code changes apart from the addition of Spotiflow to the existing environment where Starfish is installed. For an example, please refer to the provided script.

For developers

We are open to contributions, and we indeed very much encourage them! Make sure that existing tests pass before submitting a PR, as well as adding new tests/updating the documentation accordingly for new features.

Testing

First, clone the repository:

git clone git@github.com:weigertlab/spotiflow.git

Then install the testing extras:

cd spotiflow
pip install -e ".[testing]"

then run the tests:

pytest -v --color=yes --cov=spotiflow

Docs

Install the docs extras:

pip install -e ".[docs]"

and then cd into the docs folder of the cloned repository and build them:

cd spotiflow/docs
sphinx-build -M html source build

How to cite

If you use this code in your research, please cite the Spotiflow publication:

@article{dominguezmantes25,
    title = {Spotiflow: accurate and efficient spot detection for fluorescence microscopy with deep stereographic flow regression},
    author = {Dominguez Mantes, Albert and Herrera, Antonio and Khven, Irina and Schlaeppi, Anjalie and Kyriacou, Eftychia and Tsissios, Georgios and Skoufa, Evangelia and Santangeli, Luca and Buglakova, Elena and Durmus, Emine Berna and Manley, Suliana and Kreshuk, Anna and Arendt, Detlev and Aztekin, Can and Lingner, Joachim and La Manno, Gioele and Weigert, Martin},
    year = {2025},
    journal = {Nature Methods},
    isbn = {1548-7105},
    doi = {10.1038/s41592-025-02662-x},
    url = {https://doi.org/10.1038/s41592-025-02662-x},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spotiflow-0.6.5.tar.gz (8.8 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

spotiflow-0.6.5-cp314-cp314-win_amd64.whl (3.9 MB view details)

Uploaded CPython 3.14Windows x86-64

spotiflow-0.6.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

spotiflow-0.6.5-cp314-cp314-macosx_12_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.14macOS 12.0+ ARM64

spotiflow-0.6.5-cp313-cp313-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.13Windows x86-64

spotiflow-0.6.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

spotiflow-0.6.5-cp313-cp313-macosx_12_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.13macOS 12.0+ ARM64

spotiflow-0.6.5-cp312-cp312-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.12Windows x86-64

spotiflow-0.6.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

spotiflow-0.6.5-cp312-cp312-macosx_12_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.12macOS 12.0+ ARM64

spotiflow-0.6.5-cp311-cp311-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.11Windows x86-64

spotiflow-0.6.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

spotiflow-0.6.5-cp311-cp311-macosx_12_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.11macOS 12.0+ ARM64

spotiflow-0.6.5-cp310-cp310-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.10Windows x86-64

spotiflow-0.6.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

spotiflow-0.6.5-cp310-cp310-macosx_12_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.10macOS 12.0+ ARM64

spotiflow-0.6.5-cp39-cp39-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.9Windows x86-64

spotiflow-0.6.5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

spotiflow-0.6.5-cp39-cp39-macosx_12_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.9macOS 12.0+ ARM64

File details

Details for the file spotiflow-0.6.5.tar.gz.

File metadata

  • Download URL: spotiflow-0.6.5.tar.gz
  • Upload date:
  • Size: 8.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spotiflow-0.6.5.tar.gz
Algorithm Hash digest
SHA256 0e4a3a07c6fda64929824b53858ddc81dbd80f0f313844191515b7b3cdf621b2
MD5 c66661534e22de30eb2b4cf62caf0dd1
BLAKE2b-256 0ef8218b007cd50814956d8cbdbdd9162b4076f3aa2471006bb854f76b42dda7

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: spotiflow-0.6.5-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 3.9 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spotiflow-0.6.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 d0611d1a6a38c06d8a26769103cc8a2bdb2c6b0d1be79e671aad31b0317c0860
MD5 1db03a0ec2f99a69a1663087bb2ebd50
BLAKE2b-256 835844d7c4cb836566a406dfcde96d92aab911d89ed9fb512d7d56cfae62fc5c

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for spotiflow-0.6.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 18a33b75f06b5ffc12391651225878047b3cac364661d45c59d67cb1180fcbfc
MD5 fd83810b999713db2939c8941a731eac
BLAKE2b-256 20acd54119590673811d0a02e3528375ffa5348d0e1b60a4e116f46e8deb941f

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp314-cp314-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for spotiflow-0.6.5-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 c879f48a29ec883d71f6dabaa0d062d52c4ca7707744481eb34db8723aa9523a
MD5 d87f991301108a6797fd5ef842ffdf0b
BLAKE2b-256 257ddd754284d46fcc29da3b40b61e61c489e6df8e64de3eb765651414234df7

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: spotiflow-0.6.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spotiflow-0.6.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0badad1233dac4f206d7d402de680767f140e27215f79e0eed7cf1ad1056adfe
MD5 f0135b5b4c28ec20f1f462af572d322a
BLAKE2b-256 2b1307cce6bb41196ca6435e75e11a44442a9181a1708f36ccbf660589adbc0a

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for spotiflow-0.6.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7f56b1e30fed02ff97424ae6feac03ea40f008b635fd028999188b2025238bfb
MD5 ab047f65b986d8075666f60c45a0f93f
BLAKE2b-256 82375b4c44055dc287357ae1d3518a3486a8a5644e3f58c399453f0251d1b009

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp313-cp313-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for spotiflow-0.6.5-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 7f7166284740467df036ae6fe8bbe57f4cff8084f8efb83d1a970accccc1d550
MD5 21492fd58ee8e8e36b0be4d7ec321981
BLAKE2b-256 c1605f654f60c8da6146dc38a294cfdf3401ed74d8e1cde424a991cab639a300

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: spotiflow-0.6.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spotiflow-0.6.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9cc1b6ce0b206e3c46c941439d642bb3572d6b710a6497b1a305882fc06a7fbe
MD5 98bd985867e03c9e31c2775ee007bfe3
BLAKE2b-256 7243ff6de70c6fa4c24a27369c216893afeea613b0b4c5e3e265c3f1d63e45a9

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for spotiflow-0.6.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0cd5dc907767bb075ef9ecebf8716cfc68ea98d9f864fc405b8667c73253585d
MD5 8afc928e46f90bbfe22ddc2a41e2abb1
BLAKE2b-256 2e79761877899bf27956561487484ee2ee44bc7fe99018c6b0e8ce1513568561

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp312-cp312-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for spotiflow-0.6.5-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 35af910a26bb390c59e093eb76ce69063bbb20efef7742ddaf75cb5509f4b12b
MD5 0f7d494b48afda434fe21410cb27de61
BLAKE2b-256 03d0baad0c4e5a3e0b8733c679dec41227414d3debfb383be1b68e85ba31f5ac

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: spotiflow-0.6.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spotiflow-0.6.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 33537a340f389ec4315a6f14851927f9bc29321fb13241be6fd35bc4671870f9
MD5 4e3f14a46b4a030292044c13f84cea99
BLAKE2b-256 289c46f8df6b06f8ba7d337aa7dee6c4ced7af9fbdbe5ed6d9bc6ad6170b8f92

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for spotiflow-0.6.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d43c2ffaf35050b1842265cdbc83a7da5cdc335f7837c053e0685ce51ad513ae
MD5 cfb774cbf1253aadf60bb33d4452c8e1
BLAKE2b-256 cafdba8f33eb758b08ff718fbbdc6246fbb44157d37e460bd3fa72d0d32f39a0

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp311-cp311-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for spotiflow-0.6.5-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 d57e44dd7c6b14788e61ee8f88291575fa09ece6bf5931a49d0da25cf4c04d5c
MD5 54254bdacce9aca49a9210f72cb0d12d
BLAKE2b-256 8c2290d4e3d7d37fb026b0623e4c7a6e3af9b73bb3bde3ee70f5fb5d1ee5ce91

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: spotiflow-0.6.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spotiflow-0.6.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6a223dd58e9a328dc4b697ac14961177ecb85fbc040840416b9e130c3fcf13b8
MD5 de119c72705ee432651404b396d580a2
BLAKE2b-256 06494b7e4572b4696016787ff6286ca90f9f03c81bf872ca441d5bc9be5f7db1

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for spotiflow-0.6.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 62a386b77b4717543a6c0f4c351d9fbd7bab6b1aa56c864dd5266c0a3552e8db
MD5 1c283fe98d362dfb841875c1608bd3be
BLAKE2b-256 c0d5f844aeb1bfa5dc7b55a410bf047e2e13722fc5bcf38c909ea3c654cc71b3

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp310-cp310-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for spotiflow-0.6.5-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 f8654ede10130fcda45bac62e0dab2fe690f50244b8f82beb3313000c60eb298
MD5 745bb3a22041aeed863d77259744e180
BLAKE2b-256 436e82077936fb02e4a704f133624ecfe8a3688ae8a835827fa7613f60dcd1bd

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: spotiflow-0.6.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spotiflow-0.6.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 09aa828843f47aa647e12072da049b00ffaf6e08100b1154d4d370fba51d419f
MD5 10cd7ffb73c59ff653e6c5c7f25c1ee7
BLAKE2b-256 c7909decc73cb1295741b603ad3b1337b6726c2510930addd2c0f8e8763ef3d3

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for spotiflow-0.6.5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2b955f18cc2ade56f65326a192c03b0f61aaf3cd60bc48a19e604c0191262b6d
MD5 8885b35a29e9a22e0a63440f47fdb40c
BLAKE2b-256 d37fa4f7a8633df56604f6d533ff451bc38bf7c71d5e87f79360c93924a27742

See more details on using hashes here.

File details

Details for the file spotiflow-0.6.5-cp39-cp39-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for spotiflow-0.6.5-cp39-cp39-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 683ed6f69334d63fc646e959da0598dbeb74b1eb83a73d0488ec23a5a1c94cc8
MD5 0224bb31afb6d9c58785ea2bfc4d2697
BLAKE2b-256 54b36bebdb2eb46bc1f0629bc2602fa5620b41734a76e89bb8adc37b3f67256f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page