visiomode-analysis
Analysis library and CLI for behavioural session data recorded with Visiomode, a visuomotor behaviour platform for rodents.
Features
- Session summaries: quickly summarise session stats, including signal detection theory metrics.
- HTML reports: standalone, self-contained session reports with embedded Plotly figures.
- GLM regressors: event regressors (stimulus/response/reward windows) aligned to an external timestamp series, such as imaging frame timestamps or electrophysiology acquisition rates.
- Subject-level and cohort-level analysis: combine per-session trial summaries into a single per-subject summary CSV, as well as group-level analysis across subjects.
Installation
Requires Python 3.11+.
pip install visiomode-analysis
Or, to install the latest unreleased code from main:
pip install git+https://github.com/DuguidLab/visiomode_analysis.git
For local development, this project uses uv to manage the virtual environment:
git clone https://github.com/DuguidLab/visiomode_analysis.git
cd visiomode_analysis
uv sync
This creates a .venv with the package and its dependencies installed in editable mode.
Usage
CLI
The package installs a visiomode-analysis command with four subcommands: session, regressors, subject, and group.
Process a single session — generates an HTML report and a trials CSV:
visiomode-analysis session path/to/sub-01_exp-myexperiment_ses-20260101_behaviour-gonogo.json -o output/
Skip the HTML report, or generate GLM regressors alongside it, with:
visiomode-analysis session path/to/session.json -o output/ --no-report
visiomode-analysis session path/to/session.json -o output/ --with-regressors --regressor-timestamps frame_times.csv
Generate regressors for an already-processed session, aligned to an external timestamp series:
visiomode-analysis regressors path/to/session.json -o output/ --regressor-timestamps frame_times.csv
Collate a subject's sessions — combines every *trials.csv file in a directory (as produced by session) into one subject-level summary CSV:
visiomode-analysis subject path/to/subject_dir/ -o output/
Run visiomode-analysis --help or visiomode-analysis <command> --help for full option details.
Python API
The CLI is a thin wrapper around the visiomode_analysis.session module, which can also be used directly:
from visiomode_analysis import session
trials = session.get_trials("path/to/session.json")
metadata = session.get_metadata("path/to/session.json")
summary = session.summary(trials)
session.generate_report(trials, metadata, output_dir="output/")
Input files and naming convention
Session JSON filenames are expected to follow a BIDS-like pattern:
sub-<animal_id>_exp-<experiment>_ses-<YYYYMMDD>_behaviour-<protocol>.json
Metadata encoded in the filename takes precedence over the same fields in the JSON body. Output files (trials CSV, report HTML, regressors .npz, subject summary CSV) are named following the same convention, so downstream steps — e.g. subject globbing for *trials.csv — can find their inputs automatically.
Project structure
src/visiomode_analysis/
├── __init__.py # top-level Click CLI group, wires up subcommands
├── session/ # Session-level statistics
│ ├── __init__.py # JSON → trials DataFrame, metadata, summaries, report/regressor generation
│ ├── metrics.py # signal-detection-theory statistics
│ ├── plots.py # Plotly figure builders
│ └── regressor.py # per-protocol GLM regressor construction
├── subject/ # collates per-session trials.csv files into a subject summary
│ └── __init__.py
├── group/ # cohort-level aggregation across subjects (not implemented yet)
│ └── __init__.py
└── reports/ # Jinja2 templates for HTML session reports
├── __init__.py
└── templates/
├── base.html
└── session.html
Development
# Run the full test suite with coverage
hatch test --cover
# Type checking
hatch run types:check
See CONTRIBUTING.md for the issue workflow, and CHANGELOG.md for release notes.
License
MIT — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file visiomode_analysis-0.1.0.tar.gz.
File metadata
- Download URL: visiomode_analysis-0.1.0.tar.gz
- Upload date:
- Size: 431.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10f9aab704c57c01389da4b11ca6fa4367328d34b9e8b79d05df19aefc97ea9b
|
|
| MD5 |
05e5f429d633e05732f164ca186c9519
|
|
| BLAKE2b-256 |
866216564484dac0ca86fce58ef9bf68bc6c8960426800f0fdc9f7b54e9ef65a
|
Provenance
The following attestation bundles were made for visiomode_analysis-0.1.0.tar.gz:
Publisher:
python-publish.yml on DuguidLab/visiomode_analysis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
visiomode_analysis-0.1.0.tar.gz -
Subject digest:
10f9aab704c57c01389da4b11ca6fa4367328d34b9e8b79d05df19aefc97ea9b - Sigstore transparency entry: 2422229217
- Sigstore integration time:
-
Permalink:
DuguidLab/visiomode_analysis@986254bcd5213202414a0c77b66951a330c41c96 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/DuguidLab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@986254bcd5213202414a0c77b66951a330c41c96 -
Trigger Event:
push
-
Statement type:
File details
Details for the file visiomode_analysis-0.1.0-py3-none-any.whl.
File metadata
- Download URL: visiomode_analysis-0.1.0-py3-none-any.whl
- Upload date:
- Size: 28.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9b3c4da3b22f946a7904e26a12d938f2d17eea96a03d6fb244673177ce89e4a
|
|
| MD5 |
b18af57dba0d98f78f62ad050576cd30
|
|
| BLAKE2b-256 |
6893dc911f323ef8e1e367d7723c4d86fce3949d8a2c88860ee808f7b8574d61
|
Provenance
The following attestation bundles were made for visiomode_analysis-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on DuguidLab/visiomode_analysis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
visiomode_analysis-0.1.0-py3-none-any.whl -
Subject digest:
c9b3c4da3b22f946a7904e26a12d938f2d17eea96a03d6fb244673177ce89e4a - Sigstore transparency entry: 2422229313
- Sigstore integration time:
-
Permalink:
DuguidLab/visiomode_analysis@986254bcd5213202414a0c77b66951a330c41c96 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/DuguidLab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@986254bcd5213202414a0c77b66951a330c41c96 -
Trigger Event:
push
-
Statement type: