Skip to main content

Python Calcium Recording Analysis and Interpretation Toolbox

Project description

pyKrait

pyKrait

PyPI Python versions CI Docs License

End-to-end pipeline for segmenting cells, detecting calcium peaks,
and quantifying oscillation periodicity and spatial synchronicity
from time-lapse microscopy.

Analysis Steps of the pykrait package

Overview

pyKrait (python Calcium recording analysis and interpretation toolbox) automatically processes calcium-imaging videos (.czi, .tif, .tiff) and computes calcium activity, peak statistics, periodicity scores, and neighbour-aware synchronicity z-scores.

Installation

It is recommended to install pyKrait in a virtual environment using either venv or uv. The graphical user interface is optional, install it with pip install "pykrait[gui]".

Standard venv

python -m venv .venv
source .venv/bin/activate           # Windows: .venv\Scripts\activate
pip install --upgrade pip
pip install pykrait

Using uv

uv venv --python 3.11
source .venv/bin/activate           # Windows: .venv\Scripts\activate
uv pip install pykrait

Quickstart

Launch the GUI

From inside the activated virtual environment:

python -m pykrait

The GUI walks you through video selection, segmentation, peak detection, periodicity, and synchronicity, and lets you save results to disk.

Batch process an entire folder

from pykrait.pipeline.pipeline import BatchExperiment, AnalysisParameters
from pykrait.io.files import concat_analysis_files

experiment = BatchExperiment(
    folder="/path/to/videos",
    params=AnalysisParameters(),
    extension=".czi",
)
experiment.run()

concat_analysis_files("/path/to/videos", filetype="output")

This produces one Analysis_<video>/ directory per video and an analysis_output_overview.csv at the root of the folder.

Examples

Scenario Notebook
Run a folder with custom parameters notebooks/example_batch_with_custom_parameters.ipynb
Re-run a folder reusing saved parameters and cached masks notebooks/example_batch_reusing_parameters.ipynb
Inspect or refine a single video interactively Launch the GUI: python -m pykrait

How it works

For each video, pyKrait runs the following stages:

  1. Load — lazy Dask array via bioio (.czi, .tif, .tiff).
  2. Project — STD or SUM projection across time, with optional CLAHE.
  3. Segment — Cellpose (cpsam by default, or a custom model path).
  4. Extract — per-cell mean intensity per frame, computed lazily on Dask.
  5. Detrend — Blackman-windowed sinc filter (cf. pyBOAT).
  6. Detect peaksscipy.signal.find_peaks with width / height / prominence thresholds.
  7. Periodicity — STD and CoV of inter-peak intervals, scored against a shuffled-peaks null.
  8. Adjacency — neighbour graph from segmented masks (kernel-based proximity).
  9. Synchronicity — co-firing peaks within a time window and topological distance, z-scored against label-shuffled controls.

Documentation

Full API reference and tutorials: https://pykrait.readthedocs.io/en/latest/.

Acknowledgements

pyKrait builds on and heavily uses prior open-source work:

  • Cellpose for cell segmentation
  • pyBOAT for the sinc-filter detrending approach
  • bioio for image I/O
  • Dask for lazy array computation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykrait-0.3.3.tar.gz (116.2 kB view details)

Uploaded Source

Built Distribution

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

pykrait-0.3.3-py3-none-any.whl (121.2 kB view details)

Uploaded Python 3

File details

Details for the file pykrait-0.3.3.tar.gz.

File metadata

  • Download URL: pykrait-0.3.3.tar.gz
  • Upload date:
  • Size: 116.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for pykrait-0.3.3.tar.gz
Algorithm Hash digest
SHA256 2305dfb3b36e21ca0bca8d3a459d1d76b32af1b18e66a188a04adc1ec3312d6e
MD5 6a2495de8e2c89f6c4641d0c2a6a1e03
BLAKE2b-256 f560cdd463de2ec71ab418176ad4d5dfdee801f4e61a42831ff12c36d4ef7b8c

See more details on using hashes here.

File details

Details for the file pykrait-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: pykrait-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 121.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for pykrait-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bfd900e8a376dde55773407d0434c89ee314d5d15a5a1cc810bf3af5b7982460
MD5 cee9453073ea3287ee4fdfebc5ba4dac
BLAKE2b-256 0f9f406e66a15f7719fe2dfc0748c8d9739666b9b54a2fee328c4d6e16b2e7e9

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