spotiflow

Accurate and efficient spot detection for microscopy data

https://github.com/weigertlab/spotiflow

Science Score: 57.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 9 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.1%) to scientific vocabulary

Scientific Fields

Artificial Intelligence and Machine Learning Computer Science - 60% confidence
Last synced: 4 months ago · JSON representation ·

Repository

Accurate and efficient spot detection for microscopy data

Basic Info
Statistics
  • Stars: 95
  • Watchers: 4
  • Forks: 12
  • Open Issues: 6
  • Releases: 22
Created almost 2 years ago · Last pushed 5 months ago
Metadata Files
Readme License Citation Codeowners

README.md

License: BSD-3 PyPI Python Version tests PyPI - Downloads

Logo

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.

Overview

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.12):

console conda create -n spotiflow python=3.12 conda activate spotiflow

Then install PyTorch using pip:

console 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:

console pip install spotiflow

Installation (conda)

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

console 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 (2D images)

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

console 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.

Training (3D volumes)

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

console 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:

console 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 (Docker)

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

To pull the Docker container from Dockerhub use: console docker pull weigertlab/spotiflow:main

Then, run spotiflow-predict with: console docker run -it -v [/local/input/folder]:/spotiflow/input weigertlab/spotiflow:main spotiflow-predict input/your_file.tif -o . Where:
-v: represents the volume flag, which allows you to mount a folder from your local machine to the container.
/path/to/your/data:/spotiflow: is the path to the folder containing the image you want to analyze.

Note: - The current implementation of Spotiflow in Docker only supports CPU inference.

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.

```python from spotiflow.model import Spotiflow from spotiflow.sampledata import testimagehybiss2d

Load sample image

img = testimagehybiss_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. ```

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.

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, 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: console git clone git@github.com:weigertlab/spotiflow.git

Then install the testing extras:

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

then run the tests:

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

Docs

Install the docs extras:

console pip install -e ".[docs]"

and then cd into the docs folder of the cloned repository and build them: console 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:

bibtex @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}, }

Owner

  • Name: weigertlab
  • Login: weigertlab
  • Kind: organization

Citation (CITATION.cff)

cff-version: 1.2.0
message: If you use this software, please cite both the article from preferred-citation and the software itself.
authors:
  - family-names: Dominguez Mantes
    given-names: Albert
  - family-names: Herrera
    given-names: Antonio
  - family-names: Khven
    given-names: Irina
  - family-names: Schlaeppi
    given-names: Anjalie
  - family-names: Kyriacou
    given-names: Eftychia
  - family-names: Tsissios
    given-names: Georgios
  - family-names: Skoufa
    given-names: Evangelia
  - family-names: Santangeli
    given-names: Luca
  - family-names: Buglakova
    given-names: Elena
  - family-names: Durmus
    given-names: Emine Berna
  - family-names: Manley
    given-names: Suliana
  - family-names: Kreshuk
    given-names: Anna
  - family-names: Arendt
    given-names: Detlev
  - family-names: Aztekin
    given-names: Can
  - family-names: Lingner
    given-names: Joachim
  - family-names: La Manno
    given-names: Gioele
  - family-names: Weigert
    given-names: Martin
title: 'Spotiflow: accurate and efficient spot detection for fluorescence microscopy with deep stereographic flow regression'
version: 1.0.0
url: https://doi.org/10.1038/s41592-025-02662-x
doi: 10.1038/s41592-025-02662-x
date-released: 2025-06-06
preferred-citation:
  authors:
    - family-names: Dominguez Mantes
      given-names: Albert
    - family-names: Herrera
      given-names: Antonio
    - family-names: Khven
      given-names: Irina
    - family-names: Schlaeppi
      given-names: Anjalie
    - family-names: Kyriacou
      given-names: Eftychia
    - family-names: Tsissios
      given-names: Georgios
    - family-names: Skoufa
      given-names: Evangelia
    - family-names: Santangeli
      given-names: Luca
    - family-names: Buglakova
      given-names: Elena
    - family-names: Durmus
      given-names: Emine Berna
    - family-names: Manley
      given-names: Suliana
    - family-names: Kreshuk
      given-names: Anna
    - family-names: Arendt
      given-names: Detlev
    - family-names: Aztekin
      given-names: Can
    - family-names: Lingner
      given-names: Joachim
    - family-names: La Manno
      given-names: Gioele
    - family-names: Weigert
      given-names: Martin
  title: 'Spotiflow: accurate and efficient spot detection for fluorescence microscopy with deep stereographic flow regression'
  type: article
  doi: 10.1038/s41592-025-02662-x
  url: https://doi.org/10.1038/s41592-025-02662-x
  journal: Nature Methods
  year: 2025

GitHub Events

Total
  • Create event: 12
  • Issues event: 23
  • Release event: 11
  • Watch event: 32
  • Delete event: 8
  • Issue comment event: 51
  • Push event: 63
  • Pull request review event: 4
  • Pull request review comment event: 2
  • Pull request event: 8
  • Fork event: 4
Last Year
  • Create event: 12
  • Issues event: 23
  • Release event: 11
  • Watch event: 32
  • Delete event: 8
  • Issue comment event: 51
  • Push event: 63
  • Pull request review event: 4
  • Pull request review comment event: 2
  • Pull request event: 8
  • Fork event: 4

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 10
  • Total pull requests: 4
  • Average time to close issues: 11 days
  • Average time to close pull requests: 12 days
  • Total issue authors: 8
  • Total pull request authors: 3
  • Average comments per issue: 1.8
  • Average comments per pull request: 0.75
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 10
  • Pull requests: 4
  • Average time to close issues: 11 days
  • Average time to close pull requests: 12 days
  • Issue authors: 8
  • Pull request authors: 3
  • Average comments per issue: 1.8
  • Average comments per pull request: 0.75
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ajinkya-kulkarni (4)
  • migueLib (3)
  • BioinfoTongLI (2)
  • Hugo-Blanc (2)
  • ElpadoCan (2)
  • JoOkuma (2)
  • JB-Git-15 (1)
  • psobolewskiPhD (1)
  • AntoineB210 (1)
  • Yiijee (1)
  • SebastienTs (1)
  • bbrence (1)
  • anwai98 (1)
  • qin-yu (1)
  • chengarthur (1)
Pull Request Authors
  • ajinkya-kulkarni (5)
  • maweigert (3)
  • qin-yu (2)
  • Buglakova (1)
  • migueLib (1)
  • anwai98 (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 1,386 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 0
  • Total versions: 22
  • Total maintainers: 2
pypi.org: spotiflow

Accurate and efficient spot detection for microscopy data

  • Versions: 22
  • Dependent Packages: 1
  • Dependent Repositories: 0
  • Downloads: 1,386 Last month
Rankings
Dependent packages count: 10.1%
Average: 38.5%
Dependent repos count: 66.8%
Maintainers (2)
Last synced: 4 months ago

Dependencies

.github/workflows/cibuildwheel.yml actions
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/docs.yaml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
  • peaceiris/actions-gh-pages v3 composite
pyproject.toml pypi
setup.py pypi