Skip to main content

A library for classifying and tracking ROIs.

Reason this release was yanked:

testing

Project description

Welcome to ROICaT

ROICaT

build PyPI version Downloads

Region Of Interest Classification and Tracking ᗢ

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

tracking_FOV_clusters_rich

Why use ROICaT?

  • ROICaT is capable of clasifying cells with near human accuracy when compared to human relabeling and can track cells with higher accuracy than other methods currently available. With minimal input data, ROICaT can classify and track cells with XX% accuracy. Additionally, the computational needs of ROICaT are minimal, requiring only a standard computer with 4 GB of RAM and a CPU.

With ROICaT, you can:

  • Classify ROIs into different categories (e.g. neurons, dendrites, glia, etc.).
  • Track ROIs across imaging sessions/planes.

What data types can ROICaT process?

  • ROICaT can accept many different two-photon imaging data formats including: Suite2p, CaImAn, CNMF, NWB, and more.

What are the minimum computing needs?

  • We recommend the following as a starting point:
    • 4 GB of RAM (more for large data sets e.g., ~32 Gb for 100K neurons)
    • GPU not required but will increase run speed.


How to use ROICaT

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.

TRACKING:

CLASSIFICATION:

OTHER:

General workflow:

  • 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.
  • Classification: The feature vectors can then be used to classify ROIs:
  • 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 circling 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.

Installation

ROICaT works on Windows, MacOS, and Linux. If you have any issues during the installation process, please make a github issue with the error.

0. 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.
  • Anaconda or Miniconda.
  • If using Windows: Microsoft C++ 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 and drivers. 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).

1. (Recommended) Create a new conda environment

conda create -n roicat python=3.11
conda activate roicat
pip install --upgrade pip

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

2. Install ROICaT

pip install --user roicat[all]
pip install git+https://github.com/RichieHakim/roiextractors

Note: if you are using a zsh terminal, change command to: pip3 install --user 'roicat[all]' For installing GPU support on Windows, see Troubleshooting below.

3. Clone the repo to get the scripts and notebooks

git clone https://github.com/RichieHakim/ROICaT

Troubleshooting Installation

Troubleshooting (Windows)

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 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)

Troubleshooting (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 and drivers 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 and drivers 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.

Solution: To force install the GPU version of pytorch, see the pytorch installation instructions here or use the conda command:

conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia

TODO:

  • Unify model training into this repo
  • Finish classification notebooks, port to colab, make scripts
  • Integration tests
  • make better reference API

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

roicat-1.1.14.tar.gz (166.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

roicat-1.1.14-py3-none-any.whl (162.3 kB view details)

Uploaded Python 3

File details

Details for the file roicat-1.1.14.tar.gz.

File metadata

  • Download URL: roicat-1.1.14.tar.gz
  • Upload date:
  • Size: 166.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for roicat-1.1.14.tar.gz
Algorithm Hash digest
SHA256 265766f55dbfbd8b11c11dcd81ff9e0971daa38dce828812565f95f78904a00f
MD5 9a398bf5d6a75d068d6737fe61bf40d3
BLAKE2b-256 203818498ed63196fb20e0bae56c17201d5e43e24379615b4aa6f09dc6cc7c57

See more details on using hashes here.

File details

Details for the file roicat-1.1.14-py3-none-any.whl.

File metadata

  • Download URL: roicat-1.1.14-py3-none-any.whl
  • Upload date:
  • Size: 162.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for roicat-1.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 0e9041374cef63fb977d16c18880f8668430805005c5d1e3cdf83d9e6a2a0624
MD5 fe588b5a1c4b761113d3ed834a35f998
BLAKE2b-256 b25a95852cb2ebedcbd4bbb5559f83a9f99cee078be859b081df530b3c0fc339

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