Reference API

ffrprep.preproc - Preprocessing functions

preproc module for ffrprep.

Local imports are used inside functions so that Nipype Function nodes executed in separate processes have the necessary imports available at runtime. Avoid top-level imports for packages that are imported inside functions to prevent redefinition and lint warnings.

load_data([bids_root, sub_label, ...])

Identify and load EEG data from a BIDS directory using pybids for querying.

reference_data([eeg_data, ref_channels])

Re-reference the provided EEG data object.

filter_data([eeg_data, high_pass, low_pass, ...])

Apply frequency filters to the provided EEG data object.

epoch_data(eeg_data, baseline[, ...])

Epoch the provided EEG data object based on events.

make_evoked(epochs[, by_event_type])

Create evoked responses by averaging epochs.

make_combined_evoked(epochs)

Average across every event in epochs, ignoring event_id groups.

make_difference_evokeds(evoked_dict[, pairs])

Compute A - B Evokeds for one or more trial-type pairs.

build_analysis_payload(epochs[, ...])

Compute the structured {by_type, combined, diff} analysis shape.

save_preprocessing_outputs(epochs, ...[, ...])

Save preprocessing outputs to BIDS derivatives structure.

save_analysis_outputs(evoked, bids_root, ...)

Save analysis outputs to BIDS derivatives structure.

create_preprocessing_workflow([name, ...])

Create nipype workflow for FFR preprocessing.

create_analysis_workflow([name])

Build a nipype workflow that averages epochs into evoked responses and saves them to BIDS-derivatives.

ffrprep.analysis - FFR analysis functions

compute_power(avg_evoked[, f_low, f_high, ...])

Compute the average oscillatory power of a given frequency band.

rms_snr(evoked[, response_lower, response_upper])

Compute RMS-based signal-to-noise ratio (SNR) for an Evoked response.

autocorrelation(evoked)

Autocorrelation function and 95% CI for the first channel of evoked.

compute_pitch_and_conf(evoked[, win_dur, ...])

Compute the pitch (f0) and confidence metrics for an Evoked response.

plot_pitch_and_conf(results)

Plot a smoothed pitch track together with associated confidence measures.

compute_phase_consistency(epochs_A, epochs_B)

Compute phase consistency from FFR epochs.

plot_phase_consistency(phasecon, xaxis, yaxis)

Plot phase consistency matrices.

plot_phase_consistency_masked(phasecon, ...)

Plot phase consistency with significance masking.

corr_stim_to_resp(stim, resp, sfreq)

Compute the correlation between stimulus and brain response.

corr_resp_to_resp(resp1, resp2, sfreq)

Compute the correlation between two brain responses.

response_consistency(epochs[, tmin, tmax, picks])

Compute trial-to-trial response consistency from an MNE Epochs object.

compute_fft(signal_data, sfreq[, fmin, fmax])

Compute the FFT amplitude spectrum for a time-domain signal.

harmonic_amplitudes(evoked[, f0, ...])

Spectral amplitude of the fundamental and its harmonics in an FFR.

stim_to_resp_xcorr(stim, resp, sfreq[, ...])

Maximum stimulus-to-response cross-correlation (coefficient form).

load_wav_mono(path)

Read a WAV file as a float, mono (channel-averaged) waveform.

resample_signal(data, sfreq_in, sfreq_out)

Polyphase-resample a 1-D signal (no-op if the rates match).

ffrprep.reports - Report builders

This module provides functions for creating, updating, and saving MNE reports.

For FFRPREP BIDS datasets, including support for figures, HTML blocks, and special MNE objects.

build_raw_section(raw, *, section_id, title)

Build a section descriptor from a Raw object.

build_epoch_section(epochs, *, section_id, title)

Build a section descriptor from an Epochs object.

build_evoked_section(evoked, *, section_id, ...)

Build a section descriptor from an Evoked object.

build_metrics_table_section(metrics, *, ...)

Build a section descriptor summarizing a group-level metrics table.

build_phase_consistency_section(epochs_a, ...)

Build a phase-consistency section from two polarities of Epochs.

make_group(*, sections[, session, task, ...])

Construct a group descriptor consumable by the report builders.

build_subject_report(bids_root, subject, out_dir)

Render a single-file HTML preprocessing report for a subject.

build_analysis_report(bids_root, subject, ...)

Render a single-file HTML analysis report for a subject.

build_group_report(out_dir[, sections, ...])

Render a single-file HTML group-level report.

evoked_qa(evoked[, save_dir, prefix])

Generate FFR-specific QA figures for an mne.Evoked object.

epoch_qa(epochs[, save_dir, prefix])

Generate QA figures for an mne.Epochs object.

ffrprep.group - Group-level aggregation

group module for ffrprep.

Aggregates already-computed participant-level derivatives (ffrprep-analysis/sub-*/ and ffrprep-preprocessing/sub-*/eeg/) into group-level summaries: a grand-average evoked response per (task, session, run), a per-subject scalar-metrics table, and a group HTML report. This mirrors the aggregation-only scope other BIDS Apps use for their “group” level (e.g. MRIQC’s group report): it summarizes what participant-level ffrprep already computed, it does not run any group-level statistics.

discover_group_inputs(derivatives_root[, ...])

Discover participant-level derivatives to aggregate at the group level.

compute_grand_average(evoked_paths)

Load per-subject Evoked files and compute their grand average.

compute_subject_metrics(evoked_paths[, ...])

Compute per-subject scalar FFR metrics from saved derivatives.

add_qc_flags(metrics[, min_usable_pct, min_snr])

Flag recordings that fail quality thresholds; never drop rows.

build_metrics_dictionary(columns, *[, ...])

Build a BIDS-style data dictionary for the group metrics TSV.

merge_covariates(metrics, covariate_paths[, ...])

Left-join subject-level covariate TSVs onto a metrics table.

save_group_outputs(derivatives_root, task, ...)

Save a grand-average Evoked and its provenance sidecar under derivatives_root/ffrprep-group/.

save_group_metrics(derivatives_root, task, ...)

Save a per-subject metrics table to a group-level TSV file.

run_group_level(args)

Run the group-level aggregation step (BIDS-App analysis_level=group).

ffrprep.datasets - Dataset functions

download_example_data([dataset_path, ...])

Download example EEG data (1 subject) for testing and tutorials.

download_raw_data([subjects, dataset_path, ...])

Download raw EEG data for specified subjects from OSF.

download_epoch_data([subjects, dataset_path])

Download epoched EEG data for specified subjects from OSF.

download_stimuli([dataset_path])

Download FFR stimulus files into a BIDS-compliant stimuli/ directory.

ffrprep.utils - Utility functions

Utility functions for validating BIDS directories and related operations.

validate_input_dir(exec_env, bids_dir, ...)

Validate BIDS directory and structure via the BIDS-validator.