How eabhorrocks/horrocksetal24_temporaldynamics works
1. Repository purpose and runtime
- This is a MATLAB 2022a analysis repo for the paper on mouse visual cortex population dynamics.
- The code is organized around per-session processing of pre-extracted *_basic.mat files, followed by downstream group-level analyses, plotting, and statistics.
2. Primary data boundary
- The input boundary is session-level data files from the external dataset download.
- A separate metadata spreadsheet in AllenDataAnalysis/AllenSessionInfo.xlsx and the paper’s supplementary tables support session selection and labeling.
- The output boundary is a set of processed session files and derived metrics consumed by analysis scripts.
3. Session preprocessing layer
- The processSession_XXX scripts are the main ingestion/normalization layer.
- They convert raw session data into analysis-ready structures and intermediate results for:
- PSTHs
- decoding
- factor analysis
- correlations
- tuning-over-time
- These scripts are long-running and intended to be batch-executed, often in parallel.
4. Allen-specific preprocessing path
- AllenDataAnalysis contains a dedicated pipeline for Allen dataset processing.
- preprocessAllenData.m and the helper functions in processingFuns/ build trial, unit, and behavior-aligned structures from raw Allen-format data.
- analyseAllenPSTHs.m and processSession_allenPSTH.m operate on those processed Allen structures to generate PSTH summaries and figures.
5. PSTH and response-shape analysis
- The PSTHs folder focuses on peri-stimulus time histogram analysis at the cell and population level.
- It includes scripts for cell-type and speed-dependent stratification, response sorting, and PSTH metric extraction.
- This subsystem produces figures and response summaries that feed later comparisons.
6. Correlation and stability analyses
- The Correlations folder contains temporal, signal, and noise correlation analyses.
- These scripts quantify response stability and correlation structure across time and conditions.
- Outputs include precomputed .mat intermediates and figure files used in the paper’s correlation results.
7. Decoding subsystem
- The Decoding folder contains classifiers and cross-time decoding analyses.
- It includes discriminant analysis, train/test decoding, multi-population-size decoding, and cross-time decoding scripts.
- The flow here is: processed spike counts or population responses in, decoding performance matrices and summary statistics out.
8. Factor analysis and latent-dynamics subsystem
- FactorAnalysis is the main dimensionality-reduction and latent-dynamics layer.
- It uses DataHigh/GPFA-style tooling to study low-dimensional structure, angles, fit separation, neural tangling, and single-trial latent trajectories.
- This subsystem is central for linking population geometry to sensory encoding speed/stability.
9. Tuning-over-time and longitudinal metrics
- TuningOverTime tracks how tuning quality changes across time windows within a session.
- It computes R²-over-time and related timing metrics used for “start,” “finish,” and duration summaries.
- This layer converts session-level dynamics into compact temporal statistics for paper figures.
10. Reusable analysis primitives
- NeuralDataAnalysis provides the shared computational core: spike binning, PSTH construction, responsive-cell tests, pairwise/noise correlations, d-prime, mutual information, decoder helpers, and population geometry metrics.
- These functions are the common dependency layer used by the higher-level analysis folders.
11. Shared utility and visualization infrastructure
- GenericFunctions is a large support library of general MATLAB utilities for statistics, signal handling, file/table helpers, and plotting.
- GenericFunctions/Plotting includes custom plotting primitives, colormaps, and figure-export utilities.
- The repo also bundles third-party helpers such as CircStat, DABEST-Matlab, npy-matlab, and export_fig.
12. External custom toolboxes
- Toolboxes_customised contains vendored copies of the main external dependencies:
- DataHigh / GPFA for latent trajectory and factor-analysis work
- CellExplorer CCG utilities for autocorrelogram/cross-correlogram style analyses
- Umakantha et al. population-metric helpers
- These toolboxes are integrated into the analysis code rather than treated as separate services.
13. Review and supplementary analysis layer
- ReviewAnalyses contains comparison and robustness analyses, likely used for reviewer-facing extensions or alternate criteria.
- It reuses the same processed session outputs but recomputes selected metrics under different assumptions.
14. Figure artifacts and static outputs
- The repository includes many saved .fig files representing publication figures or intermediate visualizations.
- These are generated outputs, not primary inputs, and show that the analysis pipeline is meant to reproduce both numeric results and manuscript-quality graphics.
Main entry points: NeuralDataAnalysis Neural core · FactorAnalysis Factor analysis · PSTHs PSTHs · Plotting Plotting
Components 24
Session pipeline
Per-session ingestion, normalization, and batch analyses built around processed session inputs.
- Allen metadata · Spreadsheet and helpers for Allen session selection and labeling.
AllenDataAnalysis/AllenSessionInfo.xlsx - Allen preprocess · Builds Allen-format trial, unit, and behavior-aligned structures.
AllenDataAnalysis/processingFuns/preprocessAllenData.m - Allen PSTH · Runs PSTH summaries and figures for Allen sessions.
AllenDataAnalysis/analyseAllenPSTHs.m - PSTH sessions · Per-session PSTH processing entry point for the main dataset.
PSTHs/processSession_PSTH.m - Decode sessions · Per-session decoding pipeline for population responses.
Decoding/processSession_decoding.m - FA sessions · Per-session factor-analysis and population-geometry entry point.
FactorAnalysis/processSession_popAnalysis.m - Corr sessions · Per-session correlation analysis entry point.
Correlations/processSession_correlationAnalysis_v2.m - R2 sessions · Per-session tuning-over-time processing.
TuningOverTime/getTuningTimeInfo_paper.m
Analysis subsystems
Major scientific analysis branches used in the paper.
- Decoding · Classifiers and cross-time decoding analyses.
Decoding - Factor analysis · Latent-dynamics, GPFA/DataHigh, fit separation, tangling, and trajectory analysis.
FactorAnalysis - Correlations · Temporal, signal, and noise correlation analyses.
Correlations - PSTHs · Cell- and population-level PSTH stratification and metric extraction.
PSTHs - Tuning over time · Computes R2-over-time and timing summaries.
TuningOverTime - Review analyses · Alternate criteria and comparison analyses reusing processed outputs.
ReviewAnalyses
Shared core
Reusable analysis primitives and infrastructure.
- Neural core · Spike binning, PSTHs, response tests, correlations, decoding helpers, and geometry metrics.
NeuralDataAnalysis - Generic utils · Common MATLAB utilities for statistics, tables, signals, and general helpers.
GenericFunctions - Plotting · Custom plotting primitives, colormaps, and figure export utilities.
GenericFunctions/Plotting
Bundled toolboxes
Vendored external dependencies integrated into the MATLAB analysis code.
- DataHigh/GPFA · Vendored DataHigh and GPFA tooling for dimensionality reduction and latent trajectories.
Toolboxes_customised/DataHigh-master - CCG tools · CellExplorer cross-correlogram utilities and compiled helpers.
Toolboxes_customised/CellExplorer_CCG - Umakantha metrics · Vendored population-metric helpers used by the analysis code.
Toolboxes_customised/UmakanthaMetrics
Artifacts
Static figures and spreadsheet inputs bundled with the repo.
- Allen figs · Pre-rendered PSTH and response summary figures for Allen analyses.
AllenDataAnalysis/figures - Corr figs · Saved correlation result figures.
Correlations/noiseStabiity_longAxis.fig - Tuning figs · Saved longitudinal tuning figures.
TuningOverTime/tuningStart_scatter_sameScale.fig - Supp info · Supplementary statistics and information table.
SupplementaryInfo/V1 Dynamics Stats And Info Table.xlsx
Connections 27
- Allen metadata → Allen preprocess: selects sessions · Metadata guides Allen session preprocessing.
- Allen preprocess → Allen PSTH: feeds · Preprocessed Allen structures are analyzed for PSTHs.
- Allen PSTH → Allen figs: writes · Allen analysis produces saved figures.
- Neural core → PSTH sessions: supports · Shared PSTH and response routines power per-session processing.
- Neural core → Decode sessions: supports · Shared decoding helpers power per-session decoding.
- Neural core → FA sessions: supports · Shared geometry and latent-dynamics metrics support factor analysis.
- Neural core → Corr sessions: supports · Shared correlation routines support per-session correlation analysis.
- Neural core → R2 sessions: supports · Shared R2-over-time computation supports tuning analysis.
- PSTH sessions → PSTHs: feeds · Session outputs are consumed by PSTH analyses.
- Decode sessions → Decoding: feeds · Session outputs are consumed by decoding analyses.
- FA sessions → Factor analysis: feeds · Session outputs are consumed by factor-analysis analyses.
- Corr sessions → Correlations: feeds · Session outputs are consumed by correlation analyses.
- R2 sessions → Tuning over time: feeds · Session outputs are consumed by tuning-over-time analyses.
- PSTHs → Allen figs: writes · PSTH work also produces publication-style figures.
- Correlations → Corr figs: writes · Correlation analyses emit saved figures.
- Tuning over time → Tuning figs: writes · Longitudinal tuning analyses emit saved figures.
- Decoding → Supp info: summarizes · Decoding and analysis summaries contribute to supplementary tables.
- Factor analysis → DataHigh/GPFA: uses · Latent-dynamics analyses depend on DataHigh/GPFA tooling.
- Factor analysis → Umakantha metrics: uses · Factor-analysis metrics reuse shared population-metric helpers.
- Correlations → CCG tools: uses · Correlation analyses rely on correlogram tooling where needed.
- PSTHs → Plotting: uses · PSTH figures rely on shared plotting infrastructure.
- Decoding → Plotting: uses · Decoding plots rely on shared plotting infrastructure.
- Factor analysis → Plotting: uses · Factor-analysis visualizations rely on shared plotting infrastructure.
- Review analyses → PSTHs: reuses · Review analyses recompute selected PSTH metrics under alternate criteria.
- Review analyses → Factor analysis: reuses · Review analyses recompute selected factor-analysis metrics under alternate criteria.
- Generic utils → Neural core: supports · Generic utilities underpin the shared computational core.
- Generic utils → Plotting: supports · Generic utilities include plotting helpers and export tooling.