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.4.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.4-cp314-cp314-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.14Windows x86-64

spotiflow-0.6.4-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.4-cp314-cp314-macosx_12_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.14macOS 12.0+ ARM64

spotiflow-0.6.4-cp313-cp313-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.13Windows x86-64

spotiflow-0.6.4-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.4-cp313-cp313-macosx_12_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.13macOS 12.0+ ARM64

spotiflow-0.6.4-cp312-cp312-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.12Windows x86-64

spotiflow-0.6.4-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.4-cp312-cp312-macosx_12_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.12macOS 12.0+ ARM64

spotiflow-0.6.4-cp311-cp311-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.11Windows x86-64

spotiflow-0.6.4-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.4-cp311-cp311-macosx_12_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.11macOS 12.0+ ARM64

spotiflow-0.6.4-cp310-cp310-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.10Windows x86-64

spotiflow-0.6.4-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.4-cp310-cp310-macosx_12_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.10macOS 12.0+ ARM64

spotiflow-0.6.4-cp39-cp39-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.9Windows x86-64

spotiflow-0.6.4-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.4-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.4.tar.gz.

File metadata

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

File hashes

Hashes for spotiflow-0.6.4.tar.gz
Algorithm Hash digest
SHA256 801738431a7b7379faa93390aa630b8f5d3401529e59505f40d9015e1827a128
MD5 ee257698bf27ee05b12156d03454fb97
BLAKE2b-256 b6f8d0e14b955dca3b6e77d45208a9463d7f5c16d77e9831db0b6f96264d8388

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for spotiflow-0.6.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1764283651ad11f18927b8e7e9480ce0f47991479e7b3e10233067afbbeeaafd
MD5 b844a49eab0b95880d3536de839f8c45
BLAKE2b-256 25802b5060698b534fe44be0d739e4369647767fae0e275461d829ae62518eb2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotiflow-0.6.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1278a13e44963e4b4b1503f9d59178f3acbbe76369304178a9b4ef2e81c8d09d
MD5 daff1a9004c434249cfeb971502494fa
BLAKE2b-256 af3283bb027d413684255c0d4a2363e72a1a08474088aad00e45a744b8fd8897

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotiflow-0.6.4-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 7942f3e22a0d35c8bb089a636eec04ea61df8dff5b5d8dd0ea3e6e090dc1fb4a
MD5 2fb5b9dba72ee25ee9fcba572230b06b
BLAKE2b-256 4c85921c6028d6dd0688834d2756ae08bda75196341eb9a54dd9faa061b58169

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for spotiflow-0.6.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4aa849e9cac1d52aedca0da78d9d03ae6f47a1ece8b1dea3e1ce42b1cdac3040
MD5 d52d056737e4ae53459325e9c65900a3
BLAKE2b-256 b3065124fa63d65fe3107ef23995b3d4ff646dbb7548405e48555e606b261fa3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotiflow-0.6.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1cc95b1e17f12db10561571b0911388a3801dc3b4d588edb4f9745bd2317c6d2
MD5 75217f733b014f3a28178000212922e8
BLAKE2b-256 ab8efc1693bf38b0c963bb04ede5bcb55bc367170bed4e5f626bf94120a07a5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotiflow-0.6.4-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 9c222764c186b9a47e4e6911115ef348a6e4d98139c119d5bc7700f853c27e3a
MD5 cd9bee50d2af0be5e47073806f97431d
BLAKE2b-256 5744e3e1c0a2f0503048e636da263061701813b87ffcd85fe36376ebe7ff691f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for spotiflow-0.6.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 42f9f8e560f77ac307e3e5b98afd4d07208407b0a957d3152bb94ead25dc9a82
MD5 eb6db8e9b30b815964f2f2ba29bc5a67
BLAKE2b-256 4b9086821f50298f4bb67ca06fb9439c726b6f1fef7d627ee3ca6b713cbc117e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotiflow-0.6.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 05317b802e5b27e5e184154983e3f74c8c1f623231fd230bde7cac17ccc224da
MD5 a57f2040b2769db90a29106855c4fe87
BLAKE2b-256 017ba2732806ae2ffd28c1c64ded014a4e848db988d4407c3d19e0932c374469

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotiflow-0.6.4-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 dd5a54cd13fcc5d71d7f085b0569f52dd15a77f301d2dd30acdd1d5531a63ab5
MD5 c659bd4adbc369724e44540713966a9d
BLAKE2b-256 972c53952e11c71c1730ab36c3b946122ed67db37e0c406d4973c61ad0b46dec

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for spotiflow-0.6.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6a5bab56d7826cb56fbdea81820341d8977a98ae949415290a39b27fdd96c19e
MD5 0a5e58d9227ee3cb7930c95f1abbb645
BLAKE2b-256 cacb52acdf694982828be1c8faf547ccf2e2e5a9980032c03ab549f985879eb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotiflow-0.6.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5b22ac7c3bc1eb9d3a3ad42c810d30d5cc32c9bc5c5ab981908332a7f5d99e48
MD5 0d5b1074d63a7894e50f27b23f07e0ea
BLAKE2b-256 9edbaea6e5ee7ea1d76cf700bfd14c5b5dd9698096c73be9719bd7edc3df271b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotiflow-0.6.4-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 62a184981968c04cda1f451dc0d7953c4221695c87d203bbabc7ad1839ed74c4
MD5 abfe126257e7bf92511c5835ff99fd20
BLAKE2b-256 875e488b1bbd9ea13f52e800d6485bf5df9828002d24a1248e5c4c531f2f7c95

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for spotiflow-0.6.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f89a38add533d62b2587fcc41e775bdee3a905ff9573a51f5ca6d140933a4b0a
MD5 c6b32ab05f1221bdd96f9f1401271fa4
BLAKE2b-256 13d0740e5ddaa087eabc3eac25616d78eef113f68f8e1c67ea0530e3d22d2fdb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotiflow-0.6.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d67376780c61a241ff5b69438e8a7519b3133740f243e53b5a6fb2142adfb037
MD5 baf61d9620ed399af4477b5bd749d387
BLAKE2b-256 eb4830a89e4912b4bce8f2fb7a6d128057a67923cd434e593ce29625c4d3e513

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotiflow-0.6.4-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 d331c15cfadeb9c2b37d5042f73c073bdb36af0693a999803ab2b0378db8c24c
MD5 08b2104dd84b3b16caf07ac11ac56256
BLAKE2b-256 fbfbbbaa0e74ddd65b736c69a31c0415b461a14806d4e2edcbd8f11694a0a6c7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for spotiflow-0.6.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a935d1edfd34b68efeb111bf92f157535d265d11dd028cb46254a9565b847bec
MD5 777f4c3548032777f7a93b8b3fd19efc
BLAKE2b-256 7bdca30c2604964d98d580e8a5ef436e14ec46f2d8844a124dd5a1c00c1288a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotiflow-0.6.4-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ef81df9431ce4b3eb89e3ce90d05302672089c1873eb6203fbc8cc83079771b6
MD5 a42120052ea323092c536d542cfb2917
BLAKE2b-256 30802810262048342fb2f8afdc11b584e5030d04b229f5688ca24eef7b2ca9a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotiflow-0.6.4-cp39-cp39-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 33960fde4553ce4c2584872ea0c9b84ea63c6e33c9e0d19875dbb0e1182e4a0e
MD5 a1b7dde8cd88e089d308f0941790a072
BLAKE2b-256 2afa1bb1a7492cfd2a897e730292d5cef6666778436a0cd5e8b2c0fd66d88354

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