# floristijhuis/neuro-utils architecture

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

- Interactive diagram: https://gitdiagram.com/floristijhuis/neuro-utils
- Repository: https://github.com/floristijhuis/neuro-utils

## Overview

neuro-utils is a small command-line wrapper that reads one project YAML, selects BIDS subjects and sessions, then runs native FreeSurfer or containerized fMRIPrep/MRIQC and places outputs in derivatives. Its main stages are configuration and selection, tool-specific command preparation, optional scratch staging, execution, and output cleanup or retention on failure. The graph distinguishes participant and group MRIQC workflows and FreeSurfer reuse. Relationships are based on the shown source and README; unsampled configuration and capabilities are not expanded beyond documented behavior.

Main entry points: [`neuro_utils/cli.py`](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/cli.py) (Command entry), [`neuro_utils/nipreps.py`](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/nipreps.py) (Container jobs), [`neuro_utils/staging.py`](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/staging.py) (BIDS staging), [`neuro_utils/freesurfer.py`](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/freesurfer.py) (FreeSurfer workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and configuration"]
  node_cli["Command entry<br/>[cli.py]"]
  node_config["Project config<br/>[config.py]"]
  node_selection["Subject selection<br/>[cli.py]"]
end

subgraph group_processing["Processing workflows"]
  node_freesurfer["FreeSurfer workflow<br/>[freesurfer.py]"]
  node_fmriprep["fMRIPrep workflow<br/>[nipreps.py]"]
  node_mriqc_participant["MRIQC participant<br/>[nipreps.py]"]
  node_mriqc_group["MRIQC group<br/>[nipreps.py]"]
end

subgraph group_runtime["Execution and staging"]
  node_staging["BIDS staging<br/>[staging.py]"]
  node_container_jobs["Container jobs<br/>[nipreps.py]"]
  node_container_runtime["Docker commands<br/>[containers.py]"]
end

subgraph group_data["Dataset locations"]
  node_bids_dataset["BIDS dataset"]
  node_derivatives["Derivatives"]
  node_scratch["Scratch workspace"]
end

node_user(("CLI user"))
node_project_yaml["Project YAML"]
node_freesurfer_tool["recon-all"]
node_docker["Docker daemon"]

node_user -->|"runs command"| node_cli
node_cli -->|"loads YAML"| node_config
node_project_yaml -->|"configures project"| node_config
node_cli -->|"resolves subjects"| node_selection
node_selection -->|"lists subjects"| node_bids_dataset
node_cli -->|"dispatches"| node_freesurfer
node_cli -->|"dispatches"| node_fmriprep
node_cli -->|"dispatches"| node_mriqc_participant
node_cli -->|"dispatches"| node_mriqc_group
node_freesurfer -->|"runs recon-all"| node_freesurfer_tool
node_freesurfer -->|"copies outputs"| node_staging
node_fmriprep -->|"prepares job"| node_container_jobs
node_mriqc_participant -->|"prepares job"| node_container_jobs
node_mriqc_group -->|"prepares job"| node_container_jobs
node_container_jobs -->|"builds and runs"| node_container_runtime
node_container_runtime -->|"invokes Docker"| node_docker
node_fmriprep -->|"stages BIDS and FreeSurfer"| node_staging
node_mriqc_participant -->|"stages BIDS"| node_staging
node_mriqc_group -->|"stages BIDS and reports"| node_staging
node_staging -->|"copies selected data"| node_bids_dataset
node_staging -->|"writes workspace"| node_scratch
node_freesurfer -->|"selects T1w"| node_bids_dataset
node_freesurfer -->|"writes reconstructions"| node_derivatives
node_container_jobs -->|"publishes outputs"| node_derivatives
node_container_jobs -->|"uses work area"| node_scratch

click node_cli "https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/cli.py"
click node_config "https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/config.py"
click node_selection "https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/cli.py"
click node_freesurfer "https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/freesurfer.py"
click node_fmriprep "https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/nipreps.py"
click node_mriqc_participant "https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/nipreps.py"
click node_mriqc_group "https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/nipreps.py"
click node_staging "https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/staging.py"
click node_container_jobs "https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/nipreps.py"
click node_container_runtime "https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/containers.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_cli,node_config,node_selection,node_user toneBlue
class node_freesurfer,node_fmriprep,node_mriqc_participant,node_mriqc_group toneAmber
class node_staging,node_container_jobs,node_container_runtime toneMint
class node_bids_dataset,node_derivatives,node_scratch toneRose
class node_project_yaml,node_freesurfer_tool,node_docker toneIndigo
```

## Components

### CLI and configuration

- [Command entry](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/cli.py): `neuro_utils/cli.py`
- [Project config](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/config.py): `neuro_utils/config.py`
- [Subject selection](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/cli.py): `neuro_utils/cli.py`

### Processing workflows

- [FreeSurfer workflow](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/freesurfer.py): `neuro_utils/freesurfer.py`
- [fMRIPrep workflow](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/nipreps.py): `neuro_utils/nipreps.py`
- [MRIQC participant](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/nipreps.py): `neuro_utils/nipreps.py`
- [MRIQC group](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/nipreps.py): `neuro_utils/nipreps.py`

### Execution and staging

- [BIDS staging](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/staging.py): `neuro_utils/staging.py`
- [Container jobs](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/nipreps.py): `neuro_utils/nipreps.py`
- [Docker commands](https://github.com/floristijhuis/neuro-utils/blob/main/neuro_utils/containers.py): `neuro_utils/containers.py`

### Dataset locations

- **BIDS dataset**
- **Derivatives**
- **Scratch workspace**

### Other components

- **CLI user**
- **Project YAML**
- **recon-all**
- **Docker daemon**

## Connections

- CLI user → Command entry: runs command (evidence: `README.md`)
- Command entry → Project config: loads YAML (evidence: `neuro_utils/cli.py`)
- Project YAML → Project config: configures project (evidence: `README.md`)
- Command entry → Subject selection: resolves subjects (evidence: `neuro_utils/cli.py`)
- Subject selection → BIDS dataset: lists subjects (evidence: `neuro_utils/cli.py`)
- Command entry → FreeSurfer workflow: dispatches (evidence: `neuro_utils/cli.py`)
- Command entry → fMRIPrep workflow: dispatches (evidence: `neuro_utils/cli.py`)
- Command entry → MRIQC participant: dispatches (evidence: `neuro_utils/cli.py`)
- Command entry → MRIQC group: dispatches (evidence: `neuro_utils/cli.py`)
- FreeSurfer workflow → recon-all: runs recon-all (evidence: `neuro_utils/freesurfer.py`)
- FreeSurfer workflow → BIDS staging: copies outputs (evidence: `neuro_utils/freesurfer.py`)
- fMRIPrep workflow → Container jobs: prepares job (evidence: `neuro_utils/nipreps.py`)
- MRIQC participant → Container jobs: prepares job (evidence: `neuro_utils/nipreps.py`)
- MRIQC group → Container jobs: prepares job (evidence: `neuro_utils/nipreps.py`)
- Container jobs → Docker commands: builds and runs (evidence: `neuro_utils/nipreps.py`)
- Docker commands → Docker daemon: invokes Docker (evidence: `neuro_utils/containers.py`)
- fMRIPrep workflow → BIDS staging: stages BIDS and FreeSurfer (evidence: `neuro_utils/nipreps.py`)
- MRIQC participant → BIDS staging: stages BIDS (evidence: `neuro_utils/nipreps.py`)
- MRIQC group → BIDS staging: stages BIDS and reports (evidence: `neuro_utils/nipreps.py`)
- BIDS staging → BIDS dataset: copies selected data (evidence: `neuro_utils/staging.py`)
- BIDS staging → Scratch workspace: writes workspace (evidence: `neuro_utils/staging.py`)
- FreeSurfer workflow → BIDS dataset: selects T1w (evidence: `neuro_utils/freesurfer.py`)
- FreeSurfer workflow → Derivatives: writes reconstructions (evidence: `neuro_utils/freesurfer.py`)
- Container jobs → Derivatives: publishes outputs (evidence: `neuro_utils/nipreps.py`)
- Container jobs → Scratch workspace: uses work area (evidence: `neuro_utils/nipreps.py`)
