Welcome to NeuraLib’s documentation!

API Reference

Release Notes

Installation

Create and activate a new conda environment (Python>=3.10, but >=3.12 not yet tested), then install:

conda create -n neuralib python=3.10
conda activate neuralib
pip install neura-library

If you wish to install all dependencies, run:

pip install neura-library[all]

If you wish to install the minimal required dependencies according to usage purpose:

  • Choices: atlas, scanner, imaging, segmentation, model, gpu, imagelib, tools

  • Example of using atlas module:

pip install neura-library[atlas]

If install as developer mode (Install pre-commit and linter check by ruff):

pip install neura-library[dev]
pre-commit install
ruff check .

Note

The GPU-related modules are recommended to be installed separately. For example:

  • pip install tensorflow: Used in cascade spike prediction, stardist cellular segmentation

  • pip install torch: Used in cellpose cellular segmentation, facemap keypoint extraction

Warning

The command pip install neura-library[all] does NOT include segmentation, or gpu dependencies. These modules are mainly used for wrapper and contain:

  1. Old package dependencies (e.g., numpy < 2.0)

  2. Heavy packages (e.g., torch, tensorflow)

Recommended installation approach: Create a separate conda environment for the specific job, for example you need to run segmentation:

conda create -n neuralib_seg python=3.10
conda activate neuralib_seg
pip install neura-library[segmentation]

CLI project.scripts

neuralib_brainrender

  • See examples in api

neuralib_brainrender -h

neuralib_widefield

  • See example in api

neuralib_widefield -h

Notebook Demo

Modules

neuralib.atlas

neuralib.imaging

neuralib.segmentation

neuralib.locomotion

neuralib.model

neuralib.morpho

  • Morphological reconstruction data presentation

neuralib.tracking

Utilities Modules

neuralib.argp

  • Use argparse as dataclass field

neuralib.persistence

  • Caching the analyzed results (i.e., concatenation for statistic purpose)

neuralib.sqlp

  • Python functions to build a SQL (sqlite3) statement.

neuralib.dashboard

  • Interactive dashboard visualization

neuralib.plot

  • Module for general plotting purpose

neuralib.imglib

  • Image processing library

neuralib.io

  • File IO and example dataset

neuralib.tools.gspread

  • Google spreadsheet API wrapper for read/write

neuralib.tools.slack_bot

  • Real-time Slack notification bot for analysis pipeline

neuralib.util.color_logging

  • Logging with color format

neuralib.util.gpu

  • OS-dependent GPU info

neuralib.util.profile

  • Simple benchmark profile testing and debugging

neuralib.util.table

  • Rich table visualization

neuralib.util.segments

  • Epoch or value segments

Doc for Array type

  • Array[DType, [*Shape]]

  • DType = array datatype. Shape = array shape. | = Union

Example

  • int or bool with (N,3) array -> Array[int|bool, [N, 3]]

  • float array with union shape (N,2) or (N,T,2) -> Array[float, [N, 2]|[N, T, 2]]

Indices and tables