# zareishayan/mean-cov-model architecture

> Architecture diagram of the GitHub repository zareishayan/mean-cov-model, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zareishayan/mean-cov-model
- Repository: https://github.com/zareishayan/mean-cov-model
- Video tour (about a minute): https://gitdiagram.com/zareishayan/mean-cov-model/video

## Overview

This research repository analyzes macaque neural responses during a foraging task. Its main workflow is to preprocess and load trial data, fit a conditional mean and structured covariance model, evaluate predictions, and interpret neural selectivity and population covariance. The graph also separates dataset/model definitions and training utilities from interpretation and visualization. Notebook orchestration is documented, but its implementation was not sampled; links from it to specific utilities are therefore shown as unverified.

Main entry points: [`mean-cov-model.ipynb`](https://github.com/zareishayan/mean-cov-model/blob/main/mean-cov-model.ipynb) (End-to-end analysis), [`src/helper_functions.py`](https://github.com/zareishayan/mean-cov-model/blob/main/src/helper_functions.py) (Training utilities), [`src/classes.py`](https://github.com/zareishayan/mean-cov-model/blob/main/src/classes.py) (Joint Gaussian model), [`src/plot_functions.py`](https://github.com/zareishayan/mean-cov-model/blob/main/src/plot_functions.py) (Analysis visualizations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_filter["Trial and unit filtering<br/>[filter_data.m]"]
  node_dataset["Preprocessed neural data<br/>[data.mat]"]
  node_notebook["End-to-end analysis"]
end

subgraph group_model["Modeling"]
  node_trialdata["Trial dataset<br/>[classes.py]"]
  node_mean["Conditional mean model<br/>[classes.py]"]
  node_covariance["Latent covariance model<br/>[classes.py]"]
  node_jointmodel["Joint Gaussian model<br/>[classes.py]"]
  node_training["Training utilities"]
end

subgraph group_analysis["Evaluation and interpretation"]
  node_prediction["Conditional predictions<br/>[classes.py]"]
  node_metrics["Predictive evaluation"]
  node_groupinfluence["Group influence analysis"]
  node_shap["Permutation SHAP"]
  node_selectivity["Null-standardized selectivity"]
  node_covanalysis["Covariance interpretation<br/>[plot_functions.py]"]
end

subgraph group_presentation["Visualization"]
  node_plots["Analysis visualizations<br/>[plot_functions.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"runs analysis"| node_notebook
node_filter -->|"preprocesses data"| node_dataset
node_dataset -->|"provides data"| node_notebook
node_notebook -.->|"builds trials"| node_trialdata
node_notebook -.->|"trains models"| node_training
node_trialdata -.->|"supplies batches"| node_training
node_training -.->|"fits model"| node_jointmodel
node_mean -->|"predicts mean"| node_jointmodel
node_covariance -->|"defines covariance"| node_jointmodel
node_jointmodel -->|"conditions predictions"| node_prediction
node_training -.->|"evaluates predictions"| node_metrics
node_notebook -->|"computes attributions"| node_shap
node_notebook -->|"tests selectivity"| node_selectivity
node_notebook -.->|"tests functional roles"| node_groupinfluence
node_covariance -->|"interprets structure"| node_covanalysis
node_shap -.->|"visualizes results"| node_plots
node_selectivity -.->|"visualizes results"| node_plots
node_covanalysis -.->|"generates figures"| node_plots

click node_filter "https://github.com/zareishayan/mean-cov-model/blob/main/filter_data.m"
click node_dataset "https://github.com/zareishayan/mean-cov-model/blob/main/data.mat"
click node_notebook "https://github.com/zareishayan/mean-cov-model/blob/main/mean-cov-model.ipynb"
click node_trialdata "https://github.com/zareishayan/mean-cov-model/blob/main/src/classes.py"
click node_mean "https://github.com/zareishayan/mean-cov-model/blob/main/src/classes.py"
click node_covariance "https://github.com/zareishayan/mean-cov-model/blob/main/src/classes.py"
click node_jointmodel "https://github.com/zareishayan/mean-cov-model/blob/main/src/classes.py"
click node_training "https://github.com/zareishayan/mean-cov-model/blob/main/src/helper_functions.py"
click node_prediction "https://github.com/zareishayan/mean-cov-model/blob/main/src/classes.py"
click node_metrics "https://github.com/zareishayan/mean-cov-model/blob/main/src/helper_functions.py"
click node_groupinfluence "https://github.com/zareishayan/mean-cov-model/blob/main/src/helper_functions.py"
click node_shap "https://github.com/zareishayan/mean-cov-model/blob/main/src/helper_functions.py"
click node_selectivity "https://github.com/zareishayan/mean-cov-model/blob/main/mean-cov-model.ipynb"
click node_covanalysis "https://github.com/zareishayan/mean-cov-model/blob/main/src/plot_functions.py"
click node_plots "https://github.com/zareishayan/mean-cov-model/blob/main/src/plot_functions.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_filter,node_dataset,node_notebook toneBlue
class node_trialdata,node_mean,node_covariance,node_jointmodel,node_training toneAmber
class node_prediction,node_metrics,node_groupinfluence,node_shap,node_selectivity,node_covanalysis toneMint
class node_plots toneRose
class node_researcher toneIndigo
```

## Components

### Data preparation

- [Trial and unit filtering](https://github.com/zareishayan/mean-cov-model/blob/main/filter_data.m): `filter_data.m`
- [Preprocessed neural data](https://github.com/zareishayan/mean-cov-model/blob/main/data.mat): `data.mat`
- [End-to-end analysis](https://github.com/zareishayan/mean-cov-model/blob/main/mean-cov-model.ipynb): `mean-cov-model.ipynb`

### Modeling

- [Trial dataset](https://github.com/zareishayan/mean-cov-model/blob/main/src/classes.py): `src/classes.py`
- [Conditional mean model](https://github.com/zareishayan/mean-cov-model/blob/main/src/classes.py): `src/classes.py`
- [Latent covariance model](https://github.com/zareishayan/mean-cov-model/blob/main/src/classes.py): `src/classes.py`
- [Joint Gaussian model](https://github.com/zareishayan/mean-cov-model/blob/main/src/classes.py): `src/classes.py`
- [Training utilities](https://github.com/zareishayan/mean-cov-model/blob/main/src/helper_functions.py): `src/helper_functions.py`

### Evaluation and interpretation

- [Conditional predictions](https://github.com/zareishayan/mean-cov-model/blob/main/src/classes.py): `src/classes.py`
- [Predictive evaluation](https://github.com/zareishayan/mean-cov-model/blob/main/src/helper_functions.py): `src/helper_functions.py`
- [Group influence analysis](https://github.com/zareishayan/mean-cov-model/blob/main/src/helper_functions.py): `src/helper_functions.py`
- [Permutation SHAP](https://github.com/zareishayan/mean-cov-model/blob/main/src/helper_functions.py): `src/helper_functions.py`
- [Null-standardized selectivity](https://github.com/zareishayan/mean-cov-model/blob/main/mean-cov-model.ipynb): `mean-cov-model.ipynb`
- [Covariance interpretation](https://github.com/zareishayan/mean-cov-model/blob/main/src/plot_functions.py): `src/plot_functions.py`

### Visualization

- [Analysis visualizations](https://github.com/zareishayan/mean-cov-model/blob/main/src/plot_functions.py): `src/plot_functions.py`

### Other components

- **Researcher**

## Connections

- Researcher → End-to-end analysis: runs analysis (evidence: `README.md`)
- Trial and unit filtering → Preprocessed neural data: preprocesses data (evidence: `README.md`)
- Preprocessed neural data → End-to-end analysis: provides data (evidence: `README.md`)
- End-to-end analysis → Trial dataset: builds trials
- End-to-end analysis → Training utilities: trains models
- Trial dataset → Training utilities: supplies batches (evidence: `src/helper_functions.py`)
- Training utilities → Joint Gaussian model: fits model (evidence: `src/helper_functions.py`)
- Conditional mean model → Joint Gaussian model: predicts mean (evidence: `README.md`)
- Latent covariance model → Joint Gaussian model: defines covariance (evidence: `README.md`)
- Joint Gaussian model → Conditional predictions: conditions predictions (evidence: `README.md`)
- Training utilities → Predictive evaluation: evaluates predictions (evidence: `src/helper_functions.py`)
- End-to-end analysis → Permutation SHAP: computes attributions (evidence: `README.md`)
- End-to-end analysis → Null-standardized selectivity: tests selectivity (evidence: `README.md`)
- End-to-end analysis → Group influence analysis: tests functional roles
- Latent covariance model → Covariance interpretation: interprets structure (evidence: `README.md`)
- Permutation SHAP → Analysis visualizations: visualizes results
- Null-standardized selectivity → Analysis visualizations: visualizes results
- Covariance interpretation → Analysis visualizations: generates figures (evidence: `src/plot_functions.py`)
