Decoding Hand Kinematics Using Extracellular Neural Recordings from Primary Motor and Dorsal Premotor Cortices in Macaques Performing a Sequential Reaching Task
This repository contains a complete, report-ready analysis pipeline for studying the distinct contributions of primary motor cortex (M1) and dorsal premotor cortex (PMd) during a continuous sequential reaching task.
The workflow is implemented in a cleaned and modular notebook at Project.ipynb and includes:
- Neural data preprocessing and smoothing.
- Planning-versus-execution directional tuning analysis.
- Population PSTH analysis (cue-aligned and movement-onset aligned).
- Continuous kinematic decoding with linear and recurrent models.
- Trajectory diagnostics and GIF export for best-trial visual summaries.
- Temporal Dynamics: Population PSTHs indicate stronger preparatory modulation in PMd and stronger movement-linked peaks in M1.
- Decoder Comparison: The notebook benchmarks a linear Wiener-style baseline (Ridge) against a GRU-based recurrent decoder for continuous velocity decoding.
- Continuous Information in Both Regions: Both PMd and M1 carry decodable kinematic information, with stronger decoding typically observed in M1.
- Acceleration Challenge: Position and velocity are generally reconstructed more reliably than acceleration, which is more sensitive to noise and smoothing assumptions.
Note: exact metric values depend on dataset/session selection and split configuration.
The electrophysiological and behavioral data used here was originally collected by Matthew G. Perich in the lab of Lee E. Miller at Northwestern University.
Dataset source:
- CRCNS motor-cortex dataset
pmd-1 - Link: https://crcns.org/data-sets/motor-cortex/pmd-1
This notebook is currently configured to run on:
source_data/processed/MM_S1_processed.mat
It also supports PMd+M1 sessions when M1 data is present.
Project.ipynb: Main cleaned notebook for all analyses and figures.Project.pre_cleanup_backup.ipynb: Backup of the pre-cleanup notebook state.source_data/processed/: Processed session.matfiles.exports/: Generated media outputs (including GIFs when exported).processing/: MATLAB helper scripts used during preprocessing workflows.
# Clone the repository
git clone https://github.com/arvindini/Introduction_to_Computational_Neuroscience.git
cd Introduction_to_Computational_Neuroscience/MDSC628/Project
# Create and activate environment (conda)
conda create -n torch-env python=3.10 -y
conda activate torch-env
# Install dependencies
pip install numpy pandas scipy scikit-learn matplotlib jupyter torch pillowIf you use micromamba, create an equivalent Python 3.10 environment and install the same packages.
- Launch Jupyter in this directory.
- Open
Project.ipynb. - Select the
python3kernel in your environment. - Run all cells from top to bottom.
Reproducibility details:
- Random seeds are fixed in decoder utilities.
- Group-aware split logic is used in decoder evaluation.
- Notebook outputs are generated directly from code execution.
The decoder section focuses on two families:
- Ridge (Wiener-style) velocity decoder on sliding neural windows.
- GRU velocity decoder with targeted hyperparameter search.
Decoded velocity is integrated to reconstruct position. Acceleration is derived and reported as supplemental.
- The notebook is region-aware and gracefully handles PMd-only sessions.
- M1 analysis branches are executed only when M1 data is available.
- Generated visual artifacts can be exported to
exports/.
If this code or workflow contributes to your work, please cite the original dataset source and acknowledge CRCNS pmd-1 and the original data contributors.