# adigoryl/spectraflow architecture

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

- Interactive diagram: https://gitdiagram.com/adigoryl/spectraflow
- Repository: https://github.com/adigoryl/spectraflow

## Overview

SpectraFlow is a 1D NMR feature-selection and classification research framework. The documented workflow preprocesses spectra through wavelet denoising and PCA binning, then runs cross-validated feature selection and model evaluation, producing selected-feature and learning-progress visualizations. The repository also contains reconstruction and parallel experiment runners. Several links rely on the SOURCE INDEX or README rather than complete source excerpts, so uncertain internal sequencing is omitted.

Main entry points: [`pipeline/parallel_spectraflow.py`](https://github.com/adigoryl/spectraflow/blob/main/pipeline/parallel_spectraflow.py) (Parallel runner), [`preprocessing/preprocess_control.py`](https://github.com/adigoryl/spectraflow/blob/main/preprocessing/preprocess_control.py) (Preprocess control), [`models/MLPSequentialAttention.py`](https://github.com/adigoryl/spectraflow/blob/main/models/MLPSequentialAttention.py) (Attention MLP), [`pipeline/spectraflow_reconstruction.py`](https://github.com/adigoryl/spectraflow/blob/main/pipeline/spectraflow_reconstruction.py) (Reconstruction runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Spectra preprocessing"]
  node_raw_spectra["Raw spectra<br/>[CPMG.csv]"]
  node_denoising["Wavelet denoising<br/>[WaveletDenoise.py]"]
  node_binning["PCA binning<br/>[PCABinning.py]"]
  node_preprocess_control["Preprocess control"]
  node_prepared_data["Prepared spectra"]
end

subgraph group_experiments["Experiment workflows"]
  node_data_handler["Fold preparation<br/>[DataHandler.py]"]
  node_parallel_runner["Parallel runner"]
  node_spectraflow_runner["SpectraFlow runner<br/>[spectraflow.py]"]
  node_reconstruction_runner["Reconstruction runner"]
end

subgraph group_learning["Selection and models"]
  node_feature_selector["Feature selector<br/>[FeatureSelector.py]"]
  node_loorfe["LOORFE elimination<br/>[LOORFE.py]"]
  node_attention_model["Attention MLP"]
  node_attention["Sequential attention"]
  node_base_mlp["Base MLP<br/>[MLP.py]"]
  node_eval_mlp["Evaluation MLP<br/>[MLPEval.py]"]
  node_legacy_models["Legacy selectors<br/>[mlp_sparse.py]"]
end

subgraph group_outputs["Evaluation and views"]
  node_learning_plot["Learning progress plots<br/>[live_learning.py]"]
  node_ppm_plot["Selected-feature spectra<br/>[ppm_selected.py]"]
  node_general_plots["Analysis plots<br/>[plots.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"runs preprocessing"| node_preprocess_control
node_researcher -->|"runs analysis"| node_parallel_runner
node_raw_spectra -.->|"provides spectra"| node_preprocess_control
node_preprocess_control -->|"applies denoising"| node_denoising
node_preprocess_control -->|"applies binning"| node_binning
node_preprocess_control -.->|"writes processed data"| node_prepared_data
node_parallel_runner -->|"prepares folds"| node_data_handler
node_data_handler -->|"reads CSV data"| node_prepared_data
node_parallel_runner -->|"runs selection"| node_feature_selector
node_parallel_runner -->|"evaluates models"| node_eval_mlp
node_parallel_runner -->|"uses selection model"| node_attention_model
node_parallel_runner -->|"runs elimination"| node_loorfe
node_parallel_runner -->|"plots selected features"| node_ppm_plot
node_spectraflow_runner -->|"uses selection model"| node_attention_model
node_spectraflow_runner -->|"supports legacy selector"| node_legacy_models
node_reconstruction_runner -->|"uses selection model"| node_attention_model
node_reconstruction_runner -->|"evaluates model"| node_eval_mlp
node_reconstruction_runner -->|"plots training progress"| node_learning_plot
node_reconstruction_runner -->|"plots selected features"| node_ppm_plot
node_attention_model -->|"weights features"| node_attention
node_attention_model -->|"inherits from"| node_base_mlp
node_feature_selector -->|"uses callback"| node_learning_plot
node_loorfe -->|"uses callback"| node_learning_plot

click node_raw_spectra "https://github.com/adigoryl/spectraflow/blob/main/datasets/vasoplegia/CPMG.csv"
click node_denoising "https://github.com/adigoryl/spectraflow/blob/main/preprocessing/WaveletDenoise.py"
click node_binning "https://github.com/adigoryl/spectraflow/blob/main/preprocessing/PCABinning.py"
click node_preprocess_control "https://github.com/adigoryl/spectraflow/blob/main/preprocessing/preprocess_control.py"
click node_prepared_data "https://github.com/adigoryl/spectraflow/blob/main/datasets/vasoplegia/preprocessed/cpmg_db1__bin005_overlap0025.csv"
click node_data_handler "https://github.com/adigoryl/spectraflow/blob/main/pipeline/DataHandler.py"
click node_parallel_runner "https://github.com/adigoryl/spectraflow/blob/main/pipeline/parallel_spectraflow.py"
click node_spectraflow_runner "https://github.com/adigoryl/spectraflow/blob/main/pipeline/spectraflow.py"
click node_reconstruction_runner "https://github.com/adigoryl/spectraflow/blob/main/pipeline/spectraflow_reconstruction.py"
click node_feature_selector "https://github.com/adigoryl/spectraflow/blob/main/pipeline/FeatureSelector.py"
click node_loorfe "https://github.com/adigoryl/spectraflow/blob/main/pipeline/LOORFE.py"
click node_attention_model "https://github.com/adigoryl/spectraflow/blob/main/models/MLPSequentialAttention.py"
click node_attention "https://github.com/adigoryl/spectraflow/blob/main/models/SequentialAttention.py"
click node_base_mlp "https://github.com/adigoryl/spectraflow/blob/main/models/MLP.py"
click node_eval_mlp "https://github.com/adigoryl/spectraflow/blob/main/models/MLPEval.py"
click node_legacy_models "https://github.com/adigoryl/spectraflow/blob/main/models/old_models/mlp_sparse.py"
click node_learning_plot "https://github.com/adigoryl/spectraflow/blob/main/plots/live_learning.py"
click node_ppm_plot "https://github.com/adigoryl/spectraflow/blob/main/plots/ppm_selected.py"
click node_general_plots "https://github.com/adigoryl/spectraflow/blob/main/plots/plots.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_raw_spectra,node_denoising,node_binning,node_preprocess_control,node_prepared_data toneBlue
class node_data_handler,node_parallel_runner,node_spectraflow_runner,node_reconstruction_runner toneAmber
class node_feature_selector,node_loorfe,node_attention_model,node_attention,node_base_mlp,node_eval_mlp,node_legacy_models toneMint
class node_learning_plot,node_ppm_plot,node_general_plots toneRose
class node_researcher toneIndigo
```

## Components

### Spectra preprocessing

- [Raw spectra](https://github.com/adigoryl/spectraflow/blob/main/datasets/vasoplegia/CPMG.csv): `datasets/vasoplegia/CPMG.csv`
- [Wavelet denoising](https://github.com/adigoryl/spectraflow/blob/main/preprocessing/WaveletDenoise.py): `preprocessing/WaveletDenoise.py`
- [PCA binning](https://github.com/adigoryl/spectraflow/blob/main/preprocessing/PCABinning.py): `preprocessing/PCABinning.py`
- [Preprocess control](https://github.com/adigoryl/spectraflow/blob/main/preprocessing/preprocess_control.py): `preprocessing/preprocess_control.py`
- [Prepared spectra](https://github.com/adigoryl/spectraflow/blob/main/datasets/vasoplegia/preprocessed/cpmg_db1__bin005_overlap0025.csv): `datasets/vasoplegia/preprocessed/cpmg_db1__bin005_overlap0025.csv`

### Experiment workflows

- [Fold preparation](https://github.com/adigoryl/spectraflow/blob/main/pipeline/DataHandler.py): `pipeline/DataHandler.py`
- [Parallel runner](https://github.com/adigoryl/spectraflow/blob/main/pipeline/parallel_spectraflow.py): `pipeline/parallel_spectraflow.py`
- [SpectraFlow runner](https://github.com/adigoryl/spectraflow/blob/main/pipeline/spectraflow.py): `pipeline/spectraflow.py`
- [Reconstruction runner](https://github.com/adigoryl/spectraflow/blob/main/pipeline/spectraflow_reconstruction.py): `pipeline/spectraflow_reconstruction.py`

### Selection and models

- [Feature selector](https://github.com/adigoryl/spectraflow/blob/main/pipeline/FeatureSelector.py): `pipeline/FeatureSelector.py`
- [LOORFE elimination](https://github.com/adigoryl/spectraflow/blob/main/pipeline/LOORFE.py): `pipeline/LOORFE.py`
- [Attention MLP](https://github.com/adigoryl/spectraflow/blob/main/models/MLPSequentialAttention.py): `models/MLPSequentialAttention.py`
- [Sequential attention](https://github.com/adigoryl/spectraflow/blob/main/models/SequentialAttention.py): `models/SequentialAttention.py`
- [Base MLP](https://github.com/adigoryl/spectraflow/blob/main/models/MLP.py): `models/MLP.py`
- [Evaluation MLP](https://github.com/adigoryl/spectraflow/blob/main/models/MLPEval.py): `models/MLPEval.py`
- [Legacy selectors](https://github.com/adigoryl/spectraflow/blob/main/models/old_models/mlp_sparse.py): `models/old_models/mlp_sparse.py`

### Evaluation and views

- [Learning progress plots](https://github.com/adigoryl/spectraflow/blob/main/plots/live_learning.py): `plots/live_learning.py`
- [Selected-feature spectra](https://github.com/adigoryl/spectraflow/blob/main/plots/ppm_selected.py): `plots/ppm_selected.py`
- [Analysis plots](https://github.com/adigoryl/spectraflow/blob/main/plots/plots.py): `plots/plots.py`

### Other components

- **Researcher**

## Connections

- Researcher → Preprocess control: runs preprocessing (evidence: `README.md`)
- Researcher → Parallel runner: runs analysis (evidence: `README.md`)
- Raw spectra → Preprocess control: provides spectra
- Preprocess control → Wavelet denoising: applies denoising (evidence: `preprocessing/preprocess_control.py`)
- Preprocess control → PCA binning: applies binning (evidence: `preprocessing/preprocess_control.py`)
- Preprocess control → Prepared spectra: writes processed data
- Parallel runner → Fold preparation: prepares folds (evidence: `pipeline/parallel_spectraflow.py`)
- Fold preparation → Prepared spectra: reads CSV data (evidence: `pipeline/DataHandler.py`)
- Parallel runner → Feature selector: runs selection (evidence: `pipeline/parallel_spectraflow.py`)
- Parallel runner → Evaluation MLP: evaluates models (evidence: `pipeline/parallel_spectraflow.py`)
- Parallel runner → Attention MLP: uses selection model (evidence: `pipeline/parallel_spectraflow.py`)
- Parallel runner → LOORFE elimination: runs elimination (evidence: `pipeline/parallel_spectraflow.py`)
- Parallel runner → Selected-feature spectra: plots selected features (evidence: `pipeline/parallel_spectraflow.py`)
- SpectraFlow runner → Attention MLP: uses selection model (evidence: `pipeline/spectraflow.py`)
- SpectraFlow runner → Legacy selectors: supports legacy selector (evidence: `pipeline/spectraflow.py`)
- Reconstruction runner → Attention MLP: uses selection model (evidence: `pipeline/spectraflow_reconstruction.py`)
- Reconstruction runner → Evaluation MLP: evaluates model (evidence: `pipeline/spectraflow_reconstruction.py`)
- Reconstruction runner → Learning progress plots: plots training progress (evidence: `pipeline/spectraflow_reconstruction.py`)
- Reconstruction runner → Selected-feature spectra: plots selected features (evidence: `pipeline/spectraflow_reconstruction.py`)
- Attention MLP → Sequential attention: weights features (evidence: `models/MLPSequentialAttention.py`)
- Attention MLP → Base MLP: inherits from (evidence: `models/MLPSequentialAttention.py`)
- Feature selector → Learning progress plots: uses callback (evidence: `pipeline/FeatureSelector.py`)
- LOORFE elimination → Learning progress plots: uses callback (evidence: `pipeline/LOORFE.py`)
