Repository navigation
[STUDY] Implement long-tail selection helpers - #156
suraj-ranganath merged 1 commit into
Conversation
|
Claude finished @suraj-ranganath's task in 4m 8s —— View job Code review
I reviewed all 13 new helpers, BlockingNone. ImportantNone. Nits
Test gaps
EEGLAB parity notes
|
|
🤖 Specification for follow-up #149 Problem Phase 6 left STUDY long-tail rows outside the implemented design, cache-reader, plotting, precompute, and selection surfaces. The missing standalone pieces were mostly metadata helpers that EEGLAB users expect around dataset/trial selection, trialinfo construction, subject filtering, same-ICA grouping, and cache invalidation after membership changes. The remaining non-PAC rows also needed explicit row-level disposition instead of generic port placeholders. Approach Added STUDY helper modules under src/eegprep/functions/studyfunc and lazy exports in src/eegprep/init.py. The helpers preserve EEGLAB-facing 1-based dataset/trial indices at public boundaries, sync STUDY.datasetinfo from ALLEEG when practical, and avoid any runtime dependency on src/eegprep/eeglab. Expanded STUDY_DATA_FIELDS so std_substudy/std_rmdat/std_rmalldatafields invalidate stale cached plotting and measure fields after dataset membership changes. Updated Sphinx docs, implementation notes, and docs/parity/eeglab_core_parity_matrix.json so non-PAC #149 rows are implemented, consolidated, matlab_runtime_skip, or external_dependency_skip; PAC rows remain open for #148. Key code def std_selectdataset(
STUDY: dict[str, Any],
ALLEEG: list[dict[str, Any]] | None,
indvar: str | None = "",
indvarvals: Any = None,
verboseFlag: str = "verbose",
) -> tuple[list[int], list[list[int]]]:
_ = verboseFlag
datasets = as_alleeg_list(ALLEEG)
study = sync_datasetinfo(ensure_study(STUDY), datasets)
infos = [info for info in study.get("datasetinfo") or [] if isinstance(info, dict)]
trialselect = _all_trials(infos, datasets)
if _empty_value(indvar):
return list(range(1, len(infos) + 1)), trialselectoutput = deepcopy(study)
if remove_data:
output["datasetinfo"] = [deepcopy(infos[index - 1]) for index in keep]
for index, info in enumerate(output["datasetinfo"], start=1):
info["index"] = index
output_alleeg = [deepcopy(datasets[index - 1]) for index in keep if index <= len(datasets)]
else:
output["datasetinfo"] = deepcopy(infos)
output_alleeg = deepcopy(datasets)
_remap_dataset_references(output, mapping)
output = std_rmalldatafields(output, "both")Tests The new tests/test_study_long_tail_helpers.py uses three loaded datasets with datasetinfo and per-trial event metadata. It covers dataset and trial independent-variable discovery, 1-based selection, missing trialinfo-key position preservation, numeric continuous trial filters, direct ALLEEG sync, subject filtering, same-ICA grouping with subject boundaries, STUDY subsetting, dataset removal, event-count filtering, and cache-field clearing. Existing STUDY metadata, measures, and end-to-end tests were rerun to cover integration with current design/precompute/read/plot paths. |
b5be08d
into
feature/eeglab-core-parity-completion
Add standalone STUDY selection, trialinfo, consistency, subsetting, dataset removal, subject-filter, and ICA-grouping helpers with multi-dataset coverage. Classify the remaining non-PAC Phase 6 STUDY plotting/precompute rows as consolidated, MATLAB-runtime, or external-dependency entries while leaving PAC rows to #148. Part of epic #131 and stacked under PR #152.
Closes #149