Code repository for the manuscript "Distinct Neural processes link speech planning and execution" by Duraivel et al (2026).
This repository contains all MATLAB scripts needed to reproduce the figures in the manuscript. Data are available on Zenodo (doi: 10.5281/zenodo.20720848).
We used intracranial EEG (sEEG/ECoG) to investigate how the human brain plans and executes speech sequences during articulation. Using temporal generalization decoding and high-gamma (70–150 Hz) cortical activation analyses across 10 anatomically defined regions of interest, we identified a two-tiered hierarchical structures in three speech networks:
- Planning network (IFG, rMFG, cMFG)
- Articulation network (SMC, IPC)
- Monitoring network (Insula, aSTG, pSTG, STS, PAC)
speechPlanning_manuscript/
├── setup.m # Configure paths — edit before running anything
├── data/
│ ├── colors.mat # Shared color palette for all plots
│ └── README.md # Zenodo package description and figure index
├── visualization/ # One script per figure — run these to reproduce figures
│ ├── figure1_behavior.m
│ ├── figure2_hg_timecourses.m
│ ├── figure3_syllable_decoding.m
│ ├── figure4_hierarchy.m
│ ├── figure5_phoneme_sequence.m
│ ├── extended_data1_rh_hg.m
│ ├── extended_data2_syllable_roi_lh.m
│ ├── extended_data3_hierarchy_per_roi.m
│ ├── supp1_behavior_lme.m
│ ├── supp2_hg_go_cue.m
│ ├── supp3_nnmf.m
│ ├── supp4_syllable_rh_roi.m
│ ├── supp5_syllable_go_cue.m
│ ├── supp6_phonotactics.m
│ ├── supp7_ifg_specificity.m
│ ├── supp8_subject_specific.m
│ ├── supp9_micro_ecog.m
│ ├── supp10_phoneme_rh_roi.m
│ └── supp11_phoneme_sequence_rh.m
├── processing/ # Scripts that generate the .mat result files from raw data
│ ├── electrode_selection.m
│ ├── nonNegMatFact.m
│ ├── Phoneme_Sequencing_*.m
│ └── server/ # HPC batch scripts (SLURM/cluster jobs)
└── decoding/ # µECoG-specific decoding (requires raw recordings)
├── setup_micro.m
├── figure5_micro_s14/
├── supp9_micro_s16_s62/
└── utils/
- MATLAB R2020a or later
- IEEG_Pipelines —
git clone https://github.com/coganlab/speech-planning.git
cd speech-planningDownload the Zenodo archive (doi: 10.5281/zenodo.20720848) and extract it to a local folder. The package contains four subdirectories:
speech_planning_data/
├── hg_activations/ # Pooled high-gamma epoch data
├── decoding_results/ # Temporal generalization decoder outputs
├── behavior/ # Behavioral summary files
└── micro_ecog/ # µECoG electrode metadata
See data/README.md for a full description of every file in the package.
Open setup.m and set the two user-configurable paths at the top:
DATA_DIR = '/path/to/speech_planning_data'; % folder extracted from Zenodo
IEEG_DIR = '/path/to/IEEG_Pipelines/MATLAB'; % your local clone of IEEG_PipelinesHG_DIR, DEC_DIR, BEH_DIR, and OUT_DIR are derived automatically from DATA_DIR.
In MATLAB, navigate to the repository root and run any visualization script:
cd /path/to/speech-planning
visualization/figure3_syllable_decoding % no iEEG access neededFigures are saved as .eps and .png to OUT_DIR/figure3/ (i.e., inside your Zenodo data folder under figures/).
| Figure | Script | Zenodo data needed | Requires iEEG access? |
|---|---|---|---|
| Figure 1 | visualization/figure1_behavior.m |
— | Yes (popTaskSubjectData) |
| Figure 2 | visualization/figure2_hg_timecourses.m |
hg_activations/ |
Yes (extractRoiIds) |
| Figure 3 | visualization/figure3_syllable_decoding.m |
decoding_results/ |
No |
| Figure 4 | visualization/figure4_hierarchy.m |
decoding_results/ |
No |
| Figure 5 | visualization/figure5_phoneme_sequence.m |
decoding_results/ |
No (µECoG panels: Yes) |
| Extended Data 1 | visualization/extended_data1_rh_hg.m |
hg_activations/ |
Yes |
| Extended Data 2 | visualization/extended_data2_syllable_roi_lh.m |
decoding_results/ |
No |
| Extended Data 3 | visualization/extended_data3_hierarchy_per_roi.m |
decoding_results/ |
No |
| Supp 1 | visualization/supp1_behavior_lme.m |
— | Yes |
| Supp 2 | visualization/supp2_hg_go_cue.m |
hg_activations/ |
Yes |
| Supp 3 | visualization/supp3_nnmf.m |
hg_activations/ |
Yes |
| Supp 4 | visualization/supp4_syllable_rh_roi.m |
decoding_results/ |
No |
| Supp 5 | visualization/supp5_syllable_go_cue.m |
decoding_results/ |
No |
| Supp 6 | visualization/supp6_phonotactics.m |
decoding_results/ |
No |
| Supp 7 | visualization/supp7_ifg_specificity.m |
hg_activations/ |
Yes |
| Supp 8 | visualization/supp8_subject_specific.m |
hg_activations/ |
Yes |
| Supp 9 | visualization/supp9_micro_ecog.m |
micro_ecog/ + raw µECoG |
Yes |
| Supp 10 | visualization/supp10_phoneme_rh_roi.m |
decoding_results/ |
No |
| Supp 11 | visualization/supp11_phoneme_sequence_rh.m |
decoding_results/ |
No |
Figures requiring institutional iEEG access use popTaskSubjectData from IEEG_Pipelines to load raw trial data from the CoganLab data server. These figures cannot be reproduced from the Zenodo package alone.
Scripts in decoding/ use raw µECoG recordings and require additional setup:
- Open
decoding/setup_micro.m - Set
MICRO_DIRto your localMicro/Processed Datafolder - Set
RECON_DIRto your local clone of ECoG_Recon (matlab_code subfolder)
µECoG subjects:
- S14 (manuscript S3, 256-ch) — Figure 4 and 5 µECoG panels →
decoding/figure5_micro_s14/ - S16 (manuscript S1, 128-ch) — Figure 3 µECoG panels →
decoding/supp9_micro_s16_s62/ - S62 (manuscript S2, 256-ch) — Figure 3 µECoG panels →
decoding/supp9_micro_s16_s62/
Electrode metadata for these subjects (impedance, significant channel masks) is included in the Zenodo package under micro_ecog/.
The processing/ directory contains scripts that generate the .mat files in the Zenodo package from raw iEEG recordings. These require institutional data access and are provided for transparency, not for general reproduction.
electrode_selection.m— identifies production-active electrodes (FDR q<0.05)Phoneme_Sequencing_timeGen_syllable_ROI_pooledSubjects.m— runs syllable temporal generalization decoder per ROIPhoneme_Sequencing_timeGen_Blick_ROI_pooledSubjects.m— runs phonotactic (BLICK) regressornonNegMatFact.m+Phoneme_Sequencing_timeGen_decomposition_pooledSubjects.m— NNMF decomposition (k=5)processing/server/— parallelized HPC versions of the above for cluster submission
Processed neural data are available on Zenodo under restricted access: doi: 10.5281/zenodo.20720848. Access can be requested via the Zenodo record page.
Raw iEEG recordings are available upon request to corresponding authors.
Suseendrakumar Duraivel | CoganLab, Duke University
Gregory Cogan | CoganLab, Duke University