Accurate and efficient spot detection for microscopy data
Project description
Spotiflow - accurate and efficient spot detection with stereographic flow
Spotiflow is a deep learning-based, threshold-agnostic, and subpixel-accurate 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.
Installation
Create and activate a fresh conda environment (we currently support Python 3.9 to 3.11):
conda create -n spotiflow python=3.9
conda activate spotiflow
Then install PyTorch using conda/mamba (refer to the official installation instructions for more info depending on your system):
For MacOS:
conda install pytorch::pytorch torchvision -c pytorch # for MacOS
For Linux/Windows with a CUDA device (one might need to change the cuda version accordingly):
conda install pytorch torchvision pytorch-cuda=11.8 -c pytorch -c nvidia # Might need to change the cuda version accordingly
Note (only 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
Usage
Training
See the example training script or the example notebook for an example of training. For finetuning an already pretrained model, please refer to the finetuning example notebook.
Inference
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.
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", inference=True)
# Or load your own trained model from folder
# model = Spotiflow.from_folder("./mymodel", inference=True)
# Predict
points, details = model.predict(img) # points contains the coordinates of the detected spots, the attributes 'heatmap' and 'flow' of `details` contains the predicted full resolution heatmap and the prediction of the stereographic flow respectively (access them by `details.heatmap` or `details.flow`).
Napari plugin
Our napari plugin allows detecting spots directly with an easy-to-use UI. See napari-spotiflow for more information.
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 paper (currently preprint):
@inproceedings{dominguezmantes2024,
author = {},
title = {},
...
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for spotiflow-0.1.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d0ee097122895a7a3cf211a6fffe7fab8ca57fa9d17fb2b382760afcb54de0f |
|
MD5 | 1b60ac8af9a2d27a1dfd8f8d6032a2de |
|
BLAKE2b-256 | b228480889c90770f9ddf59b1b97828dd9e7c2e2daa66567731a218bc1135fd2 |
Hashes for spotiflow-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba41ae38a5235339bc32278ffca38e0f6182985d31c30c4a9fcda860fcfc1b6a |
|
MD5 | abd0e7df39e1bb20d0d180bc6817f5fc |
|
BLAKE2b-256 | 14af3393a9313be63e73c8d795b608f44db8af771547f2142a383519cbd8f190 |
Hashes for spotiflow-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce17144bd54eadef1c73e291cff99a8f6bf5749a9cb3d460e0d583b84ea7cf41 |
|
MD5 | 10d05fcb971b33874e67ff6099094bfc |
|
BLAKE2b-256 | 11e37d6ac5889ae2e19b33aa0bfbf551d6b9e783ef874803f7343f11c60ae378 |
Hashes for spotiflow-0.1.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71f2efda9218f8b0f833a048183924b3f32ed037c7377db1a6a4d78fcfc1b757 |
|
MD5 | 0d6a273f3bc6bae2b8c3a210c428c270 |
|
BLAKE2b-256 | 61ab147c47a4e3c23f10c403584f19dbd1c6f6af0113fb9d0d6ab76272b04a81 |
Hashes for spotiflow-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80f106fac7a88046cc2d82bb4d9fcd0df155ef25e07452a6f863d6854efed493 |
|
MD5 | 58a111dc560eec982a755ff2ac4273f0 |
|
BLAKE2b-256 | 0702b5e7cd5863ffdd9c638239315ba43ac22ed483371acedf772a5414e646cc |
Hashes for spotiflow-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5996bc91a6ad16c84eb57a6378700e070c0f25f2fcc1298ad791b053c95eff62 |
|
MD5 | d10b9bef272f5c105ef41b7998f119ca |
|
BLAKE2b-256 | aa54629bfd6fb31c22bd22ac5a317553a8d32b3b0a807cb1f704da809cedb227 |
Hashes for spotiflow-0.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e67ce4bde9e36c235392ab7120f9d22cf4c21e24e22513ba9e3d4ffc922a2368 |
|
MD5 | 17e7d213cd63b825cc0d38ef07befc7c |
|
BLAKE2b-256 | 6a98d17a269adebdb5652017fef3c19711ee8dafd778161f84afbfa68b358586 |
Hashes for spotiflow-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4df98685b168c4116355df464b2422e90092fc66137c7f3daed615a9c8c5f5a |
|
MD5 | 3c8c250787a7399ead572fa5c05629ab |
|
BLAKE2b-256 | 187852d68563ad33ad65fd187401f4aa8c4dddab2c63ed4ae8945cca4a967cbc |
Hashes for spotiflow-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce3e9947fdd3d433a53819e6bfea04f5cf6fb82d7e444f06155f09529207acd4 |
|
MD5 | 2a7cf9bb0fee5da93447359365377845 |
|
BLAKE2b-256 | 1ce65d422f91ea54f69fddbabf1ca5f6c69a5a2dee348f90c6d974661731f604 |