F7b: ADOS-2 association as library 0.4.0 with the accepted spike tests

The 33 zone x item spike pairs could not be estimated with about 46
children. The four spike tests accepted before seeing the ADOS-2 replace
them: any zone with the total CSS (repetitive behaviours and social affect
are one pair until the hospital sends CSS by domain), left with items 1 and
18, right with items 4, 5 and 7, and central with item 21 as exploratory.
The predictor is any useful spike in NREM on the group's electrodes.

Item altered from 2, CSS high from 8, at least 5 children with and without
the event, q within each biomarker without the exploratory pair, one CSS
family adjusted by age and module, no z clipping. The settings are module
constants; each fit saves them with its pairs, and a model without them is
refused. score() leaves each fitted child out. Keys are stored hashed.
This commit is contained in:
2026-12-03 22:27:11 -06:00
parent 920003c5d4
commit aab20683aa
4 changed files with 573 additions and 153 deletions
+34
View File
@@ -1,3 +1,4 @@
import json
from datetime import date
from types import SimpleNamespace
@@ -6,6 +7,7 @@ import pandas as pd
import pytest
from pydantic import ValidationError
from core.tea import ADOS2_ITEMS
from models.definitions import ScopeConfig, after_ingest
from models.tea import jobs
from models.tea.eeg import curves
@@ -45,6 +47,38 @@ def test_the_domain_routine_scores_the_curves_then_relates_the_association():
assert JOBS.routine() == [*MODELS, ASSOCIATION]
def test_the_association_cohort_takes_spikes_as_yes_or_no(monkeypatch):
def study(child, day, features):
return {
**dict.fromkeys(ADOS2_ITEMS),
"person_id": child,
"study_date": day,
"edf": f"{child}-{day}",
"age_months": 24.0,
"module": "toddler",
"evaluation_date": None,
"birth_date": None,
"language_level": None,
"features": json.dumps(features),
}
spikes = {"eeg-spikes": {"minutes": 10.0, "electrode_F8": 0.2, "electrode_C3": 0.0}}
studies = [study("one", "2025-01-01", spikes), study("two", "2025-01-01", {})]
scores = [
{"edf": "one-2025-01-01", "metric": metric, "part": "zones", "site": "central", "z": 1.5}
for metric in ("paroxysmal_spikes", "spindles")
]
monkeypatch.setattr(eeg, "association_cohort_rows", lambda: (studies, scores))
fit, scored = jobs.cohort()
assert list(fit.child) == ["one"]
assert list(scored.child) == ["one", "two"]
assert [c for c in scored.columns if c.startswith("z_")] == ["z_spindles_central"]
found = fit.iloc[0]
assert (found.spikes_any_any, found.spikes_any_right, found.spikes_any_central) == (1, 1, 0)
assert pd.isna(found.spikes_any_left)
assert scored.iloc[1].filter(like="spikes_any_").isna().all()
def test_after_ingest_requests_a_run_only_with_pending_eegs():
skip = after_ingest("r1", lambda: False)
assert isinstance(skip, dg.SkipReason)