Emmett James Thompson
Scripts for processing data collected during electrophysiology (ephys) recordings for the 8-port sequence task.
- See our publication for more details: Replay of Procedural Experience is Independent of the Hippocampus.
This repository provides a pipeline for processing three main data streams:
- Electrophysiology (ephys)
- Behavioral data
- Video data
The workflow includes initial processing (scripts 1–5) and final alignment to create a synchronization file. The output is organized into a clean, structured directory.
This pipeline assumes data collected with the following setup:
- Neuropixels (1.0 or 2.0): Recorded using Open Ephys.
- Behavioral data: Collected with Bpod using the "Sequence Automated" protocol.
- Video data: Recorded using FLIR cameras positioned above and below the task/sleep arenas. Triggers sent via GPIO. Video (
.avi
) and timestamps (.csv
) saved through Bonsai. - Synchronization: TTL pulses (see TTL Alignment section).
The pipeline is organized into six sequential phases:
Processes raw ephys data (Open Ephys output) using the SpikeInterface framework and spike sorts the data with Kilosort 4.
Requirements:
- SpikeInterface
- Kilosort 4
- Note: GPU access is recommended for faster processing. See
HPC_helpsheet
for cluster computing tips.
- Note: GPU access is recommended for faster processing. See
Output:
- Organized file directories for each recording.
- Kilosort outputs (spike times) for each probe.
Processes video files (.avi
) and timestamps (.csv
) generated by Bonsai:
- Converts timestamps into seconds.
- Labels the three experimental phases of the videos using trigger times (see TTL Alignment).
- Automatically detects and labels camera views (back or top).
Output:
- Renamed and organized
.avi
files. - Copies of raw files in a dump folder for subsequent DeepLabCut tracking.
- Timestamp DataFrames for each video.
Generates tracking files for video data:
- Creates
.sh
shell scripts for DeepLabCut processing on a cluster. - These files reply on a ".py" file called dlc_on_hpc
- This file is located in "other_files" and needs to be moved to the same location as the ".sh" files which call it.
- Tracks behavioral ports and mouse head center.
Requirements:
- DeepLabCut
- See
HPC_helpsheet
for cluster usage guidance.
Output:
- Tracking files in the organized directory.
Processes raw .mat
files from Bpod into a Python-readable format. Update file paths before use.
Output:
- Processed behavioral data files in the organized directory.
Determines brain locations of Kilosorted units using:
- Spectral Analysis
- Analyzes ephys signals across the probe.
- Note: Multiple recordings across the probe length improve accuracy.
- Histology
- Perfuse and image the brain.
- Align sections to the Allen Brain Atlas using brainreg.
- Trace probe tracks with brainreg-segment.
Output:
- Spectral analysis results or histology-based probe tracks.
Aligns all datasets (ephys, behavior, video) to a common timeframe. Update file paths before running the script.
Output:
- Spike DataFrames with depth and brain region information.
- Synchronization files aligning behavior, ephys, and video data.
The Bpod behavioral controller serves as the central clock, sending TTL pulses to:
- Ephys (via niDAQ)
- Cameras (via GPIO)
During sleep, TTL pulses are sent every 30 seconds. During tasks, TTLs are triggered by the trial structure.
- Go high when a new trial starts.
- Stay high until the mouse initiates the sequence task (first correct port).
Ensure the following software is installed:
- Git
- Python 3.12.3
- Jupyter Notebook
- Python libraries (see
requirements.txt
).- Note: Some dependencies may be redundant or missing but should be easy to identify.
- Important: Use
moviepy
version1.0.3
. Newer versions (as of December 2024) are broken.
This repo and the documentation is not at all comprehensive and designed for my data structures. If you need further assistance or have questions about adaoting these scripts for your needs feel free to contact me