Skip to content

Commit

Permalink
Merge pull request #199 from RichieHakim/dev
Browse files Browse the repository at this point in the history
Update documentation to use MyST embedding
  • Loading branch information
RichieHakim authored Feb 24, 2024
2 parents 14c82d4 + 063a651 commit 74b6c14
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 202 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ version as the PyTorch CUDA version you choose. All CUDA 11.x versions are
intercompatible, so if you have CUDA 11.8 drivers, you can install
`torch==2.0.1+cu117`.

### **Solution 2:**
**Solution:**<br>
If you are sure you have a compatible GPU and correct drivers, you can force
install the GPU version of pytorch, see the pytorch installation instructions.
Links for the [latest version](https://pytorch.org/get-started/locally/) or
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ sphinx
# sphinx==7.2.6 sphinx_rtd_theme doesn't yet support sphinx 7
sphinx_rtd_theme==1.2.2
# furo==2023.9.10
myst_parser==2.0.0
roicat[all]
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def add_subdirs_to_sys_path(path):
'sphinx.ext.githubpages', # allows integration with github
'sphinx.ext.napoleon', # parsing of different docstring styles
'sphinx.ext.coverage', # allows coverage of docstrings
'myst_parser', # allows markdown parsing
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
71 changes: 4 additions & 67 deletions docs/source/howto.rst
Original file line number Diff line number Diff line change
@@ -1,70 +1,7 @@
How to use ROICaT
=================

Listed below, we have a suite of easy to run notebooks for running the ROICaT
pipelines.

* The **Google CoLab notebooks** can be run fully remotely without installing
anything on your computer.
* The **Jupyter notebooks** can be run locally on your computer and require you to
`install ROICaT
<https://roicat.readthedocs.io/en/latest/installation.html>`__.

.. image:: ../media/tracking_FOV_clusters_rich.gif
:align: right
:width: 300
:alt: ROICaT logo_1

**TRACKING:**
* `Interactive notebook <https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/tracking/tracking_interactive_notebook.ipynb>`__
* `Google CoLab <https://githubtocolab.com/RichieHakim/ROICaT/blob/main/notebooks/colab/tracking/tracking_interactive_notebook.ipynb>`__
* (TODO) `demo script <https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/tracking/tracking_scripted_notebook.ipynb>`__

|
.. image:: ../media/umap_with_labels.png
:align: right
:width: 200
:alt: ROICaT logo_1

**CLASSIFICATION:**
* `Interactive notebook - Drawing <https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/classification/classify_by_drawingSelection.ipynb>`__
* `Google CoLab - Drawing <https://githubtocolab.com/RichieHakim/ROICaT/blob/main/notebooks/colab/classification/classify_by_drawingSelection_colab.ipynb>`__
* `Interactive notebook - Labeling <https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/classification/labeling_interactive.ipynb>`__
* (TODO) `Interactive notebook - Train classifier <https://github.com/RichieHakim/ROICaT>`__
* (TODO) `Interactive notebook - Inference with classifier <https://github.com/RichieHakim/ROICaT>`__

|
**OTHER:**
* `Custom data importing notebook <https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/other/demo_data_importing.ipynb>`__
* Train a new ROInet model using the provided Jupyter Notebook [TODO: link].
* Use the API to integrate ROICaT functions into your own code: `Documentation <https://roicat.readthedocs.io/en/latest/roicat.html>`__.

How ROICaT pipelines work:
##########################

* **Pass ROIs through ROInet:** Images of the ROIs are passed through a
neural network which outputs a feature vector for each image describing what
the ROI looks like. These feature vectors are used in the next steps.
* **Classification:**
* A simple **classifier** can be trained using user supplied labeled data
(e.g. an array of images of ROIs and a corresponding array of labels for
each ROI).
* Alternatively, classification can be done by projecting the feature
vectors into a lower-dimensional space using UMAP and then simply
**drawing** a circle around the region of space to classify the ROIs.
* **Tracking**: The feature vectors can be combined with information about
the position of the ROIs to track the ROIs across imaging sessions/planes.


ROInet model data
#################

Below are links to the current ROInet models. These models are trained on data
from many labs from around the world. They take in images of ROIs and output a
feature vector describing each ROI. See documentation on the `ROInet_embedder
<https://roicat.readthedocs.io/en/latest/roicat.html#roicat.ROInet.ROInet_embedder>`__
for more information on how to use these models.

.. include:: ../helpers/ROInet_links.txt
.. include:: ../../README.md/
:start-after: # How to use ROICaT
:end-before: # Installation
:parser: myst_parser.sphinx_
10 changes: 6 additions & 4 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ROICaT
Region of Interest Classification and Tracking
##############################################

ROICaT is a simple-to-use Python package for classifying images of cells and tracking them across imaging sessions/planes.

`Github Repository <https://github.com/richiehakim/ROICaT>`_

.. image:: ../media/logo1.png
Expand All @@ -14,11 +16,10 @@ Region of Interest Classification and Tracking
|

ROICaT is a simple-to-use Python package for classifying images of cells and tracking them across imaging sessions/planes.

--------

Contents
--------
========

.. toctree::
:maxdepth: 1
Expand All @@ -32,10 +33,11 @@ Contents
roicat


--------

Indices and tables
------------------
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

.. _github: https://github.com/RichieHakim/ROICaT
25 changes: 24 additions & 1 deletion docs/source/inputsAndOutputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Inputs
can be facilitated through a custom data importing notebook found `here
<https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/other/demo_data_importing.ipynb>`_.

-------

Outputs
#######

Expand Down Expand Up @@ -38,12 +40,33 @@ ROIs
- **idx_roi_session:** Session-wise ROI indices.
- **n_sessions:** Number of sessions.

-------

Applying labels to Data
~~~~~~~~~~~~~~~~~~~~~~~

You can use the output labels to align any data with the same indexing as the
ROIs like time series (calcium traces). ROICaT provides a set of functions to
help with this. The term **"UCID" (Unique Cluster ID)** is used to
refer to the cluster labels. All functions are within the :ref:`roicat.util
<roicat-util-module>` module.

- ``roicat.util.match_arrays_with_ucids``: Align data using UCIDs. This function
will align data arrays (e.g., calcium traces) using the UCIDs.
- ``roicat.util.mask_UCIDs_with_iscell``: Update UCIDs based on an ``iscell``
array (provided by Suite2p or ROICaT classification). This function will set
the UCID of any ROI with ``iscell==0`` to -1.
- ``roicat.util.discard_UCIDs_with_fewer_matches``: Discard UCIDs with fewer
than a specified number of matches.

-------

Quality Control
~~~~~~~~~~~~~~~

Typically, little post-hoc curation is needed. However, defining inclusion
criteria is useful for quality control. Below is a section from `Nguyen et al.
(Nature 2023) <https://www.google.com>`_ that describes the inclusion criteria
(Nature 2023) <https://www.nature.com/articles/s41586-023-06810-1>`_ that describes the inclusion criteria
used in their study:

.. admonition:: Nguyen et al. (2023)
Expand Down
138 changes: 9 additions & 129 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
@@ -1,136 +1,16 @@
Installation
============

ROICaT has been tested on Windows 10 & 11, MacOS, and Linux.

Requirements
############

- Segmented data. For example Suite2p output data (stat.npy and ops.npy files),
CaImAn output data (results.h5 files), or any other type of data using this
`custom data importing notebook
<https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/other/demo_custom_data_importing.ipynb>`__.
- `Anaconda <https://www.anaconda.com/distribution/>`__ or `Miniconda
<https://docs.conda.io/en/latest/miniconda.html>`__.
- If using Windows: `Microsoft C++ Build Tools
<https://visualstudio.microsoft.com/visual-cpp-build-tools/>`__
- If using linux/unix: GCC >= 5.4.0, ideally == 9.2.0. Google how to do this on
your operating system. Check with: ``gcc --version``.
- **Optional:** `CUDA compatible NVIDIA GPU
<https://developer.nvidia.com/cuda-gpus>`__ and `drivers
<https://developer.nvidia.com/cuda-toolkit-archive>`__. Using a GPU can
increase ROICaT speeds ~5-50x, though without it, ROICaT will still run
reasonably quick. GPU support is not available for Macs.
- The below commands should be run in the terminal (Mac/Linux) or Anaconda
Prompt (Windows).


Installation
############


1. **Recommended: Create a new conda environment**

.. literalinclude:: ../helpers/create_env.txt

You will need to activate the environment with ``conda activate roicat`` each
time you want to use ROICaT.

2. **Install ROICaT**

.. literalinclude:: ../helpers/pip_install.txt

Note: if you are using a zsh terminal, add quotes around the pip install
command, i.e. ``pip install "roicat[all]"``

3. **Clone the repo to get the scripts and notebooks**

.. literalinclude:: ../helpers/clone_repo.txt

.. include:: ../../README.md/
:start-after: # Installation
:end-before: # Troubleshooting Installation
:parser: myst_parser.sphinx_


Troubleshooting Installation
############################

Windows installation
---------------------

If you receive the error:
``ERROR: Could not build wheels for hdbscan, which is required to install pyproject.toml-based projects``
on Windows, make sure that you have installed Microsoft C++ Build Tools.
If not, download from
`here <https://visualstudio.microsoft.com/visual-cpp-build-tools/>`__
and run the commands:

::

cd path/to/vs_buildtools.exe
vs_buildtools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools

Then, try proceeding with the installation by rerunning the pip install
commands above.
(`reference <https://stackoverflow.com/questions/64261546/how-to-solve-error-microsoft-visual-c-14-0-or-greater-is-required-when-inst>`__)


GPU support
-----------

GPU support is not required. Windows users will often need to manually
install a CUDA version of pytorch (see below). Note that you can check
your nvidia driver version using the shell command: ``nvidia-smi`` if
you have drivers installed.

Use the following command to check your PyTorch version and if it is GPU
enabled:

::

python -c “import torch, torchvision; print(f’Using versions:
torch=={torch.\__version\_\_},
torchvision=={torchvision.\__version\_\_}‘);
print(f’torch.cuda.is_available() = {torch.cuda.is_available()}’)”


**Outcome 1:** Output expected if GPU is enabled:

::

Using versions: torch==X.X.X+cuXXX, torchvision==X.X.X+cuXXX
torch.cuda.is_available() = True

This is the ideal outcome. You are using a CUDA version of PyTorch and
your GPU is enabled.

**Outcome 2:** Output expected if non-CUDA version of PyTorch is
installed:

::

Using versions: torch==X.X.X, torchvision==X.X.X
OR
Using versions: torch==X.X.X+cpu, torchvision==X.X.X+cpu
torch.cuda.is_available() = False

If a non-CUDA version of PyTorch is installed, please follow the
instructions here: https://pytorch.org/get-started/locally/ to install a
CUDA version. If you are using a GPU, make sure you have a `CUDA
compatible NVIDIA GPU <https://developer.nvidia.com/cuda-gpus>`__ and
`drivers <https://developer.nvidia.com/cuda-toolkit-archive>`__ that
match the same version as the PyTorch CUDA version you choose. All CUDA
11.x versions are intercompatible, so if you have CUDA 11.8 drivers, you
can install ``torch==2.0.1+cu117``.

**Outcome 3:** Output expected if GPU is not available:

::

Using versions: torch==X.X.X+cuXXX, torchvision==X.X.X+cuXXX
torch.cuda.is_available() = False
============================

If a CUDA version of PyTorch is installed but GPU is not available, make
sure you have a `CUDA compatible NVIDIA
GPU <https://developer.nvidia.com/cuda-gpus>`__ and
`drivers <https://developer.nvidia.com/cuda-toolkit-archive>`__ that
match the same version as the PyTorch CUDA version you choose. All CUDA
11.x versions are intercompatible, so if you have CUDA 11.8 drivers, you
can install ``torch==2.0.1+cu117``.
.. include:: ../../README.md/
:start-after: # Troubleshooting Installation
:end-before: # TODO
:parser: myst_parser.sphinx_
3 changes: 3 additions & 0 deletions docs/source/roicat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ roicat.helpers module
:undoc-members:
:show-inheritance:


.. _roicat-util-module:

roicat.util module
------------------

Expand Down

0 comments on commit 74b6c14

Please sign in to comment.