Compress your first LFP recording
You need Python ≥ 3.10 and a raw Neuropixels LFP binary (.lf.cbin or .lf.bin) with its .meta file.
1. Install
uv add lfpack # or: pip install lfpack2. Compress
from lfpack import compress_bin_to_h5
compress_bin_to_h5("my_recording.lf.cbin", "my_recording.lf.h5")This runs the pipeline: saturation and bad-channel detection, filtering, decimation to 250 Hz and the codec. A 60 min 384-channel NP1 recording gives a file of about 20 MB. Cadzow denoising is on by default, as IBL does it; pass cadzow=False to skip it. Pass cadzow_checkpoint_file= to keep the decimated 250 Hz array: re-running with another alpha then skips straight to the codec.
3. Read
from lfpack import LFPackReader
sr = LFPackReader("my_recording.lf.h5")
print(sr.ns / sr.fs, sr.nc, sr.fs) # duration (s), channels, 250 Hz
traces = sr[0 : int(4 * sr.fs)] # first 4 s, (1000, nc) float32, volts
print(sr.geometry["y"]) # channel depths (µm)LFPackReader behaves like spikeglx.Reader: slicing decodes only the chunks it needs.
4. Look at it
viewephys -f my_recording.lf.h5viewephys opens lfpack files natively.
Next
- Read lfpack files: multi-recording files and binned reads
- Write your own file: compress data that is not a SpikeGLX binary