From 070bcc2edf5f075f1446491b90f0c821f728007f Mon Sep 17 00:00:00 2001 From: AlbertDominguez Date: Tue, 8 Oct 2024 10:43:53 +0200 Subject: [PATCH] update docs --- docs/source/cli.rst | 23 ++++++----------------- docs/source/index.rst | 38 +++++++++++++++++++++++++------------- docs/source/train.rst | 3 ++- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/docs/source/cli.rst b/docs/source/cli.rst index e342612..c47e7df 100644 --- a/docs/source/cli.rst +++ b/docs/source/cli.rst @@ -1,23 +1,12 @@ Inference via CLI ----------------- -You can use the CLI to run inference on an image or folder containing several images. +Command Line Interface (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 -To do that, simply use the following command: +.. code-block:: console -.. code-block:: + $ spotiflow predict --input PATH - 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 or the `-\-model-dir` flag for a model you trained yourself. - -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: - -.. code-block:: - - spotiflow-predict -h +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``). diff --git a/docs/source/index.rst b/docs/source/index.rst index 4165221..210ee65 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -4,7 +4,7 @@ Spotiflow ========= -Spotiflow is a learning-based spot detection method for fluorescence microscopy images. For more information, please refer to our `paper `__. +Spotiflow is a learning-based subpixel-accurate spot detection method for 2D and 3D 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. For more information, please refer to our `paper `__. Getting Started --------------- @@ -13,36 +13,36 @@ Installation ~~~~~~~~~~~~ -First, create and activate a new conda environment. +First, create and activate a fresh ``conda`` environment (we currently support Python 3.9 to 3.12). If you don't have ``conda`` installed, we recommend using `miniforge `__. .. code-block:: console - (base) $ conda create -n spotiflow python=3.9 - (base) $ conda activate spotiflow + $ conda create -n spotiflow python=3.12 + $ conda activate spotiflow +**Note (for MacOS users):** if using MacOS, there is a known bug causing the installation of PyTorch with conda to sometimes break OpenMP. You can avoid installing PyTorch with ``conda`` and let install it automatically via pip instead. Then, install Pytorch using ``conda``/ ``mamba``. Please follow the `official instructions for your system `__. -As an example, for MacOS: +As an example, for a Linux system with CUDA (note that you should change the CUDA version to match the one installed on your system): .. code-block:: console - (spotiflow) $ conda install pytorch::pytorch torchvision -c pytorch + $ conda install pytorch torchvision pytorch-cuda=12.1 -c pytorch -c nvidia -For a linux system with CUDA (note that you should change the CUDA version to match the one installed on your system): - -.. code-block:: console - - (spotiflow) $ conda install pytorch torchvision pytorch-cuda=11.8 -c pytorch -c nvidia +**Note (for Windows users):** if using Windows, 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`` using ``pip``: .. code-block:: console - (spotiflow) $ pip install spotiflow + $ pip install spotiflow Predicting spots in an image ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Python API +^^^^^^^^^^ + The snippet below shows how to retrieve the spots from an image using one of the pretrained models: .. code-block:: python @@ -73,8 +73,20 @@ If a custom model is used, simply change the model loadings step to: # Load a custom model model = Spotiflow.from_folder("/path/to/model") - +Command Line Interface (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 + +.. code-block:: console + + $ spotiflow predict --input 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``). + +Napari plugin +^^^^^^^^^^^^^ +Spotiflow also can be run easily in a graphical user interface as a `napari `__ plugin. See :ref:`napari:Predicting spots using the napari plugin` for more information. Contents -------- diff --git a/docs/source/train.rst b/docs/source/train.rst index cb81763..910b127 100644 --- a/docs/source/train.rst +++ b/docs/source/train.rst @@ -78,6 +78,7 @@ You can then load it by simply calling: In the 3D case, you should initialize a :py:mod:`spotiflow.model.config.SpotiflowModelConfig` object and pass it to the `Spotiflow` constructor with the appropriate parameter set (see other options for the configuration at the end of the section): .. code-block:: python + # Same imports as before from spotiflow.model import SpotiflowModelConfig @@ -117,7 +118,7 @@ You can also pass other parameters relevant for training to the `fit` method. Fo ) -In order to change the model architecture (`e.g.` number of input/output channels, number of layers, variance for the heatmap generation, etc.), you can create a :py:mod:`spotiflow.model.config.SpotiflowModelConfig` object and populate it accordingly. Then you can pass it to the `Spotiflow` constructor (note that this is necessary for 3D). For example, if our image is RGB and we need the network to use 3 input channels, we can do the following: +In order to change the model architecture (`e.g.` number of input channels, number of layers, variance for the heatmap generation, etc.), you can create a :py:mod:`spotiflow.model.config.SpotiflowModelConfig` object and populate it accordingly. Then you can pass it to the `Spotiflow` constructor (note that this is necessary for 3D). For example, if our image is RGB and we need the network to use 3 input channels, we can do the following: .. code-block:: python