Adds the only legitimate BBB <-> MRI bridge in the platform — researcher
lane only. Fusion engine still excludes BBB as a diagnostic modality.
Modules:
- src/models/bbb_permeability_map.py: scalar BBB leakage score in [0,1]
with two modes. heuristic_proxy (default) reuses the 2D resnet18
Alzheimer classifier and computes 1 - P(NonDemented). dce_onnx loads
a real 4D DCE-MRI ONNX model from BBB_PERMEABILITY_DCE_PATH and
averages a normalised Ktrans map; raises a clear FileNotFoundError
with contract documentation when no artifact exists.
- src/research/drug_dose_adjuster.py: pure-function dose revision keyed
on (BBB intact?, drug BBB-permeable?). Permeable drugs see an
aggressive linear cut floored at 30%; non-permeable drugs see a mild
cut floored at 60%; intact BBB returns baseline unchanged. Unknown
drug permeability is treated as permeable (safer). Rationale always
includes the 'research suggestion, not medical advice' disclaimer.
API:
- POST /predict/bbb_permea…
feat(eeg,frontend): EEG fusion-flow test + Streamlit EEG form + real-artifact sanity
- tests/fusion/test_eeg_modality_flow.py: end-to-end EEG -> fusion `eeg`
modality flow (alzheimers feature spike lifts AD score; control profile
doesn't inflate it).
- tests/models/test_eeg_model_real.py: skip-if-absent sanity for the real
EEG joblib; runs automatically once the file lands at the canonical path.
- src/frontend/app.py: doctor MRI tab grows an EEG predict form
(comma-separated features) calling POST /predict/eeg. 503 surfaces as a
human-readable warning instead of a stack trace.
feat(models): EEG classifier loader + predict (stub-able for hackathon demo)
- _compute_train_stats() captures median, std, n_train of the model's
own predict_proba on X_train. Joblib-roundtrip-safe.
- train() persists stats alongside _neurobridge_fp_cols and
_neurobridge_calibration. INFO log line now surfaces the median.
- Foundation for Day-7 T1B drift z-score in /predict/bbb.
- 2 new tests (TestTrainStatsMetadata): attribute presence + roundtrip.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
feat(models): calibration metadata — precision-at-threshold bins on _neurobridge_calibration
- train() does 80/20 stratified split, fits on train, computes 6
precision-at-confidence-threshold bins (0.50/0.60/0.70/0.75/0.80/0.90)
on the held-out test set, stashes the result on
model._neurobridge_calibration for the API to surface.
- Tiny-fixture fallback: ValueError on stratified split → train on full
data + emit zero-support bins.
- 3 new tests covering attribute presence, sorted thresholds, and
joblib roundtrip preservation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
feat(models): SHAP top-k explainer for BBB predictions