Skip to content

Repository files navigation

LFP Analysis of the DLPFC during Working Memory Period After Checkboard Onset in Macaque Monkeys

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


What this repo does

  1. Loads trial event times from CFDeventStruct.mat (NI DAQ clock, ~20 kHz).
  2. Synchronizes NI time to Neuropixels LFP time via shared sync pulses.
  3. Extracts per-trial LFP windows around CheckerboardDrawnTime (or other events).
  4. Plots single-trial and averaged traces for quick QC.

Core library: neuraldynamics/lfp_export.py
Runnable example: notebooks/aligner.py


Repository layout

.
├── 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

Quick start

0. Prerequisites

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"))
savepath

Also, be sure to have both target_filename and chk_filename h5 files computed beforehand.

1. Clone and install

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 shell

Or 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 docs

2. Add session data

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

3. Run the aligner

cd notebooks
python aligner.py

Expected output:

  • Console summary: trial count, channel list, sync parameters
  • Plot saved to data/processed/aligner_lfp_plot.png

4. Read the documentation

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

Option C — GitHub Pages (after publishing):

https://YOUR_ORG.github.io/cfd-dlpfc-lfp-analysis/


Configuration

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

Exporting H5 files

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.


Data policy

  • In git: code, docs, small config files
  • Not in git: .lf.bin, .nidq.bin, .mat session 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

Relationship to CFD_DLPFC-main

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-main

License

Same as the parent CFD_DLPFC project. Update this section when you publish the repo.

About

Analysis of LF bands in Macaque Monkeys during Working Memory

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages