Skip to content

About

source code of paper "Fine grained two-dimensional cursor control with epidural minimally invasive brain-computer interface"

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

NEO-8D-code

Analysis code for the NEO-8D project: decoding single and dual upper-limb movements from ECoG spectral features.

Two participants (P01, P02) performed four single movements (Left/Right Elbow, Left/Right Hand) and four dual movements (combinations of two single movements). This repository contains the high-gamma PSD datasets together with self-contained MATLAB scripts covering the main analyses: ERDS spectra, demixed PCA, linear decomposition of dual-movement patterns, class-distance clustering, cross-validated decoding, and an offline center-out BCI simulation.

Requirements

  • MATLAB R2023b (older releases down to ~R2019b should also work).
  • Statistics and Machine Learning Toolbox (pca, fitlm, fitcdiscr, linkage, ksdensity, ...).
  • No third-party toolboxes: all colormaps are vendored in utils/slanCM_palette.m.

Data download

Please download the two PSD datasets (PSDdata-P01.mat, PSDdata-P02.mat) from the figshare link and place them in the data/ folder:

NEO-8D-code/
└── data/
    ├── PSDdata-P01.mat
    └── PSDdata-P02.mat

Each file contains three variables:

Variable Size Description
Spectra freq x channels x trials PSD values per trial (8 ECoG channels)
fb 76 x 1 frequency axis, ~2–148 Hz (0.5 s window, fs = 1000 Hz)
Ylab trials x 1 trial label (see table below)

Trial labels:

Code Condition Code Condition
100 Rest 121 LE & LH
101 LE (left elbow) 122 LE & RE
102 LH (left hand) 125 LH & RH
103 RE (right elbow) 126 RE & RH
104 RH (right hand)
  • P01: 5588 trials (motor-imagery style cues)
  • P02: 1912 trials (attempted movements)

How to run

  1. Open MATLAB in the NEO-8D-code/ folder (startup.m adds utils/ to the path automatically; if you start MATLAB elsewhere, run startup once first).

  2. Every script is standalone — open it and run top-to-bottom. Set the participant at the top of the file:

    SUBJECT = 'P01';   % 'P01' | 'P02'
  3. Or run a script for a specific participant without editing it:

    SUBJECT = 'P02';  offline_bci_simulation

Scripts

Script What it does Approx. runtime
erds_spectra.m Task-related SNR (ERDS) spectra per movement class for both participants; optionally HG RMS time courses if non-public HGseqdata-*.mat files are placed in data/ < 1 min
movement_dpca.m Demixed PCA on single-movement patterns; projects single and dual trials onto the first two demixed axes < 1 min
dual_psd_decomposition.m Regresses each dual-movement PSD pattern onto linear combinations of single-movement patterns (R² bar plot, regression-weight scatter plots, paired statistics) < 1 min
class_distance_clustering.m Pairwise Mahalanobis distances between the 8 movement classes + Ward hierarchical clustering < 1 min
class_psd_maps.m Trial-averaged channel x frequency PSD maps for each of the 8 classes < 1 min
decoding_confusion_matrices.m Repeated 80/20 LDA decoding (100 splits): single-movement 4-class and merged single+dual 4-class confusion matrices; population-vector diagram a few minutes
offline_bci_simulation.m Full offline pipeline: 3 decoding schemas + stochastic center-out BCI simulation driven by the measured confusion matrices (5040 population-vector permutations) ~10–30 min

Notes

  • Axis limits in some scripts are tuned for P01; for P02 the scripts fall back to automatic limits where relevant.

Reference

(add the manuscript citation here once available)

About

source code of paper "Fine grained two-dimensional cursor control with epidural minimally invasive brain-computer interface"

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages