Repository navigation
Reproduce Whiteford paper results with new preproc and analysis - #52
Merged
Merged
Conversation
Some published FFR pipelines band-pass with zero-phase first-order Butterworth filters (butter + filtfilt) and reject trials on absolute amplitude (max|x| >= threshold) rather than peak-to-peak. Both are now opt-in (defaults unchanged), plumbed through the CLI, nipype workflow nodes and sidecar (RejectionMode). Tests compare the IIR output with scipy butter+sosfiltfilt and check abs vs ptp on constructed epochs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
harmonic_amplitudes computes zero-padded, band-averaged FFT amplitudes at the harmonics of f0 (fundamental and summed upper harmonics, in uV) and stim_to_resp_xcorr the max cross-correlation in xcorr 'coeff' form with an optional lag window and Fisher z. load_wav_mono / resample_signal bring a stimulus to the EEG rate. Defaults follow Whiteford et al. (2025). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
With --f0 the group table gains rms_snr_polarity_sum, f0_uv and upper_harmonics_uv computed on the sum of the two per-trial-type averages; --stimulus adds stimulus-to-response r/z/lag (and a lag-limited variant); --n-trials-presented adds usable_pct. participants.tsv and --covariates are joined onto the saved TSV. discover_group_inputs returns per-type evokeds, and the report section shows histograms instead of an unreadably tall table for large cohorts. Defaults leave existing group outputs unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The stim2resp_r/z/lag_ms columns must search all lags; --xcorr-lag-range only defines the separate stim2resp_lim_* variant. The primary columns were accidentally computed with the restriction whenever a lag range was given. Validated on real data: max-over-all-lags r = 0.1607 vs 0.1610 published. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Multi-site cohorts can label the one recorded channel differently (A32 vs Cz) and mne.grand_average refuses to combine them. Rename single-channel evokeds to the most common name (with a note); mismatched multi-channel sets raise an explicit error. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Owner
Author
|
@PeerHerholz in my mind, this PR is the next milestone: using the new group analysis to validate an existing dataset while also using this dataset processing to test out the current FFRPrep implementation and point out required fixes. If the previous PRs look good (referenced above—all relatively simple one-issue fixes), let's merge them so that we can focus on #43 and this current PR. |
Collaborator
|
Sounds good! Happy to give this |
# Conflicts: # CHANGES.rst # docs/source/pipeline_details.rst # ffrprep/preproc.py # ffrprep/tests/test_preproc.py
Bulk runs over hundreds of subjects were limited by disk space (2.5-4 GB of Nipype working files per subject) and needed external wrapper scripts to resume after interruptions. - --skip-existing skips (task, run) iterations whose JSON sidecars already exist; completion is judged from sidecars so it survives --no-keep-epochs. A finished subject builds no report and no longer errors when the epochs were removed. - --clean-work-dir removes an iteration's Nipype working files after it succeeds (logs are kept; failed iterations keep theirs for debugging). - --keep-epochs/--no-keep-epochs (default keep) deletes *_epo.fif after the analysis stage; ignored with a warning for --stage preprocessing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
--min-usable-pct and --min-snr add qc_usable_pct_ok / qc_snr_ok, qc_include and qc_reason columns to the group metrics TSV. Recordings are flagged, never dropped: the table and grand averages keep every subject so downstream analyses choose whether to filter, and the report summary shows the flagged count. A NaN value fails its check; --min-usable-pct without --n-trials-presented is a clear error. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The group step now writes task-<task>[_run-<run>]_metrics.json with a description and units for every metrics column (BIDS-style), embedding the windows, harmonic settings and QC thresholds the run used. Covariate columns take their description/levels/units from the JSON sidecar next to the covariate TSV when present. merge_covariates gains return_sources and save_group_metrics a dictionary argument. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Owner
Author
|
A few additional commits:
|
pipeline_details.rst: the group section now covers the polarity-sum and stimulus metrics, covariates, QC flags, the metrics dictionary, channel-name harmonization and the ffrprep-group output files; the sidecar text lists RejectionMode and Sources/RawSources and explains the epoch counts; the workflow section describes --skip-existing, --clean-work-dir and --no-keep-epochs. The walkthrough, index and README point to the group step. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Owner
Author
|
Updated docs to match this PR's changes (as well as the
|
github-actions Bot
pushed a commit
that referenced
this pull request
Sep 29, 2026
Reproduce Whiteford paper results with new preproc and analysis 626fc0d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds new preprocessing options and analysis outputs to allow for reproduction of the Whiteford et al. musicianship FFR results.
Note 1: this was created by branching the
group-levelbranch, so it cannot be merged until #43 is merged with main.Note 2: It also uses tools introduced in #46 #47 #48 #49 #50 #51 . It will conflict in
preproc.pyandtest_preproc.py(andCHANGES.rst). To resolve: merge main into whiteford-repro. Keep both sides in_save_one_preproc_epochs(the new RejectionMode fields plus the raw-sources and counts logic). Inepoch_data, put the per-condition count call after the--reject-mode absdrop block, so ABS_AMP rejections are counted.