# gin-ieeg/bidsforge architecture

> Architecture diagram of the GitHub repository gin-ieeg/bidsforge, 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/gin-ieeg/bidsforge
- Repository: https://github.com/gin-ieeg/bidsforge

## Overview

bidsforge is a BIDS-based iEEG analysis toolkit. The principal workflow discovers and groups BIDS files, configures a processor and writer, runs signal or trial-statistics analyses, and writes derivatives with provenance. Its documented branches include Hilbert envelopes, time-frequency maps, subject-level condition tests and regressions, and their group-level ROI analyses. A separate visualization application supports trial-statistics exploration. Some pipeline modules were not sampled; their presence and roles are documented in the README, so those links are documentation-backed rather than claims of inspected implementation.

Main entry points: [`bidsforge/processing/base.py`](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/base.py) (Run and write), [`bidsforge/processing/trial_stats/processor.py`](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/trial_stats/processor.py) (Subject trial stats), [`bidsforge/visualization/trial_stats/window.py`](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/visualization/trial_stats/window.py) (Analysis window), [`bidsforge/processing/trial_stats_group/processor.py`](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/trial_stats_group/processor.py) (Group statistics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bids["BIDS inputs"]
  node_dataset["BIDS dataset<br/>[dataset.py]"]
  node_file["BIDS files<br/>[file.py]"]
  node_groups["File grouping<br/>[file_group.py]"]
  node_matching["Entity matching<br/>[matching.py]"]
  node_loader["Data loading<br/>[loader.py]"]
end

subgraph group_pipeline["Processing framework"]
  node_base["Run and write<br/>[base.py]"]
  node_hilbert["Hilbert envelopes<br/>[dsp.py]"]
  node_tf["Time-frequency maps<br/>[dsp.py]"]
  node_storage["HDF5 support<br/>[hdf5.py]"]
  node_matlab["MATLAB support<br/>[matlab.py]"]
end

subgraph group_subject["Subject analyses"]
  node_subjectstats["Subject trial stats<br/>[processor.py]"]
  node_subjectparams["Subject parameters<br/>[params.py]"]
  node_subjectresult["Subject results<br/>[result.py]"]
  node_tfstats["TF trial stats<br/>[processor.py]"]
  node_resolver["Trial resolution<br/>[trial_resolver.py]"]
  node_rules["Condition rules<br/>[condition_rules.py]"]
  node_events["Event handling<br/>[events.py]"]
end

subgraph group_group["Group analyses"]
  node_subjectgroup["Group statistics<br/>[processor.py]"]
  node_groupresult["Group results<br/>[result.py]"]
end

subgraph group_viz["Visualization"]
  node_app["Stats application<br/>[app.py]"]
  node_window["Analysis window<br/>[window.py]"]
  node_worker["Background workers<br/>[worker.py]"]
  node_plot["Subject plots<br/>[plot_panel.py]"]
  node_groupplot["Group plots"]
end

node_user(("Analyst"))

node_user -->|"provides data"| node_dataset
node_dataset -->|"discovers files"| node_file
node_dataset -->|"builds groups"| node_groups
node_file -->|"loads data"| node_loader
node_user -->|"configures run"| node_base
node_base -.->|"runs processor"| node_hilbert
node_base -.->|"runs processor"| node_tf
node_base -.->|"runs processor"| node_subjectstats
node_base -.->|"runs processor"| node_subjectgroup
node_base -->|"processes groups"| node_groups
node_base -.->|"writes derivatives"| node_storage
node_subjectstats -->|"resolves trials"| node_resolver
node_subjectstats -->|"uses events"| node_events
node_resolver -->|"applies rules"| node_rules
node_subjectstats -.->|"produces results"| node_subjectresult
node_tfstats -->|"resolves trials"| node_resolver
node_subjectgroup -.->|"produces results"| node_groupresult
node_user -->|"opens analysis"| node_app
node_app -->|"launches window"| node_window
node_window -->|"starts workers"| node_worker
node_window -.->|"renders results"| node_plot
node_window -->|"renders group results"| node_groupplot
node_subjectresult -.->|"aggregates subjects"| node_subjectgroup
node_subjectgroup -.->|"matches inputs"| node_matching

click node_dataset "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/bids/dataset.py"
click node_file "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/bids/file.py"
click node_groups "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/bids/file_group.py"
click node_matching "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/bids/matching.py"
click node_loader "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/data/loader.py"
click node_base "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/base.py"
click node_hilbert "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/hilbert/dsp.py"
click node_tf "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/time_frequency/dsp.py"
click node_subjectstats "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/trial_stats/processor.py"
click node_subjectparams "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/trial_stats/params.py"
click node_subjectresult "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/trial_stats/result.py"
click node_tfstats "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/time_frequency_stats/processor.py"
click node_resolver "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/utils/trial_resolver.py"
click node_rules "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/utils/condition_rules.py"
click node_events "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/utils/events.py"
click node_subjectgroup "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/trial_stats_group/processor.py"
click node_groupresult "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/trial_stats_group/result.py"
click node_storage "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/utils/hdf5.py"
click node_matlab "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/utils/matlab.py"
click node_app "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/visualization/trial_stats/app.py"
click node_window "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/visualization/trial_stats/window.py"
click node_worker "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/visualization/trial_stats/worker.py"
click node_plot "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/visualization/trial_stats/panels/plot_panel.py"
click node_groupplot "https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/visualization/trial_stats/panels/group_plot_panel.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_dataset,node_file,node_groups,node_matching,node_loader toneBlue
class node_base,node_hilbert,node_tf,node_storage,node_matlab toneAmber
class node_subjectstats,node_subjectparams,node_subjectresult,node_tfstats,node_resolver,node_rules,node_events toneMint
class node_subjectgroup,node_groupresult toneRose
class node_app,node_window,node_worker,node_plot,node_groupplot,node_user toneIndigo
```

## Components

### BIDS inputs

- [BIDS dataset](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/bids/dataset.py): `bidsforge/bids/dataset.py`
- [BIDS files](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/bids/file.py): `bidsforge/bids/file.py`
- [File grouping](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/bids/file_group.py): `bidsforge/bids/file_group.py`
- [Entity matching](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/bids/matching.py): `bidsforge/bids/matching.py`
- [Data loading](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/data/loader.py): `bidsforge/data/loader.py`

### Processing framework

- [Run and write](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/base.py): `bidsforge/processing/base.py`
- [Hilbert envelopes](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/hilbert/dsp.py): `bidsforge/processing/hilbert/dsp.py`
- [Time-frequency maps](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/time_frequency/dsp.py): `bidsforge/processing/time_frequency/dsp.py`
- [HDF5 support](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/utils/hdf5.py): `bidsforge/processing/utils/hdf5.py`
- [MATLAB support](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/utils/matlab.py): `bidsforge/processing/utils/matlab.py`

### Subject analyses

- [Subject trial stats](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/trial_stats/processor.py): `bidsforge/processing/trial_stats/processor.py`
- [Subject parameters](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/trial_stats/params.py): `bidsforge/processing/trial_stats/params.py`
- [Subject results](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/trial_stats/result.py): `bidsforge/processing/trial_stats/result.py`
- [TF trial stats](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/time_frequency_stats/processor.py): `bidsforge/processing/time_frequency_stats/processor.py`
- [Trial resolution](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/utils/trial_resolver.py): `bidsforge/processing/utils/trial_resolver.py`
- [Condition rules](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/utils/condition_rules.py): `bidsforge/processing/utils/condition_rules.py`
- [Event handling](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/utils/events.py): `bidsforge/processing/utils/events.py`

### Group analyses

- [Group statistics](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/trial_stats_group/processor.py): `bidsforge/processing/trial_stats_group/processor.py`
- [Group results](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/processing/trial_stats_group/result.py): `bidsforge/processing/trial_stats_group/result.py`

### Visualization

- [Stats application](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/visualization/trial_stats/app.py): `bidsforge/visualization/trial_stats/app.py`
- [Analysis window](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/visualization/trial_stats/window.py): `bidsforge/visualization/trial_stats/window.py`
- [Background workers](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/visualization/trial_stats/worker.py): `bidsforge/visualization/trial_stats/worker.py`
- [Subject plots](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/visualization/trial_stats/panels/plot_panel.py): `bidsforge/visualization/trial_stats/panels/plot_panel.py`
- [Group plots](https://github.com/gin-ieeg/bidsforge/blob/master/bidsforge/visualization/trial_stats/panels/group_plot_panel.py): `bidsforge/visualization/trial_stats/panels/group_plot_panel.py`

### Other components

- **Analyst**

## Connections

- Analyst → BIDS dataset: provides data (evidence: `README.md`)
- BIDS dataset → BIDS files: discovers files (evidence: `bidsforge/bids/dataset.py`)
- BIDS dataset → File grouping: builds groups (evidence: `bidsforge/bids/file_group.py`)
- BIDS files → Data loading: loads data (evidence: `bidsforge/bids/file.py`)
- Analyst → Run and write: configures run (evidence: `README.md`)
- Run and write → Hilbert envelopes: runs processor
- Run and write → Time-frequency maps: runs processor
- Run and write → Subject trial stats: runs processor (evidence: `bidsforge/processing/trial_stats/processor.py`)
- Run and write → Group statistics: runs processor
- Run and write → File grouping: processes groups (evidence: `bidsforge/processing/base.py`)
- Run and write → HDF5 support: writes derivatives
- Subject trial stats → Trial resolution: resolves trials (evidence: `bidsforge/processing/trial_stats/processor.py`)
- Subject trial stats → Event handling: uses events (evidence: `bidsforge/processing/trial_stats/processor.py`)
- Trial resolution → Condition rules: applies rules (evidence: `bidsforge/processing/utils/trial_resolver.py`)
- Subject trial stats → Subject results: produces results (evidence: `bidsforge/processing/trial_stats/processor.py`)
- TF trial stats → Trial resolution: resolves trials (evidence: `bidsforge/processing/time_frequency_stats/processor.py`)
- Group statistics → Group results: produces results
- Analyst → Stats application: opens analysis (evidence: `README.md`)
- Stats application → Analysis window: launches window (evidence: `bidsforge/visualization/trial_stats/app.py`)
- Analysis window → Background workers: starts workers (evidence: `bidsforge/visualization/trial_stats/window.py`)
- Analysis window → Subject plots: renders results (evidence: `bidsforge/visualization/trial_stats/window.py`)
- Analysis window → Group plots: renders group results (evidence: `bidsforge/visualization/trial_stats/window.py`)
- Subject results → Group statistics: aggregates subjects
- Group statistics → Entity matching: matches inputs
