Skip to content

Latest commit

 

History

History
97 lines (64 loc) · 6.5 KB

plotting.md

File metadata and controls

97 lines (64 loc) · 6.5 KB

Automatic diagnostic figures

decomb run and decomb psd generate publication-ready diagnostic figures evaluating harmonic suppression, off-target spectral alteration, and synthetic probe recovery. All figures adhere to strict scientific visualization standards:

  • Output Formats: Simultaneous vector PDF (embedded TrueType fonts, vector axes and annotations) and 600 DPI raster PNG at a standard 7.2-inch column width.
  • Unmanipulated Data: Raw spectral bins and differences are displayed without smoothing, clipping, or thresholding.
  • Visual Palette: Consistent, colorblind-safe color maps and line styles across source and derivative representations.

Caching and Redrawing

Computing multi-channel Welch spectra across an entire cohort is computationally intensive. To facilitate rapid re-plotting and styling iterations, decomb psd writes a cache file: cohort_spectra.npz.

  • Cache Reuse: Subsequent invocations of decomb psd check whether Welch settings, the correction manifest, and recording paths remain unchanged. If identical, measurements are loaded from cohort_spectra.npz, reducing execution time from ~20 minutes to under 30 seconds.
  • Safe Invalidation: If any parameter or upstream file digest differs, decomb automatically recalculates spectra from source files, logging the differing key. Unlike study caches, diagnostic recomputation never refuses; it simply updates the cache.
  • Scope Note: Time–frequency spectrograms (time_frequency/<recording>.png) are generated during the raw measurement pass; cache-only runs retain previously generated spectrograms.

Figure Specifications and Interpretation

1. Correction Summary

  • Broadband Spectrum: Square root of mean linear power spectral density ($\mu\text{V}/\sqrt{\text{Hz}}$). Channels are averaged within each recording before cohort averaging.
  • Harmonic Suppression Markers: Mean decibel suppression at the nearest Welch bin: $$\Delta \text{PSD}h = 10 \log{10}\left( \frac{\text{PSD}{\text{source}}(h \cdot f_0)}{\text{PSD}{\text{corrected}}(h \cdot f_0)} \right)$$ Calculated exclusively across recordings that modeled harmonic $h$. Error bars represent sample standard deviations ($s$) across contributing recordings.
  • Zoomed Tooth Details: Unsmoothed Welch bins around anchor harmonics, illustrating the $\pm 0.1\text{ Hz}$ peak interval and flanking reference windows ($\pm [0.25, 0.55]\text{ Hz}$ and $\pm [1.0, 4.0]\text{ Hz}$).
  • Scalp Topography: Mean harmonic prominence reduction across the sensor array, mapped via MNE linear interpolation within the sensor convex hull.

2. Spectral Change and Probe Recovery

  • Paired Decibel Change: Evaluates binwise difference $\text{PSD}{\text{corrected}} - \text{PSD}{\text{source}}$ in decibels, displaying cohort mean and $\pm 1$ sample standard deviation shading. This reveals subtle off-target deviations that overlay plots might obscure.
  • Probe Gain and Waveform Error: Evaluates the preservation of injected synthetic probes: $$\text{Gain } G = \frac{|F(x + s) - F(x)|}{|s|} \times 100%$$ $$\text{NRMSE} = \frac{| (F(x + s) - F(x)) - s |}{|s|} \times 100%$$ where $x$ is the baseline recording, $s$ is the synthetic probe, and $F(\cdot)$ is the regression operator.
  • Target Boundaries:
    • Preserved signals target $100%$ gain and $0%$ NRMSE.
    • The comb-locked control (aligned to tracked comb phase at 0 Hz offset) targets $0%$ gain and $100%$ NRMSE.

3. Time–Frequency Dynamics

Spectrograms are saved to time_frequency/<recording>.png and .pdf alongside an NPZ array archive:

  • Windowing: Non-overlapping Hann windows of duration removal.estimation_window_s with 50% nominal overlap.
  • Paired Change: The third panel plots $10 \log_{10}(\text{PSD}{\text{corrected}} / \text{PSD}{\text{source}})$ using a zero-centered symmetric colormap.
  • Boundary Demarcations: Solid vertical lines mark acquisition boundaries; dotted vertical lines indicate the 60-second support block regression partitions.

4. Recording-Level Performance Scatter

recording_performance.png provides cohort-wide quality assurance on a single plane:

  • Horizontal Axis: Mean suppression (dB) on modeled harmonic bins for each recording.
  • Vertical Axis: Mean absolute off-tooth change (dB) across non-harmonic frequencies outside the $\pm 0.1\text{ Hz}$ guard band. Taking absolute values prior to averaging prevents cancellation of positive and negative fluctuations.
  • A numbered tag identifies the recording with the largest off-tooth spectral change, documented in the companion TSV.

5. Sensor Topography of Comb Prominence

channel_topography.png maps comb power across the electrode montage:

  • Channel prominence is defined as peak power relative to the symmetric flanking background.
  • Panel (a) shows source and derivative prominence per channel on a shared ordinate.
  • Panels (b, c) map spatial distributions on identical contour levels.
  • Panel (d) displays inter-tooth background baseline changes, verifying that broadband EEG power is unperturbed.

6. Frequency-Selectivity Sweep

apply writes <recording>_frequency_sweep.png evaluating filter selectivity across 9 frequency offsets ($\pm 0.6, \pm 0.3, \pm 0.12, \pm 0.03, 0\text{ Hz}$ for a 1.2 Hz fundamental) and 4 initial phases ($0, \pi/2, \pi, 3\pi/2$):

  • Probes are phase-referenced to the tracked cryocooler harmonic: $$\phi_{\text{probe}}(t) = h \cdot \phi(t) + 2\pi \cdot \Delta f \cdot t + \theta_0$$
  • Evaluates whether filter suppression rolls off sharply away from the target tooth, verifying filter specificity without assuming time-invariant frequency.

Exemplar Figures

The figures below illustrate production outputs from a 126-recording cohort run applying frozen model 2026-09-12-robust-shared-phase-v5-110hz to participant recording sub-0001_task-thermalactive_run-1_eeg:

Full-Recording Time–Frequency Diagnostic

Full-recording time–frequency diagnostic

Vector PDF · Methods caption


Frequency-Offset Probe Recovery

Frequency-offset probe recovery

Vector PDF · Methods caption


Recording-Level Suppression and Off-Tooth Change

Recording-level suppression and off-tooth change

Vector PDF · Methods caption