lfpack
Lossy LFP codec for Neuropixels recordings
lfpack compresses Neuropixels LFP into random-access HDF5 files of about 1.5 % of the decimated (250 Hz, float32) data, and reads them back through a drop-in replacement for spikeglx.Reader. The raw band is cleaned and decimated to 250 Hz and Cadzow-denoised (on by default), then every 8 s chunk is coded as an SVD whose spatial modes live in one shared basis per recording and whose temporal modes are thresholded wavelet packets.
pip install lfpackfrom lfpack import compress_bin_to_h5, LFPackReader
compress_bin_to_h5("recording.lf.cbin", "recording.lf.h5")
sr = LFPackReader("recording.lf.h5")
traces = sr[0:1000] # (1000, n_channels) float32, voltsChoosing α
α, the wavelet-packet threshold, is the only parameter that moves behaviour decoding (11 IBL NP1 recordings, ε = 100, shared basis of 32 vectors):
| α | file / 250 Hz float32 | SNR | wheel-speed R² below uncompressed (mean) |
|---|---|---|---|
| 14 | 0.82 % | 14.4 dB | 0.0054 |
| 7 (default) | 1.55 % | 18.5 dB | 0.0030 |
| 2.5 | 3.09 % | 23.4 dB | 0.0005 |
See the codec for how these were measured. The BWM release ships these three α as small, default and fine (dataset).
Documentation
| Tutorial | Compress and read your first recording |
| BWM LFP dataset | Access the IBL Brain-Wide Map LFP release |
| Read lfpack files | Recordings, scales, binned reads, format-1 files |
| Write your own file | Compress your own arrays, attach sync |
| Pipeline and codec | What each stage does and why |
| HDF5 format | On-disk layout |
| API | Function reference |