visualization.VisualizationMixin#
- class autoclean.mixins.viz.visualization.VisualizationMixin[source]#
Mixin providing visualization methods for EEG data.
This mixin extends the base ReportingMixin with specialized methods for generating plots and visualizations of EEG data. It provides a comprehensive set of visualization tools for assessing data quality and understanding the effects of preprocessing steps.
All visualization methods respect configuration toggles from autoclean_config.yaml, checking if their corresponding step is enabled before execution. Each method can be individually enabled or disabled via configuration.
Available visualization methods include:
plot_raw_vs_cleaned_overlay: Overlay of original and cleaned EEG data
plot_bad_channels_with_topography: Bad channel visualization with topographies
psd_topo_figure: Combined PSD and topographical maps for frequency bands
step_psd_topo_figure: Wrapper for backwards compatibility
- plot_raw_vs_cleaned_overlay(raw_original, raw_cleaned)[source]#
Plot raw data channels over the full duration, overlaying the original and cleaned data.
- Parameters:
- raw_original
mne.io.Raw
Original raw EEG data before cleaning.
- raw_cleaned
mne.io.Raw
Cleaned raw EEG data after preprocessing.
- raw_original
- Returns:
Notes
The method downsamples the data for plotting to reduce file size
The resulting plot is saved to the derivatives directory with appropriate naming
Metadata about the plot is stored in the processing database
Original data is plotted in red, cleaned data in black.
- plot_bad_channels_with_topography(raw_original, raw_cleaned, pipeline, zoom_duration=30, zoom_start=0)[source]#
Plot bad channels with a topographical map and time series overlays.
This method creates a comprehensive visualization of bad channels including:
A topographical map showing the locations of bad channels
Time series plots comparing original and cleaned data for bad channels
Both full duration and zoomed-in views of the data
The visualization helps to validate the detection and interpolation of bad channels during preprocessing.
- Parameters:
- raw_original: mne.io.Raw
Original raw EEG data before cleaning.
- raw_cleaned: mne.io.Raw
Cleaned raw EEG data after interpolation of bad channels.
- pipeline: Any
Pipeline object containing pipeline metadata and utility functions.
- zoom_duration: float, Optional
Duration in seconds for the zoomed-in time series plot.
- zoom_start: float, Optional
Start time in seconds for the zoomed-in window.
- Returns:
Notes
If no bad channels are found, the method returns without creating a plot
The resulting plot is saved to the derivatives directory
- step_psd_topo_figure(raw_original, raw_cleaned, bands=None)[source]#
Generate and save a single high-resolution image that includes:
Two PSD plots side by side: Absolute PSD (mV²) and Relative PSD (%).
Topographical maps for multiple EEG frequency bands arranged horizontally, showing both pre and post cleaning.
Annotations for average power and outlier channels.
- Parameters:
- raw_original
mne.io.Raw
Original raw EEG data before cleaning.
- raw_cleaned
mne.io.Raw
Cleaned EEG data after preprocessing.
- bands
list
oftuple
, optional List of frequency bands to plot. Each tuple should contain (band_name, lower_freq, upper_freq).
- raw_original
- Returns:
- image_path
str
Path to the saved combined figure.
- image_path