# tmedani/brainstorm3 architecture

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

- Interactive diagram: https://gitdiagram.com/tmedani/brainstorm3
- Repository: https://github.com/tmedani/brainstorm3

## Overview

Brainstorm is a graphical and scriptable application for analyzing MEG, EEG, fNIRS, ECoG, depth-electrode, and animal electrophysiology recordings. Its principal user workflow is to access data through the interface or batch scripts, apply analysis pipelines, and inspect results; the README documents these capabilities but the sampled code does not show the application-level routing between them. The graph therefore marks those links as unverified. Sampled source confirms a standalone Plexon PLX reader and two MATLAB numerical extensions; their integration with the main workflow is not established by the excerpts.

Main entry points: [`toolbox/process`](https://github.com/tmedani/brainstorm3/tree/master/toolbox/process) (Analysis pipelines), [`toolbox/gui`](https://github.com/tmedani/brainstorm3/tree/master/toolbox/gui) (Graphical interface), [`toolbox/script`](https://github.com/tmedani/brainstorm3/tree/master/toolbox/script) (Batch scripting), [`toolbox/io`](https://github.com/tmedani/brainstorm3/tree/master/toolbox/io) (Recording I/O)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_interface["Graphical interface"]
  node_batch["Batch scripting"]
  node_pipelines["Analysis pipelines"]
end

subgraph group_data["Data and anatomy"]
  node_dataio["Recording I/O"]
  node_database[("Data management")]
  node_anatomy["Anatomy processing"]
  node_sensors["Sensor handling"]
end

subgraph group_analysis["Signal analysis"]
  node_forward["Forward modeling"]
  node_inverse["Source estimation"]
  node_connectivity["Connectivity analysis"]
  node_timefreq["Time-frequency analysis"]
  node_results["Result visualization"]
end

subgraph group_extensions["Reader and numerical extensions"]
  node_plxreader["Plexon PLX reader<br/>[readPLXFileC.c]"]
  node_plxformat["Plexon format definitions<br/>[PlexonFiles.h]"]
  node_pacmex["Direct PAC metric<br/>[direct_pac_mex.c]"]
  node_meanvar["Mean variance MEX<br/>[bst_meanvar.c]"]
end

node_researcher(("Researcher"))

node_researcher -->|"uses"| node_interface
node_researcher -->|"scripts analyses"| node_batch
node_interface -.->|"accesses recordings"| node_dataio
node_dataio -.->|"stores data"| node_database
node_interface -.->|"runs pipelines"| node_pipelines
node_batch -.->|"runs pipelines"| node_pipelines
node_pipelines -.->|"uses anatomy"| node_anatomy
node_pipelines -.->|"uses sensors"| node_sensors
node_pipelines -.->|"computes forward model"| node_forward
node_pipelines -.->|"estimates sources"| node_inverse
node_pipelines -.->|"analyzes connectivity"| node_connectivity
node_pipelines -.->|"analyzes time frequency"| node_timefreq
node_interface -.->|"presents results"| node_results
node_plxreader -->|"uses definitions"| node_plxformat

click node_interface "https://github.com/tmedani/brainstorm3/tree/master/toolbox/gui"
click node_batch "https://github.com/tmedani/brainstorm3/tree/master/toolbox/script"
click node_pipelines "https://github.com/tmedani/brainstorm3/tree/master/toolbox/process"
click node_dataio "https://github.com/tmedani/brainstorm3/tree/master/toolbox/io"
click node_database "https://github.com/tmedani/brainstorm3/tree/master/toolbox/db"
click node_anatomy "https://github.com/tmedani/brainstorm3/tree/master/toolbox/anatomy"
click node_sensors "https://github.com/tmedani/brainstorm3/tree/master/toolbox/sensors"
click node_forward "https://github.com/tmedani/brainstorm3/tree/master/toolbox/forward"
click node_inverse "https://github.com/tmedani/brainstorm3/tree/master/toolbox/inverse"
click node_connectivity "https://github.com/tmedani/brainstorm3/tree/master/toolbox/connectivity"
click node_timefreq "https://github.com/tmedani/brainstorm3/tree/master/toolbox/timefreq"
click node_results "https://github.com/tmedani/brainstorm3/tree/master/toolbox/tree"
click node_plxreader "https://github.com/tmedani/brainstorm3/blob/master/external/plexon/readPLXFileC.c"
click node_plxformat "https://github.com/tmedani/brainstorm3/blob/master/external/plexon/PlexonFiles.h"
click node_pacmex "https://github.com/tmedani/brainstorm3/blob/master/toolbox/connectivity/private/direct_pac_mex.c"
click node_meanvar "https://github.com/tmedani/brainstorm3/blob/master/toolbox/math/bst_meanvar.c"

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_interface,node_batch,node_pipelines toneBlue
class node_dataio,node_database,node_anatomy,node_sensors toneAmber
class node_forward,node_inverse,node_connectivity,node_timefreq,node_results toneMint
class node_plxreader,node_plxformat,node_pacmex,node_meanvar toneRose
class node_researcher toneIndigo
```

## Components

### User interaction

- [Graphical interface](https://github.com/tmedani/brainstorm3/tree/master/toolbox/gui): `toolbox/gui`
- [Batch scripting](https://github.com/tmedani/brainstorm3/tree/master/toolbox/script): `toolbox/script`
- [Analysis pipelines](https://github.com/tmedani/brainstorm3/tree/master/toolbox/process): `toolbox/process`

### Data and anatomy

- [Recording I/O](https://github.com/tmedani/brainstorm3/tree/master/toolbox/io): `toolbox/io`
- [Data management](https://github.com/tmedani/brainstorm3/tree/master/toolbox/db): `toolbox/db`
- [Anatomy processing](https://github.com/tmedani/brainstorm3/tree/master/toolbox/anatomy): `toolbox/anatomy`
- [Sensor handling](https://github.com/tmedani/brainstorm3/tree/master/toolbox/sensors): `toolbox/sensors`

### Signal analysis

- [Forward modeling](https://github.com/tmedani/brainstorm3/tree/master/toolbox/forward): `toolbox/forward`
- [Source estimation](https://github.com/tmedani/brainstorm3/tree/master/toolbox/inverse): `toolbox/inverse`
- [Connectivity analysis](https://github.com/tmedani/brainstorm3/tree/master/toolbox/connectivity): `toolbox/connectivity`
- [Time-frequency analysis](https://github.com/tmedani/brainstorm3/tree/master/toolbox/timefreq): `toolbox/timefreq`
- [Result visualization](https://github.com/tmedani/brainstorm3/tree/master/toolbox/tree): `toolbox/tree`

### Reader and numerical extensions

- [Plexon PLX reader](https://github.com/tmedani/brainstorm3/blob/master/external/plexon/readPLXFileC.c): `external/plexon/readPLXFileC.c`
- [Plexon format definitions](https://github.com/tmedani/brainstorm3/blob/master/external/plexon/PlexonFiles.h): `external/plexon/PlexonFiles.h`
- [Direct PAC metric](https://github.com/tmedani/brainstorm3/blob/master/toolbox/connectivity/private/direct_pac_mex.c): `toolbox/connectivity/private/direct_pac_mex.c`
- [Mean variance MEX](https://github.com/tmedani/brainstorm3/blob/master/toolbox/math/bst_meanvar.c): `toolbox/math/bst_meanvar.c`

### Other components

- **Researcher**

## Connections

- Researcher → Graphical interface: uses (evidence: `README.md`)
- Researcher → Batch scripting: scripts analyses (evidence: `README.md`)
- Graphical interface → Recording I/O: accesses recordings
- Recording I/O → Data management: stores data
- Graphical interface → Analysis pipelines: runs pipelines
- Batch scripting → Analysis pipelines: runs pipelines
- Analysis pipelines → Anatomy processing: uses anatomy
- Analysis pipelines → Sensor handling: uses sensors
- Analysis pipelines → Forward modeling: computes forward model
- Analysis pipelines → Source estimation: estimates sources
- Analysis pipelines → Connectivity analysis: analyzes connectivity
- Analysis pipelines → Time-frequency analysis: analyzes time frequency
- Graphical interface → Result visualization: presents results
- Plexon PLX reader → Plexon format definitions: uses definitions (evidence: `external/plexon/readPLXFileC.c`)
