Skip to main content

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

Note: the package is not yet on PyPI. Install directly from GitHub.

Recommended: new conda environment

conda create -n mea python=3.11
conda activate mea
pip install git+https://github.com/Molecularbiologyworld/py-mea-axion.git

Or into an existing environment

pip install git+https://github.com/Molecularbiologyworld/py-mea-axion.git

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

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,
    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.


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]

DOI


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

py_mea_axion-0.1.0.tar.gz (74.3 kB view details)

Uploaded Source

Built Distribution

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

py_mea_axion-0.1.0-py3-none-any.whl (55.5 kB view details)

Uploaded Python 3

File details

Details for the file py_mea_axion-0.1.0.tar.gz.

File metadata

  • Download URL: py_mea_axion-0.1.0.tar.gz
  • Upload date:
  • Size: 74.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for py_mea_axion-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f861ee57391e3b2001a1d81e37930ddd8442e7b5147188b165e39ad512769a04
MD5 1fc981f18b262c95077e5f2e88a05e87
BLAKE2b-256 41661c6a0081475447b62288e225c2a0454c2bea8147be959158451fe0a2c307

See more details on using hashes here.

File details

Details for the file py_mea_axion-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_mea_axion-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 55.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for py_mea_axion-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4eefc5bef8a7708c1fc34788eefbf0bd8bf54594b1ce2586b0b24177eb68b81
MD5 d3b36b8aee670aefdc265c95dc888d7a
BLAKE2b-256 70f248b6daa597beb1a8a4e2666c0dc2d1ed869c82f06a2e2643290178dfde69

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