In Silico · system structure
Clinical Decision Support Software Architecture
Two engines that assist a clinician without deciding for them: adaptive difficulty control for cognitive training, and dementia risk stratification from MRI and speech.
What this work is
Design specifications and a standard-library Python reference harness for two pieces of dementia software. Unit N1 sets the difficulty of each cognitive-training trial for a patient; it makes no clinical judgement and flags patients whose ability falls outside the difficulty range for clinician review. Unit N2 turns already-extracted brain MRI and speech features into a research-use risk stratification score that assists a clinician's reading; no output state is a diagnosis and every state assumes clinician review.
Scope Both units run only on synthetic cohorts that the code generates from two frozen fixtures; no raw data or summary statistics from ADNI, OASIS-3 or DementiaBank are read. The results are therefore virtual metrics under the fixtures' assumptions: they show whether the pipeline behaves as designed, not real-cohort performance, and no clinical evaluation is included.
N1 · Synthetic harness · cog16
Adaptive cognitive-training difficulty control engine
Chooses the difficulty of each training trial so that a patient's success probability settles in a target band while runs of consecutive errors stay under a limit, and checks on a virtual cohort whether that policy converges. It changes difficulty only; it makes no diagnosis or medication judgement and claims no therapeutic effect.
- Virtual patient samplerFixture stratum parameters and a patient seed → One patient's fixed parameter set
- Virtual patient response generatorTask, difficulty lattice point, trial index → Scored result, log latency, timeout flag, true success probability
- State estimatorScored result, log latency, timeout flag, trial context → State mean and covariance, fatigue-regime probability
- Safe bandit control and state machineFilter estimates, task, trial index, current error run → State code and next difficulty lattice point, or a session halt
- Independent safety monitorPresented lattice point, returned state code, scored result → Violation count recorded in the evidence document
- Convergence judgePer-trial true success probabilities, scored results, session breaks → Per-patient verdict: converged, error-run limit kept
- Cohort Monte Carlo and gatesFrozen fixture and its seeds → N1 block of the evidence document
- Independent auditorEvidence document and the frozen fixtures → Audit document with gate status and hashes
| Component | What it does | Input → output | Code |
|---|---|---|---|
| Virtual patient sampler | Draws one virtual patient's fixed parameters (abilities, knob sensitivities, fatigue, practice, latency) from the fixture's stratum settings with a seeded generator. | Fixture stratum parameters and a patient seed → One patient's fixed parameter set | cog16/ |
| Virtual patient response generator | For a presented difficulty level, simulates one trial with a multidimensional item-response model that includes practice, fatigue, time-of-day and latency terms. | Task, difficulty lattice point, trial index → Scored result, log latency, timeout flag, true success probability | cog16/ |
| State estimator | Updates three filters from each observation: an extended Kalman filter for ability and knob sensitivity, a latency-baseline filter, and a two-state fatigue-regime filter. | Scored result, log latency, timeout flag, trial context → State mean and covariance, fatigue-regime probability | cog16/ |
| Safe bandit control and state machine | Among moves the slew limit allows, keeps lattice points whose pessimistic success probability clears the floor, minimises a tracking loss, and sets the machine state. | Filter estimates, task, trial index, current error run → State code and next difficulty lattice point, or a session halt | cog16/ |
| Independent safety monitor | Inside the trial loop, checks every presented level against four invariants from the lattice points and scored results, without reading the scheduler's estimates. | Presented lattice point, returned state code, scored result → Violation count recorded in the evidence document | cog16/ |
| Convergence judge | Applies the entry-and-hold definition to one patient's trajectory: settling time within the deadline, per-trial deviation, exposure, and the consecutive-error rate. | Per-trial true success probabilities, scored results, session breaks → Per-patient verdict: converged, error-run limit kept | cog16/ |
| Cohort Monte Carlo and gates | Runs the primary cohort, replicates, baseline policies, distribution-shift scenarios, fault injection and protocol cases, then aggregates rates, bounds and gate flags. | Frozen fixture and its seeds → N1 block of the evidence document | cog16/ |
| Independent auditor | Without importing the solver, re-aggregates per-patient rows, rechecks exact bounds in integer arithmetic, re-derives protocol-case verdicts, and decides four gates. | Evidence document and the frozen fixtures → Audit document with gate status and hashes | cog16/ |
Flow
- The runner loads the frozen fixture, checks its lock hash, and draws each virtual patient's fixed parameters from seeds derived from the fixture.
- At each trial the scheduler picks a difficulty lattice point for the current task from the allowed moves, inserts an unscored assisted trial, or halts the session.
- The monitor checks the chosen level against its invariants, and the response generator returns a scored result, a log latency and a timeout flag.
- The scheduler updates its ability, latency and fatigue-regime estimates from those three observations; it never reads the generator's internals.
- After the last session the judge applies the convergence and consecutive-error definitions, once to the true probability and once to the scheduler's own prediction.
- The cohort run aggregates patient verdicts into rates, exact binomial bounds and gate flags, and the runner writes them with a hash into one evidence document.
- The auditor recomputes the claimed figures from that document without the solver code and writes an audit document that passes or names the first failed gate.
What is guarded
- Constrained moves: right after an error no difficulty knob may rise, upward steps are capped per trial, and a candidate is allowed only if its pessimistic success probability clears a floor that rises with the error run. If no candidate qualifies, the easiest one is forced (EASE_FORCED).
- Fail-safe states: an unscored assisted trial when the error run reaches its cap (SUPPORT), a session stop on sustained fatigue (HALT_FATIGUE) or when the easiest level is still too hard (HALT_RANGE_FLOOR), and a switch to a model-free staircase when the filter faults numerically (FALLBACK).
- Independent monitor: four invariants (levels inside the lattice, bounded upward moves, no rise right after an error, capped run of scored errors) are checked on every trial, and the violation count must be zero for the gate and for the audit.
- No invented convergence: a patient whose ability lies outside the difficulty range gets a range-saturation flag for clinician review and is counted as not converged; two fixed protocol cases must produce exactly that verdict.
- Frozen inputs and output form: the run is rejected if the fixture lock hash (SHA-256) differs or if any string in the evidence is free text rather than a code token. A check mode re-runs and compares the document byte for byte.
- Independent audit: the auditor shares only the serialisation and hash helpers and the fixtures with the runner. A failed gate stops the audit there, sets auditStatus to fail and leaves later gates as not_run.
Not built or not run
- The PyTorch batch interface (a vectorised cohort environment and scheduler) is a specification only. It was not run, and its equivalence test against the reference implementation was not done.
- Importing real summary statistics from ADNI and DementiaBank into the fixture is written as a procedure and has not been carried out. The fatigue, time-of-day and lapse parameters remain assumptions.
- A test with a response generator whose functional form differs from the policy's internal model. The distribution-shift runs move parameters only, so this mismatch was not measured.
- Estimator extensions the specification lists as absent: following abrupt changes without a false-alarm cost (the detector exists only as the VAR_CHANGE_DETECT variant, off in the primary policy), using latency in ability estimation, and graded-response items.
- The auditor does not re-run the cohort simulation. Replicate, distribution-shift and baseline runs carry no per-patient rows in the evidence, so their success counts are the runner's own tallies and the auditor rechecks only their bounds and gates.
Result and documents
In a synthetic virtual cohort of 1,000 patients, 962 (96.2%) settled in the 0.70–0.80 success-probability band within 4 sessions, stayed there and kept consecutive errors under the limit. The one-sided 95% lower bound is 0.9505; the internal target is 0.95.
Synthetic inputs only (synthetic_only). These are virtual metrics on synthetic cohorts. No ADNI, OASIS-3 or DementiaBank data were read, no real cohort has been evaluated, clinical validity has not been assessed and no auditor has signed the result.
Measured values, limits and gates on the N1 record · Difficulty Control for Adaptive Cognitive Training
N1 design specification: adaptive difficulty control engine (KR) · N1 and N2 replay record (KR) · N1 and N2 cross-model review log (KR) (KR) · Audit record (JSON) · Run output (JSON)
N2 · Synthetic harness · cog16
Multi-site MRI and speech fusion risk stratification
Produces a research-use dementia risk stratification score from already-extracted brain MRI features and de-identified speech features collected at different sites and devices, to assist a clinician's reading. It never issues a standalone diagnosis, and every output state assumes clinician review.
- Synthetic cohort builderFixture cohort, unit-effect and split settings → Subject rows with features, covariates, unit and split
- Manifest alignment auditManifest entries for every split in use → Violation codes; any code stops the run
- Site and device harmonisationRaw features, covariates, acquisition unit; calibration rows → Unit-corrected standardised residuals (the model input)
- Missing-modality fusion networkCorrected MRI and/or speech residual vectors → One logit and the fused representation
- Probability calibrationValidation-split logits and labels → Temperature per modality pattern; calibrated probability
- Fail-safe output routerCheck flags, age, feature deviation, probability, pair lag → One output state code
- Cross-cohort evaluation and gatesSynthetic cohorts and fixture evaluation settings → N2 block of the evidence document with per-case scores
- Independent auditorEvidence document and the frozen fixtures → Audit document with gate status and hashes
| Component | What it does | Input → output | Code |
|---|---|---|---|
| Synthetic cohort builder | Generates the synthetic imaging, speech and paired cohorts with site and device effects from the fixture, and assigns every subject to one split. | Fixture cohort, unit-effect and split settings → Subject rows with features, covariates, unit and split | cog16/ |
| Manifest alignment audit | Before fitting, checks the manifest of the splits in use for subjects shared across splits or sites, external units or sites in training, and mismatched pairs or masks. | Manifest entries for every split in use → Violation codes; any code stops the run | cog16/ |
| Site and device harmonisation | Fits a reference on cognitively normal training rows, converts features to covariate-adjusted residuals, and removes unit effects with shrunken ComBat estimates. | Raw features, covariates, acquisition unit; calibration rows → Unit-corrected standardised residuals (the model input) | cog16/ |
| Missing-modality fusion network | Encodes each modality that is present, weights it with a gate that also sees the other modality, and sums the gated vectors into one logit. Trained with modality dropout. | Corrected MRI and/or speech residual vectors → One logit and the fused representation | cog16/ |
| Probability calibration | Fits one temperature per modality pattern on the internal validation split only. An evidential head on the frozen fused vector outputs a probability and an uncertainty. | Validation-split logits and labels → Temperature per modality pattern; calibrated probability | cog16/ |
| Fail-safe output router | Assigns each case one of five output states in a fixed order: reject input, hold for an uncalibrated unit, abstain outside support, flag for review, or assistive report. | Check flags, age, feature deviation, probability, pair lag → One output state code | cog16/ |
| Cross-cohort evaluation and gates | Trains on one imaging cohort and evaluates on the other, both ways, with DeLong intervals, calibration error, matching, permutation and leak controls, then grades gates. | Synthetic cohorts and fixture evaluation settings → N2 block of the evidence document with per-case scores | cog16/ |
| Independent auditor | Without importing the solver, recomputes each gate AUROC and DeLong interval from per-case scores by the all-pairs definition, and re-derives calibration error and gates. | Evidence document and the frozen fixtures → Audit document with gate status and hashes | cog16/ |
Flow
- The harness checks the fixture, runs known-answer checks on its own metric code, and generates the synthetic cohorts with each subject assigned to one split.
- Before fitting, it audits the manifest of the splits in use and stops if any violation code appears.
- Harmonisation fits its reference on cognitively normal training rows and outputs unit-corrected residuals; units unseen in training are corrected from calibration rows.
- The fusion network is trained on image-only rows, speech-only rows and label-matched pseudo-pairs, and a temperature is fitted on the validation split.
- External test cases are scored under three unit-correction modes, and the default-mode scores are routed case by case to an output state code.
- Evaluation adds controls (covariate-only model, matching, label permutation, injected manifest faults), and gates are graded only if the checks and controls pass.
- The auditor recomputes the gate figures from the per-case scores in the evidence document by a different method and writes the audit document.
What is guarded
- Input boundary: the model input schema holds only already-extracted scalar features. The speech payload check (validate_speech_payload) refuses audio references, transcripts, frame-level sequences and speaker embeddings.
- Manifest audit before the run: a subject in more than one split or site, an external unit or site on the training side, a mismatched or out-of-window pair, or a mask without features stops the pipeline.
- Label separation: the reference is fitted on cognitively normal training rows only. Calibration-split labels are used only to pick normal reference rows, never for weights, thresholds or temperature, and the external test split enters no fitting step.
- Fail-closed routing: no output state means a diagnosis. An uncalibrated unit is held without a score, an out-of-support case abstains, and a borderline probability or a stale pair is flagged for review. The remaining state is an assistive report, which the specification marks as requiring clinician review.
- Gates tied to checks: gate values are read only when the known-answer checks, the permutation controls and the leak control all pass; otherwise every gate is reported as NOT_EVALUATED.
- Independent audit: the auditor recomputes the gate figures from per-case scores without the solver code and stops at the first failed gate, leaving auditStatus as fail.
Not built or not run
- Feature extraction from images and recordings (FreeSurfer-type segmentation, acoustic extractors) is an input contract only. The harness runs the steps after feature extraction.
- The PyTorch modules and domain-adversarial training are interface and formula only. The harness runs a reduced form with one token per modality and stops at the unit probe that decides whether the adversarial term would be switched on.
- Evaluation on the real ADNI, OASIS-3 and DementiaBank cohorts is a written procedure and has not been run. The combined MRI-and-speech evaluation ran only on synthetic pairs, because the public sources hold no MRI and speech from the same subject.
- The stages before the router that would derive its check flags from an incoming case (schema validation, unit-calibration lookup), and the rule that any exception or timeout closes to REJECT_INPUT, are specified only. In the cohort run those flags are passed in as fixed values.
- The auditor does not refit the model; it checks that the claims follow from the per-case scores. Runner and auditor run under the same file permissions, not in a blind environment, and there is no separate host or container run and no auditor signature.
Result and documents
On synthetic multi-site cohorts, the external AUROC for separating controls from MCI or dementia was 0.932 (DeLong 95% lower bound 0.909) on 540 held-out cases in one direction and 0.926 (0.905) on 560 in the other, with harmonisation referenced to control cases. The internal target is 0.90.
Synthetic inputs only (synthetic_only). These are virtual metrics on synthetic cohorts. No ADNI, OASIS-3 or DementiaBank data were read, no real cohort has been evaluated, clinical validity has not been assessed and no auditor has signed the result.
Measured values, limits and gates on the N2 record · Dementia Risk Stratification from Brain MRI and Speech
N2 design specification: multi-site MRI and speech fusion (KR) · N1 and N2 replay record (KR) · N1 and N2 cross-model review log (KR) (KR) · Audit record (JSON) · Run output (JSON)
How to read this screen
This screen describes structure: the parts, the order work passes through them and what each run is checked against. It carries no measured value of its own. The figure in each result paragraph is filled from the audit file when the site is built, and every component names the code that does the work.