Code for "Temporal coding carries more stable cortical visual representations than firing rate over time"
This repository contains MATLAB code for reproducing key analyses and figures from the manuscript titled:
"Temporal coding carries more stable cortical visual representations than firing rate over time"
The demos provided here implement core steps such as temporal code fitting, representational drift analysis, decoding, unit tracking, and longitudional dimensionality reduction for populational neural code.
Please kindly cite the mentioned work if these code help you.
- Install MATLAB 2023b (tested on Linux OS) following official MATLAB installation instructions
- Estimated installation time: ~1 hour
- Run:
main_TemporalCodeFitting.m - Purpose: Fits stimulus-coding temporal components from spike trains. Reproduces Fig. 4a–d.
- Input: Loads the variable
VS_Store(1×15 cell array). Each cell contains a 50 trials × 16 classes × 520 time bins matrix (1 ms resolution), with 0 meaning no spike and 1 indicating a spike. - Also loads source data for the rest of Fig. 4.
- Expected Output: Complete Fig. 4
- Run Time: ~3 minutes
- Run:
main_RepresentationalDriftIndex.m - Download Data: https://doi.org/10.6084/m9.figshare.28877813
- Purpose: Calculates representational drift index across 15 time intervals based on fitted temporal components, following our interpretations from Marks and Goard, 2021.
Change the variablenVSto 2, 3, or 5 to generate additional figure panels. - Expected Output: Fig. 4f
- Run Time: ~10 minutes
- Run:
main_Umap.m - Download Data: https://doi.org/10.6084/m9.figshare.28877813
- Purpose: Generates low-dimensional representations of population activity using firing rates and fitted temporal components. Combines data across individual animals for comparison between rate and temporal codes.
- Expected Output: Fig. 5, SFig. 10a–d
- Run Time: ~20 minutes
- Run:
main_Decode_fix_slide_shuffle.mormain_Decode_rate_components.m - Download Data: https://doi.org/10.6084/m9.figshare.28877813
- Purpose: Trains stimulus decoders on past days and tests on future days. Compares performance using rate codes vs temporal codes.
- Expected Output: Fig. 1j, SFig. 3a–c, SFig. 10e–f
- Run Time: 300+ minutes
- Run:
main_Rate_Component_GLM_FitAgainst_Behavior.m - Download Data: https://doi.org/10.6084/m9.figshare.28877813
- Purpose: Fits generalized linear models (GLMs) using rate/temporal components to predict behavioral variables, see captions of SFig18d for details.
- Expected Output: SFig. 18d
- Run Time: Overnight
- Run:
main_Tracking.m - Download Data: https://doi.org/10.6084/m9.figshare.28877813
- Purpose: Tracks units from the same 32-channel (2×16) electrode array (with closed channels represented as blanks) across 4 example days.
- Users are repeatedly prompted to merge (press
1) or reject (press0orEnter) unit groups after viewing overlaid waveform plots. - Example: For groups (1,2,3) and (4,5,6), six panels are shown—(1,2,3), (4,5,6), (1,4), (1,6), (3,4), (3,6)—including intra- and inter-group combinations involving the first and last temporally appearing units.
- Press
2to view additional data: waveform movies, autocorrelograms (ACGs), and cross-correlograms (CCGs, when applicable: any two units from the same session). - Advanced inputs:
Nx2array like[1 3; 2 5]to block merges between units 1 vs 3 and 2 vs 5.[-3 -3]blocks unit 3 from merging with any other units.- Inputs with complex numbers (e.g.,
[2 4i],[-1 -1i]) tentatively reject specified merges but may prompt reconsideration in future iterations.
- Expected Output: Procedures described in SFig. 19 and Supplementary Methods. Waveform overlay plots of tracked units.
- Run Time: ~120 minutes, depending on manual input frequency
- Follow the demos above by running each
main_*.mfile in MATLAB. - Resulting figures will be either displayed or saved to the
results/folder.