Subsystems
This page describes the two most complex subsystems: habitat analysis and machine learning. Preprocessing and DICOM sorting use simpler structures; see Code Map.
Habitat analysis
Habitat analysis aggregates voxel-level image features into spatially
coherent tumor subregions. HabitatAnalysis organizes the work as a
pipeline of steps and services.
Directory |
Responsibility |
|---|---|
|
K-means, GMM, SLIC, and cluster-count validation. |
|
Voxel and supervoxel feature extractors. |
|
DataFrame normalization and feature filtering. |
|
Post-segmentation radiomics, MSI, ITH, and related features. |
|
Pipeline definitions and step implementations. |
|
Feature, clustering, habitat-map, and result services. |
|
Subject-level training checkpoints. |
Clustering strategies
The habitat_segmentation.clustering_mode setting selects one of three
pipeline recipes:
``two_step`` first clusters voxels into subject-level supervoxels and then clusters pooled supervoxels into habitats.
``one_step`` clusters each subject’s voxels directly into habitats.
``direct_pooling`` pools voxels across subjects and performs one clustering operation.
Training and prediction
Train builds and fits a
HabitatPipelineand serializes it tohabitat_pipeline.pkl.Predict loads the pipeline, injects approved services, and transforms new subjects with the same fitted state.
Resume uses subject-level checkpoints for interrupted large cohorts.
After habitat maps are generated, habit extract uses
HabitatMapAnalyzer for downstream features and habit radiomics uses
TraditionalRadiomicsExtractor.
Machine learning
The machine-learning subsystem assembles feature tables, splits data, builds an sklearn pipeline, trains and evaluates models, and writes reports.
Module |
Responsibility |
|---|---|
|
Load tables, merge data, and split train/test sets. |
|
Build selector, scaler, resampler, and model pipelines. |
|
Base models, factory registration, and model implementations. |
|
Registered selectors and ICC/retest analysis. |
|
High-level holdout, K-fold, and model-comparison workflows. |
|
Concrete training and inference execution. |
|
Immutable workflow plans and structured results. |
|
Metrics, thresholds, prediction containers, and evaluation. |
|
Reports and English-labeled ROC, calibration, DCA, and KM plots. |
|
DeLong, Hosmer-Lemeshow, and Spiegelhalter-Z tests. |
|
Over-sampling, under-sampling, and SMOTE. |
Execution flow
flowchart TD
C["Validated MLConfig"] --> W["Workflow.run()"]
W --> P["WorkflowPlan"]
P --> R["Runner"]
R --> D["DataManager"]
D --> B["PipelineBuilder"]
B --> F["Fit and evaluate"]
F --> O["Structured result and report"]
The single sklearn Pipeline is fitted only on training data in each fold, which prevents leakage and keeps training and evaluation behavior consistent.