Quality Control Metrics#
MEGFlow writes quality-control sidecars during processing and packages them
into a portable static HTML report. The report combines measured artifact,
ICA, epoch, and coregistration values with NormMEG-QC outputs when
megqc.enabled = true. NormMEG-QC converts minimally preprocessed MEG
recordings into an interpretable Normative MEG Data Quality (NMDQ) score.
The configuration block is still named megqc for compatibility with
existing nextflow.config files. In user-facing reports and documentation,
the framework is referred to as NormMEG-QC and the final 0-100 score is the
NMDQ score.
Subject-Level Metrics#
Metric |
Source |
Interpretation |
|---|---|---|
Sampling rate |
Preprocessed raw file metadata |
Confirms that filtering and resampling produced the expected output sampling frequency. |
Channel count |
Preprocessed raw file metadata |
Used to contextualize bad-channel counts and ratios. |
Recording duration |
Preprocessed raw file metadata |
Used to calculate bad-segment duration ratio. |
Bad channel count |
|
Number of channels marked bad by the configured bad-channel detectors. |
Bad channel ratio |
Bad channel count divided by total channel count |
Helps compare systems or recordings with different channel counts. |
Bad segment count |
|
Number of MNE annotations created by bad-segment detectors. |
Bad segment duration |
Sum of annotation durations |
Total time marked as bad in the continuous recording. |
Bad segment ratio |
Bad duration divided by raw recording duration |
Fraction of continuous time marked as bad. |
ICA marked components |
|
Components selected for exclusion before ICA is applied. |
ICA artifact candidates by category |
|
ECG, EOG, and outlier candidates retained by the three category master
switches. Disabled categories are empty, and |
ICA component review views |
|
Topographic and time-series evidence for component review. If
|
Coregistration mean, max, and min distance |
|
Distances in mm between fitted head-shape points and the head surface. High mean or max distances indicate poor MEG-MRI alignment. |
Epoch rejection rate |
|
Rejected epochs divided by estimated total epochs. Rejections can come from bad annotations, MNE reject thresholds, or optional autoreject. |
Step completion |
Presence of expected output files |
Shows whether artifact, ICA, coregistration, head model, epochs, covariance, and source outputs exist for each recording. |
NormMEG-QC and the NMDQ Score#
When megqc.enabled = true, MEGFlow scores each imported MEG recording
before the main preprocessing chain. The output is saved under
preprocessed/quality_control/<recording>/ and copied into the static
report. The NMDQ score assumes the bundled reference-aligned NormMEG-QC
preprocessing, including the fixed 1-100 Hz band-pass filter, 50 Hz notch, and
250 Hz resampling. Changing the band-pass or target sampling rate changes the
metric distribution and makes the score less comparable to the normative
reference.
Output |
Source file |
Interpretation |
|---|---|---|
NMDQ score |
|
Overall 0-100 score. Higher is better. |
Processing gate status |
|
|
Metric family scores |
|
Domain-level summaries, such as temporal, spectral, statistical, or fractal score families. |
Component scores |
|
Per-metric raw value, reference quantiles, direction of improvement, and component score. |
Family-score figure |
|
Fixed 0-100 figure showing each metric-family score and the overall NMDQ score. Exact values remain available in the family-score table. |
Use these two thresholds for different purposes:
Parameter |
Pipeline effect |
Report effect |
|---|---|---|
|
Blocks downstream MEG processing below this score. |
The subject page reports that later processing was skipped by the quality gate. |
|
Does not block processing. |
Flags recordings below this score in the subject report and dataset dashboard. |
For example, setting megqc.min_score to 70.0 only allows recordings
with scores of 70 or higher to continue into artifact detection, ICA, epochs,
covariance, coregistration, forward modeling, and source reconstruction. Setting
megqc.min_score to 0.0 keeps all successfully scored recordings. If
scoring fails while NormMEG-QC is enabled, the recording does not pass the
score gate.
The dataset dashboard includes an interactive quality-score filter. It can show recordings at or above a temporary cutoff, below a temporary cutoff, or with missing scores without rerunning the pipeline.
NormMEG-QC Metric Families#
The bundled NormMEG-QC scoring profile groups low-level channel-type metrics
into eight metric families, scores each family against the selected normative
reference, and averages available family scores into the final score_0_100.
The default score scale is 0-100 and higher is better.
Metrics are computed separately for available magnetometer and gradiometer
channels. For one channel type, let \(X_{i,t}\) be the reference-aligned
continuous signal for channel \(i\) at sample \(t\), after the fixed
NormMEG-QC preprocessing. The default policy keeps channels marked in
raw.info['bads'] and keeps BAD annotated spans during scoring so the
recording is compared with the same assumptions used by the reference cohort.
Domain |
Quality metric |
Mathematical definition |
What it captures |
|---|---|---|---|
Temporal |
Max absolute difference, absolute Q95 |
For each channel, \(d_i = \max_t |X_{i,t+1} - X_{i,t}|\). The component value is \(Q_{0.95}(|d_i|)\) across channels. |
Extreme sample-to-sample jumps, spikes, and high-frequency transients. |
Temporal |
Max absolute difference, Q75 |
Uses the same \(d_i\) and reports \(Q_{0.75}(d_i)\) across channels. |
Upper-quartile transient instability with less emphasis on the most extreme channels. |
Temporal |
Max absolute difference, IQR |
Uses the same \(d_i\) and reports \(Q_{0.75}(d_i) - Q_{0.25}(d_i)\) across channels. |
Spread of fast sample-to-sample instability across channels. |
Temporal |
Max absolute difference, mean |
Uses the same \(d_i\) and reports \(\mathrm{mean}(d_i)\) across channels. |
Overall temporal roughness across the channel group. |
Spectral |
Spectral amplitude skewness |
For each channel, compute the amplitude spectrum from the first half of \(|\mathrm{FFT}(X_i / n)|\) with the DC component set to zero, then compute \(E[(A-\mu)^3] / \sigma^3\). The component value is the channel mean. |
Spectral asymmetry; high values suggest that a few frequencies dominate the spectrum. |
Spectral |
Spectral amplitude kurtosis |
Uses the same amplitude spectrum \(A\) and computes \(E[(A-\mu)^4] / \sigma^4\); the component value is the channel mean. |
Spectral peakiness, including narrow-band interference and anomalous frequency components. |
Statistical |
Peak-to-peak amplitude, absolute Q95 |
For each channel, \(p_i = \max_t X_{i,t} - \min_t X_{i,t}\). The component value is \(Q_{0.95}(|p_i|)\) across channels. |
Large oscillations, drift, saturating channels, or abnormal amplitude ranges. |
Fractal |
DFA exponent |
Detrended Fluctuation Analysis is computed per channel. By default, MEGFlow averages per-channel DFA values within fixed-length segments and then averages the segment values. |
Long-range correlation and non-stationary temporal structure. |
For the current bundled profile, all eight families use lower_is_better:
unusually large values often indicate noise, transient artifacts, abnormal
dynamic range, or spectral peaks. The direction column in
*.component_scores.csv should still be used as the source of truth because
future NormMEG-QC profiles may mix lower_is_better, higher_is_better,
and near q50 is better metrics.
NMDQ Component Score Columns#
*.component_scores.csv contains one row per scored metric component. Metrics
are often duplicated by channel type, for example mag and grad rows for
the same family when both are available.
Each raw metric value is compared with the selected reference interval. For the
default lower_is_better direction, the component score is:
where \(x\) is the recording metric value and \(q_{0.05}\) and \(q_{0.95}\) are the reference 5th and 95th percentiles. Family scores are the average of available magnetometer and gradiometer component scores for that family. The NMDQ score is the mean of available family scores multiplied by 100.
Column |
Meaning |
|---|---|
|
Broad metric domain such as Temporal, Statistical, Spectral, or Fractal. |
|
Metric family name. Family-level scores shown in the static report are averages of valid component scores in the same family. |
|
Human-readable quality-metric name used in the score figure and family score table. |
|
Channel-type component contributing to the family score, normally
|
|
Exact metric component name, usually including channel type such as
|
|
Metric value measured from the current recording after the fixed NormMEG-QC reference preprocessing. |
|
How to interpret the raw metric. |
|
Normative Reference 5th percentile, median, and 95th percentile used for the selected reference pool. |
|
Position of the recording relative to the reference interval. |
|
Per-metric score on a 0-1 scale. Higher is better. The static report displays this as 0-100. |
|
|
|
Actual reference scope selected after fallback, such as
|
|
Device family and recording category used to look up reference quantiles. |
|
Human-readable description of what the family tends to reflect. |
The reference-position figure uses the same component rows. The green band is
the typical reference interval from q05 to q95. For the default
lower_is_better families, values above q95 are usually worse; values below
q05 may be better or unusually low depending on the metric. Always combine the
status, direction, component score, and interpretation columns when
reviewing a suspicious recording.
Static Report QC Alerts#
The static report classifies each subject as PASS, WARN, or FAIL
using simple QC alert rules:
QC alert |
Source / Docker default |
Severity and meaning |
|---|---|---|
Bad-channel count above threshold |
|
Warning. Review sensor quality and detector settings. |
Bad-segment count above threshold |
|
Warning. Review raw trace plots and bad-segment annotations. |
NMDQ score below warning threshold |
|
Warning. The recording has a low NMDQ score but may still have been
processed if it is above |
Quality gate skipped downstream processing |
|
Danger. The score was below the required processing minimum, so downstream MEG steps were not run for that recording. |
Missing expected ICA outputs |
Stage dependent |
Warning when the selected |
No ECG-related ICA components detected |
|
Optional warning. Set the report option to |
No EOG-related ICA components detected |
|
Optional warning. Set the report option to |
Missing expected coregistration outputs |
Stage dependent |
Warning when the selected |
Mean coregistration distance above threshold |
|
Danger. Usually requires reviewing fiducials, head-shape points, or MRI subject matching. |
Maximum coregistration distance above threshold |
|
Danger. Often indicates outlier head-shape points or poor alignment. |
Epoch rejection rate above threshold |
|
Warning. Check event definitions, reject thresholds, and bad annotations. |
FAIL is assigned when a subject has at least one danger alarm or three or
more alarms. WARN is assigned when there is at least one warning alarm.
PASS means no alarms under the current static thresholds.
The workflow passes the effective config values into report generation, so project overrides take precedence over both base profiles.
These two ICA presence checks affect only static-report QC alerts. They do not
disable ICA fitting, component classification, component removal, or ICA
results in the report. Configure them under report:
params {
megflow {
defaults {
report {
alert_missing_ecg_components = false
alert_missing_eog_components = false
}
}
}
}
Dataset-Level Outputs#
The static report writes a dataset dashboard and machine-readable summaries:
File |
Contents |
|---|---|
|
Dataset-level dashboard with subject table, workflow diagram, aggregate metrics, alarms, and links to subject pages. |
|
Per-recording report with artifacts, ICA, coregistration, epochs, covariance, head model, source figures, task trace details, and packaged sidecars. |
|
Artifact mask heatmap showing bad-channel rows and bad-segment time spans. It is generated and packaged even when detailed artifact image generation is disabled. |
|
NMDQ score summary with |
|
Per-component NormMEG-QC metric table with raw values, reference quantiles, direction, component scores, status, and interpretation. |
|
Family-score and overall-score figure used by the subject page. |
|
Searchable list of report alarms. |
|
Dataset-level metrics, thresholds, workflow metadata, and subject
summaries. The compatibility field |
|
Spreadsheet-friendly subject table. |
|
Full subject summary used to render the subject page. |
|
Snapshot of the effective Nextflow config when available. |
|
Workflow mode and run metadata used to render the report workflow diagram. |
|
Failed or ignored task |
|
Optional successful-task |
Practical Review Guidance#
Start with index.html and sort the subject table by alarms, bad channels,
bad segments, coregistration distance, or epoch rejection rate. Open subject
pages for high-alarm or high-outlier recordings. For artifact-heavy recordings,
inspect the waveform images and the bad-segment table before changing detector
thresholds. For source reconstruction failures or high coregistration alarms,
inspect the final ICP figures and verify that the MEG recording was matched to
the correct FreeSurfer subject.