End-to-end MEA data analysis for Axion Biosystems instruments
Project description
py-mea-axion
End-to-end analysis of multi-electrode array (MEA) recordings from Axion Biosystems instruments, in Python.
py-mea-axion reads raw .spk binary files and carries the analysis
through spike metrics, burst detection, network burst detection, and
synchrony measurement — all the way to statistical comparisons and
publication-ready figures.
Installation
Recommended: new conda environment
conda create -n mea python=3.11
conda activate mea
pip install py-mea-axion
Or into an existing environment
pip install py-mea-axion
For development (editable install from a local clone)
git clone https://github.com/Molecularbiologyworld/py-mea-axion.git
cd py-mea-axion
pip install -e .
Requirements: Python ≥ 3.10, numpy, scipy, pandas, matplotlib, pingouin, statsmodels.
Quickstart
Command-line interface
The fastest way to get results without writing any Python:
# Quick per-well summary printed to the terminal
mea-axion summary recording.spk --fs-override 12500
# Full pipeline — writes CSVs + figures to results/
mea-axion run recording.spk --out results/ --fs-override 12500
# With a plate map (adds condition labels to outputs)
mea-axion run recording.spk --metadata plate_map.csv --out results/ --fs-override 12500
# Only CSVs, skip figure generation
mea-axion run recording.spk --out results/ --no-figures --fs-override 12500
# Restrict to specific wells
mea-axion summary recording.spk --wells A1 B1 C1 --fs-override 12500
# Analyse only a time window (300-600 s)
mea-axion run recording.spk --time-start 300 --time-end 600 --out results/ --fs-override 12500
Run mea-axion --help or mea-axion run --help for the full option list.
Python API
from py_mea_axion import MEAExperiment
exp = MEAExperiment(
"recording.spk",
metadata="plate_map.csv", # optional: well_id, condition, DIV, replicate_id
fs_override=12500,
time_start_s=300.0, # optional: crop to a time window before analysis
time_end_s=600.0,
active_threshold_hz=5/60, # 5 spikes/min, matching NeuralMetric Tools default
).run()
# Tabular results
exp.spike_metrics # per-electrode: MFR, ISI stats, active flag
exp.burst_table # per-burst: start/end time, duration, spike count
exp.well_summary # per-well: n_active, mean MFR, burst rate, STTC
exp.excluded_wells # wells dropped for having too few active electrodes
# One-liner export
exp.to_csv("results.csv") # well_summary merged with metadata
# Statistics
res = exp.compare("mean_mfr_active_hz") # Mann-Whitney / Kruskal-Wallis
coef = exp.longitudinal("mean_mfr_active_hz") # mixed-effects model
# Figures
exp.plot_heatmap("A1") # electrode MFR heatmap
exp.plot_raster("A1") # spike raster + burst overlays
exp.plot_sttc("A1") # pairwise STTC matrix
exp.plot_network_timeline("A1") # network burst Gantt chart
exp.plot_trajectory("mean_mfr_active_hz") # longitudinal mean ± SEM
Plate-map CSV format
well_id,condition,DIV,replicate_id
A1,WT,14,rep1
A2,KD,14,rep1
B1,WT,14,rep2
B2,KD,14,rep2
Key parameters
Burst detection (burst_kwargs)
| Parameter | Default | Description |
|---|---|---|
algorithm |
isi_threshold |
Detection algorithm |
max_isi_s |
0.1 s | Maximum within-burst ISI |
min_spikes |
5 | Minimum spikes per burst |
min_ibi_s |
0.0 s | Minimum inter-burst interval (0 = no merging) |
Network burst detection (network_kwargs)
| Parameter | Default | Description |
|---|---|---|
algorithm |
combined_isi |
Merges all electrode spike trains, matches NeuralMetric Tools |
max_isi_s |
0.1 s | Maximum within-network-burst ISI |
min_spikes |
50 | Minimum spikes in combined train |
participation_threshold |
0.35 | Minimum fraction of electrodes that must fire |
Pass these via burst_kwargs / network_kwargs in MEAExperiment.
Analysis window
Use time_start_s / time_end_s in the Python API or
--time-start / --time-end in the CLI to analyse only a sub-window of
the recording. Spikes outside the window are excluded before metrics,
burst detection, network detection, and STTC are computed. Internally,
the retained timestamps are shifted so that the analysis window starts at
t=0.
Note on Axion .spk files
Some recordings lack a BlockVectorHeader (common with certain firmware versions).
In this case the sampling frequency is inferred automatically; a warning is printed.
If the inferred frequency is wrong, override it explicitly:
exp = MEAExperiment("recording.spk", fs_override=12500)
mea-axion run recording.spk --fs-override 12500
Running the tests
pip install -e ".[dev]"
pytest
397 tests covering all modules.
Citing
If you use py-mea-axion in your research, please cite:
[manuscript in preparation]
License
MIT — see LICENSE.
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
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 py_mea_axion-0.2.0.tar.gz.
File metadata
- Download URL: py_mea_axion-0.2.0.tar.gz
- Upload date:
- Size: 79.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a43ec80f2c19fe1e86af84c5e3039a5c79873156521f00f93b1d1431493af7f4
|
|
| MD5 |
3e228638c345fc0bb584c54fa86a6e2f
|
|
| BLAKE2b-256 |
186f7acc7b29d7418a610ea5fd47705e479a73e7666429c2a28e55a593b22070
|
File details
Details for the file py_mea_axion-0.2.0-py3-none-any.whl.
File metadata
- Download URL: py_mea_axion-0.2.0-py3-none-any.whl
- Upload date:
- Size: 61.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8eed2a2d9e81a2fb2454e46ab8ca33398867af8408cffc326517f0b2124932c0
|
|
| MD5 |
8470f8870c473cd76fd4a8339e17ea92
|
|
| BLAKE2b-256 |
b95af34e78f270a35d4159691cd86b3571de6c1b2ccdcaaa67ad05031065e7ab
|