Standalone repository for aligning Neuropixels LFP recordings to behavioral task events in the CFD DLPFC project. This repo contains the minimum code and documentation needed to run aligner.py, export trial-aligned LFP, and inspect results.
Full documentation: open index.html in a browser, or read the Sphinx docs after building them (see below).
- Loads trial event times from
CFDeventStruct.mat(NI DAQ clock, ~20 kHz). - Synchronizes NI time to Neuropixels LFP time via shared sync pulses.
- Extracts per-trial LFP windows around
CheckerboardDrawnTime(or other events). - Plots single-trial and averaged traces for quick QC.
Core library: neuraldynamics/lfp_export.py
Runnable example: notebooks/aligner.py
.
├── index.html # Documentation landing page (start here)
├── README.md # This file
├── SETUP_FROM_PARENT.md # How this repo was split from CFD_DLPFC-main
├── pyproject.toml # Python dependencies (Poetry)
├── notebooks/
│ └── aligner.py # Main analysis script
├── neuraldynamics/ # LFP alignment library
│ ├── Constants.py
│ ├── lfp_export.py
│ ├── SGLXTools.py
│ └── ... # Package init dependencies
├── docs/ # Sphinx documentation source
│ ├── index.rst
│ ├── getting-started.rst
│ ├── lfp.rst
│ └── _build/html/ # Built HTML (after `make html`)
├── data/
│ ├── raw/LFP/ # Session binaries + events (not in git)
│ └── processed/ # Plots and exported H5 files
└── scripts/
└── bootstrap_from_parent.sh
Make sure that the latest release version of Chronux is downloaded to your desktop. Within build_spectrogram.m, add the path to the extract folder of Chronux to be able to compute spectrograms. Add the following to the very top of build_spectrogram.m.
addpath(genpath("PATH_TO_CHRONUX_FOLDER"))
savepathAlso, be sure to have both target_filename and chk_filename h5 files computed beforehand.
git clone https://github.com/YOUR_ORG/cfd-dlpfc-lfp-analysis.git
cd cfd-dlpfc-lfp-analysis
# Recommended: Python 3.10–3.11 with Poetry
poetry install
poetry shellOr with conda:
conda create -n lfp_analysis python=3.11 -y
conda activate lfp_analysis
pip install numpy scipy matplotlib h5py npyx==4.1.3
pip install sphinx sphinx-rtd-theme # optional, for docsPlace these files under data/raw/LFP/ (see getting-started for paths):
| File | Purpose |
|---|---|
20250325/CFDeventStruct.mat |
Behavioral event times |
BILBO_CHKDLAY_DLPFC_03252025_g0_t0.imec0.lf.bin |
Neuropixels LFP (~7.6 GB) |
BILBO_CHKDLAY_DLPFC_03252025_g0_t0.imec0.lf.meta |
LFP metadata |
other/BILBO_CHKDLAY_DLPFC_03252025_g0_t0.nidq.bin |
NI DAQ analog + sync |
other/BILBO_CHKDLAY_DLPFC_03252025_g0_t0.nidq.meta |
NI DAQ metadata |
aligner.py creates symlinks for the nidq files in data/raw/LFP/ automatically.
Large binaries should not be committed to git. Use DVC, S3, or a shared drive and document the source in your lab wiki.
cd notebooks
python aligner.pyExpected output:
- Console summary: trial count, channel list, sync parameters
- Plot saved to
data/processed/aligner_lfp_plot.png
Option A — landing page (no build):
Open index.html in your browser.
Option B — full Sphinx site:
cd docs
pip install sphinx sphinx-rtd-theme
make html
# Open docs/_build/html/index.htmlOption C — GitHub Pages (after publishing):
https://YOUR_ORG.github.io/cfd-dlpfc-lfp-analysis/
Edit the constants at the top of notebooks/aligner.py:
| Variable | Default | Meaning |
|---|---|---|
DATA_DIR |
data/raw/LFP |
SpikeGLX LFP folder |
EVENTS_PATH |
.../CFDeventStruct.mat |
Event file |
EVENT_NAME |
CheckerboardDrawnTime |
Alignment event |
PRE_TIME_S |
0.400 |
Seconds before event |
POST_TIME_S |
1.900 |
Seconds after event |
N_TEST_CHANNELS |
5 |
Channels to extract |
For binned trial tensors saved to disk, use the library directly:
from neuraldynamics.lfp_export import LFPExperiment, ALIGNMENT_PRESETS
exp = LFPExperiment(
data_dir="data/raw/LFP",
events_path="data/raw/LFP/20250325/CFDeventStruct.mat",
)
exp.compute_sync()
exp.save_experiment(
"data/processed/",
monkey_name="BILBO",
session_date="03252025",
**ALIGNMENT_PRESETS[0],
)See the LFP Alignment page for API details.
- In git: code, docs, small config files
- Not in git:
.lf.bin,.nidq.bin,.matsession files,data/processed/*.png,.NeuroPyxels/cache - Optional: track large files with DVC or Git LFS and add remote storage instructions to
docs/getting-started.rst
This repository is a focused subset of the full CFD_DLPFC project. It keeps only LFP alignment and analysis tooling. Spike sorting, Plexon readers, and broader experiment classes remain in the parent repo.
To refresh from the parent project:
./scripts/bootstrap_from_parent.sh /path/to/CFD_DLPFC-mainSame as the parent CFD_DLPFC project. Update this section when you publish the repo.