pyKrait
End-to-end pipeline for segmenting cells, detecting calcium peaks,
and quantifying oscillation periodicity and spatial synchronicity
from time-lapse microscopy.
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:
- Load — lazy
Daskarray viabioio(.czi,.tif,.tiff). - Project — STD or SUM projection across time, with optional CLAHE.
- Segment — Cellpose (
cpsamby default, or a custom model path). - Extract — per-cell mean intensity per frame, computed lazily on Dask.
- Detrend — Blackman-windowed sinc filter (cf. pyBOAT).
- Detect peaks —
scipy.signal.find_peakswith width / height / prominence thresholds. - Periodicity — STD and CoV of inter-peak intervals, scored against a shuffled-peaks null.
- Adjacency — neighbour graph from segmented masks (kernel-based proximity).
- 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:
Metadata
Release files for pykrait 0.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pykrait-0.3.3.tar.gz | 116.2 kB | Without provenance | Details for pykrait-0.3.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pykrait-0.3.3-py3-none-any.whl | Python 3 | none | any | Details for pykrait-0.3.3-py3-none-any.whl |
Total release size: 237.4 kB
Release files / pykrait-0.3.3.tar.gz
| Download URL | pykrait-0.3.3.tar.gz |
|---|---|
| Size | 116.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2305dfb3b36e21ca0bca8d3a459d1d76b32af1b18e66a188a04adc1ec3312d6e
|
|
BLAKE2b-256 checksum How to use checksums |
f560cdd463de2ec71ab418176ad4d5dfdee801f4e61a42831ff12c36d4ef7b8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Release files / pykrait-0.3.3-py3-none-any.whl
| Download URL | pykrait-0.3.3-py3-none-any.whl |
|---|---|
| Size | 121.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bfd900e8a376dde55773407d0434c89ee314d5d15a5a1cc810bf3af5b7982460
|
|
BLAKE2b-256 checksum How to use checksums |
0f9f406e66a15f7719fe2dfc0748c8d9739666b9b54a2fee328c4d6e16b2e7e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Security for pykrait 0.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.