axonforge

A small Python toolkit for analysing extracellular electrophysiology recordings: threshold detection, waveform alignment, feature-based sorting, cluster quality metrics and interspike interval statistics.

axonforge is built for the situation most laboratories are actually in - 16 to 64 channels, recordings of minutes to an hour, stored as plain binary or HDF5, and an analysis that has to be explainable to a reviewer. Every default is written down on the methods page, every parameter is a keyword argument, and nothing is estimated behind your back.

It is not a replacement for the large sorting frameworks used on high-density probes with hundreds of channels. Those solve a harder problem - drift, dense spatial overlap, template matching - and they solve it better. What axonforge offers instead is a short, readable path from a file to a spike table you can defend line by line.

Minimal example#

Thirty-two channels of int16 at 30 kHz, from raw file to sorted units:

import axonforge as af

rec = af.io.read("session12.dat", fs=30_000, n_channels=32, dtype="int16")
rec = af.filt.common_median(rec)                  # reference across channels
rec = af.filt.bandpass(rec)                       # 300-6000 Hz, order 4

spikes = af.detect.threshold(rec, k=4.5, polarity="neg", dead_time_ms=1.0)
wf = af.waveform.extract(rec, spikes, pre_ms=0.5, post_ms=1.5)
wf = af.waveform.align(wf, mode="peak", interp=True)

feat  = af.sort.features(wf, n_components=3)
units = af.sort.cluster(feat, max_k=8, criterion="bic")

print(units.n_units)                              # 7
print(units.quality("isi_violations", refractory_ms=1.5))

The same sequence is available as a command, which is what most people use for a first look at a session:

axonforge detect session12.dat --fs 30000 --channels 32 \
    --bandpass 300:6000 --k 4.5 --out session12.afz
axonforge report session12.afz --raster --isi

The tutorial walks through this with the intermediate results shown at each step, including the raster plot it ends with.

What it does#

What it does not do#

Project facts

Version 0.7.2, released 24 September 2026. Python 3.10 to 3.13. Dependencies: NumPy and SciPy, plus h5py for HDF5 and zstandard for the container format. Pure Python with no compiled extensions. Licence: BSD 3-clause. Development started in June 2024.

Where to go next#