d8f34a77c1e136477ac01bd1215f9377c219cb2d
4 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f6a289e774 |
F7g: signal preparation as biomarcadores-tea (flat reference, symmetric Hann, mains, stable start, clamps)
Port the five F7f signal-preparation differences from biomarcadores-tea 23cafa4 and the read-only counterfactual source. Reference measurement retains exactly one flat scalp electrode in the original channel order and average reference, excluding it from QC. Patients default to dropping bad flat channels. Periodograms remove the mean and use symmetric Hann density. Preparation uses the requested mains frequency and raw-channel IIR notch QC. Stable start masks setup windows and limits fixed-line detection to the useful suffix. Sleep band sums recover the source FFT scale before applying clamps. Files changed (relative to the parent worktree): - models/models/tea/eeg/preprocess.py - models/models/tea/eeg/signals.py - models/models/tea/eeg/sleep.py - models/models/tea/eeg/analysis.py - models/models/tea/eeg/reference.py - models/models/tea/eeg/checks.py (coordinator-approved scope/signature) - models/tests/test_eeg.py Internal choices left open by the spec: - Keep the IIR implementation private as preprocess._iir_notch and the annotation word lists private as _START_MARKS and _SETUP_MARKS. Stack the Q=30 sections and filter finite runs through signals.by_runs with the counterfactual minimum length and harmonic enumeration. - Preserve the counterfactual flat predicate, not nanstd > 0.5, including its treatment of nonfinite standard deviations. Derive QC channels from raw scalp data excluding the retained flat electrode; filtering finite runs supplies the QC gap mask independently of that electrode. - Calculate the symmetric Hann once per periodograms call. For odd FFT lengths double the final bin, since it has no Nyquist bin; for even lengths exclude both DC and Nyquist from doubling. - Retain the exact stable-start finite-window count, median of channel standard deviations, second-half reference, suffix tolerance, sorted annotation precedence, accent removal and short-record return. Convert the selected annotation onset to a Python float. - Use int(start_s * fs) for the fixed-line suffix. At thirty seconds or less remaining, use the full signal, as the tested counterfactual does. - Add start_s to the existing rejected-minutes scalar dictionary after successful measurement. Recompute stable_start(rec) for reporting to keep Prepared's existing public shape. Invalid/error paths retain their existing result handling. - Extend the existing test_eeg.py with deterministic seeded synthetic arrays, direct NumPy spectra and SciPy IIR comparisons. Exercise odd and even spectra, a 60-second setup prefix with the source's 90-percent suffix rule, accented and unordered annotations, the thirty-second fixed-line boundary, small-power clamps and analysis/reference calls. No real-data fixture or source repository was modified. Validation from the parent worktree root with the requested shared venv: - ruff check: passed. - ruff format --check: passed, 152 files already formatted. - lint-imports --no-cache: passed, 2 contracts kept, 0 broken. - pytest -q -rs: 116 passed, 7 warnings, covering test_eeg, test_eeg_reasons, test_eeg_spikes, test_eeg_spindles, test_edf_header, test_tea_notes, test_tea_training_source, test_tea_preview, test_tea_job and test_curves. Run with flock /home/milk/tea-parity/heavy.lock nice -n 10 and worktree package roots on PYTHONPATH. - git diff --check in models and the parent: passed. All specified checks completed. Helsinki reference remeasurement is a follow-up after the port, not part of this synthetic-array implementation. |
||
|
|
3a409afcaa |
F2b: No evaluable carries the reason ported from the tea library
Study level: Validation.reasons, built from the three gates that decide validity (triage-not-analyzable, few-clean-minutes, few-electrodes; the library's run_study reasons plus its usable-electrode gate) and invalid-file for an unreadable file. Analysis.reasons sits next to valid, level and clean_fraction. Window level: the spike detector's 2 s gate now records every reason a window is rejected (gap, state, mixed-states, muscle, frozen) and the minutes rejected by each, kept in Spikes.rejected. A window can count under more than one reason, as in the library. The platform has no transient rejection, so there is no transient reason. Metric level: biomarkers.measure returns a Measured result with the reason per unmeasured metric: few-wake-windows and no-dominant-peak (posterior rhythm), no-n2 and no-n3 (under one minute of the stage or no events), no-sleep and few-electrodes (gradient, spikes). A study that is not valid now returns its five metrics with no value, each carrying invalid-eeg. Curve scoring returns a reason next to z: no-age, age-out-of-range and no-exposure, because only scoring knows the baseline's age coverage. The reasons and the rejected minutes travel in the features JSON under metric-reasons and rejected-minutes, outside the scenario keys so the reference tables and curve training do not see them. |
||
|
|
c1a1e294dc |
The suite keeps only logic tests
Keep deterministic model, signal, DSL and SQLite storage checks. Checks: ruff check, ruff format --check, lint-imports (two contracts kept), and pytest (115 passed, 7 warnings in 42.52s). removed models/tests/test_bundle.py::test_guard_runs_on_export_and_on_import — implementation-detail removed models/tests/test_cacu_models.py — parity-only removed models/tests/test_cacu_models.py::test_predictions_match_the_current_models — parity-only removed models/tests/test_cacu_models.py::test_survival_matches_the_current_model_with_its_index_fixed — parity-only removed models/tests/test_cacu_models.py::test_a_cohort_the_site_lacks_is_reported_not_trained — implementation-detail removed models/tests/test_cama_models.py — parity-only removed models/tests/test_cama_models.py::test_survival_matches_the_current_model — parity-only removed models/tests/test_edf_node.py — slow integration (logic now covered by test_header_reads_the_facts, test_not_an_edf_is_not_valid and test_collected_files_are_kept_once_by_content) removed models/tests/test_edf_node.py::test_edf_pipeline_keeps_and_links_the_files — slow integration (logic now covered by test_header_reads_the_facts, test_not_an_edf_is_not_valid and test_collected_files_are_kept_once_by_content) removed models/tests/test_edf_upload.py — slow integration (logic now covered by test_tea_eeg_first_n_selects_exactly_n_pending_studies for study selection) removed models/tests/test_edf_upload.py::test_an_uploaded_edf_is_analysed_by_itself — slow integration (logic now covered by test_tea_eeg_first_n_selects_exactly_n_pending_studies for study selection) removed models/tests/test_eeg.py::test_verdicts_and_checks — parity-only removed models/tests/test_eeg.py::test_metric_values — parity-only removed models/tests/test_eeg.py::test_reference_features — parity-only removed models/tests/test_eeg.py::test_curves — parity-only removed models/tests/test_execution.py::test_map_empty_items_starts_nothing — implementation-detail removed models/tests/test_execution.py::test_map_local_equals_sync — slow integration (logic now covered by test_map_sync_keeps_input_order_and_reports_each_item) removed models/tests/test_execution.py::test_map_lazy_items_are_not_all_loaded_at_once — implementation-detail removed models/tests/test_execution.py::test_progress_tag_and_log_lines_inside_running — implementation-detail removed models/tests/test_execution.py::test_no_tag_outside_running — implementation-detail removed models/tests/test_execution.py::test_version_mismatch_fails_before_any_task — implementation-detail removed models/tests/test_execution.py::test_local_cancel_leaves_no_worker_processes — slow integration (logic now covered by test_cancel_returns_the_terminal_or_cancelling_state for cancellation states) removed models/tests/test_execution.py::test_health_sync_and_local — slow integration (logic now covered by test_resolve_defaults_and_allow_list for execution defaults) removed models/tests/test_execution.py::test_health_unreachable_remote — slow integration (logic now covered by test_resolve_rejects_unlisted_scheduler_and_scheduler_in_local_mode for scheduler validation) removed models/tests/test_execution.py::test_health_rejects_unlisted_scheduler — implementation-detail removed models/tests/test_execution.py::test_progress_reaches_the_dagster_run — slow integration (logic now covered by test_shape_progress_tag and test_map_sync_keeps_input_order_and_reports_each_item) removed models/tests/test_execution.py::test_map_remote_equals_sync — slow integration (logic now covered by test_map_sync_keeps_input_order_and_reports_each_item) removed models/tests/test_execution.py::test_health_remote — slow integration (logic now covered by test_resolve_defaults_and_allow_list for remote execution choice) removed models/tests/test_execution.py::test_remote_cancel_cancels_futures — slow integration (logic now covered by test_cancel_returns_the_terminal_or_cancelling_state for cancellation states) removed models/tests/test_execution.py::test_progress_json_is_stable — implementation-detail removed models/tests/test_execution.py::test_map_on_error_converts_a_failed_item[local] — slow integration (logic now covered by test_map_on_error_converts_a_failed_item) removed models/tests/test_execution.py::test_map_raises_without_on_error[local] — slow integration (logic now covered by test_map_raises_without_on_error) removed models/tests/test_ingest.py — slow integration (logic now covered by test_collected_files_are_kept_once_by_content and test_the_drawn_patterns_read_every_report) removed models/tests/test_ingest.py::test_a_site_reaches_bronze_once_and_its_documents_are_read — slow integration (logic now covered by test_collected_files_are_kept_once_by_content and test_the_drawn_patterns_read_every_report) removed models/tests/test_recurrence.py::test_cohorts — parity-only removed models/tests/test_recurrence.py::test_routines — parity-only removed models/tests/test_recurrence.py::test_c_index_and_internal_auc — parity-only removed models/tests/test_recurrence.py::test_saved_model — parity-only removed models/tests/test_recurrence.py::test_calculator — parity-only removed models/tests/test_recurrence.py::test_risk_factors — parity-only removed models/tests/test_recurrence.py::test_train_reproduces_v1 — parity-only removed models/tests/test_silver.py::test_a_site_becomes_silver_and_review_gets_the_rest — slow integration (logic now covered by test_person_ids_survive_a_review_merge_and_split and test_a_code_nobody_mapped_is_held_with_the_reason) removed models/tests/test_survival_seer.py — parity-only removed models/tests/test_survival_seer.py::test_each_scenario_takes_the_originals_patients_and_deaths — parity-only removed models/tests/test_survival_seer.py::test_each_scenarios_observed_curves_are_the_originals — parity-only removed models/tests/test_survival_seer.py::test_the_models_points_are_the_survival_of_the_cases_it_learned_from — parity-only removed models/tests/test_tea_association.py::test_reference_parity — parity-only removed models/tests/test_tea_job.py::test_tea_eeg_runs_the_four_steps_in_order — implementation-detail removed models/tests/test_tea_job.py::test_a_failing_analysis_stops_the_graph — implementation-detail removed models/tests/test_tea_job.py::test_a_bad_scope_fails_before_any_work — implementation-detail removed models/tests/test_tea_job.py::test_config_mirrors_match_the_shared_models — implementation-detail removed models/tests/test_tea_job.py::test_definitions_load_with_every_job_and_the_sensor — implementation-detail removed models/tests/test_tea_job.py::test_relate_returns_none_without_a_champion — implementation-detail removed models/tests/test_tea_job.py::test_tea_eeg_first_n_analyses_exactly_n — slow integration (logic now covered by test_tea_eeg_first_n_selects_exactly_n_pending_studies) removed models/tests/test_tea_job.py::test_tea_eeg_remote_mode_gives_the_same_analysis — slow integration (logic now covered by test_dominant_peak_recovers_a_posterior_rhythm_above_background and test_centile_interpolation_preserves_scoring) removed models/tests/test_tea_preview.py::test_scores_come_from_the_champions — implementation-detail removed models/tests/test_tea_preview.py::test_no_champions_warns_and_leaves_z_empty — implementation-detail removed models/tests/test_tea_preview.py::test_ados2_read_with_the_pipeline_patterns — implementation-detail removed models/tests/test_tea_preview.py::test_ados2_problems_are_warnings_not_errors — implementation-detail removed models/tests/test_tea_preview.py::test_the_job_deletes_its_files_and_returns_the_result_as_output — slow integration (logic now covered by the direct-op test_the_job_deletes_its_files_and_returns_the_result_as_output) removed models/tests/test_tea_preview.py::test_the_job_deletes_its_files_when_the_study_fails — implementation-detail removed models/tests/test_tea_reference.py::test_a_named_reference_resolves_under_the_root — implementation-detail removed models/tests/test_tea_reference.py::test_60_hz_changes_the_digest_and_is_passed_on — implementation-detail removed models/tests/test_tea_reference.py::test_the_cache_is_named_by_cohort_and_digest_and_reused — implementation-detail removed models/tests/test_tea_reference.py::test_legacy_environment_still_works — implementation-detail removed models/tests/test_tea_reference.py::test_train_records_cohort_and_line_hz — implementation-detail removed models/tests/test_tea_reference.py::test_the_train_op_passes_the_reference_or_refuses_it — implementation-detail removed models/tests/test_tea_reference.py::test_reference_config_mirrors_the_shared_model — implementation-detail |
||
|
|
f305cdd044 | TEA EEG analysis and age curves, TEA jobs; CaMa recurrence on METABRIC and SCAN-B; reference-data models and routine runs |