gfp_clean_epochs.GFPCleanEpochsMixin#
- class autoclean.mixins.signal_processing.gfp_clean_epochs.GFPCleanEpochsMixin[source]#
Mixin class providing functionality to clean epochs based on Global Field Power (GFP).
- gfp_clean_epochs(epochs=None, gfp_threshold=3.0, number_of_epochs=None, random_seed=None, stage_name='post_gfp_clean', export=False)[source]#
Clean an MNE Epochs object by removing outlier epochs based on Global Field Power.
- Parameters:
- epochs: mne.Epochs, Optional
The epochs object to clean. If None, uses self.epochs.
- gfp_threshold: float
The z-score threshold for GFP-based outlier detection (default: 3.0).
- number_of_epochs: int
If specified, randomly selects this number of epochs from the cleaned data.
- random_seed: int
Seed for random number generator when selecting epochs.
- stage_name: str
Name for saving and metadata tracking. By default “post_gfp_clean”.
- exportbool, optional
If True, exports the cleaned epochs to the stage directory. Default is False.
- Returns:
- epochs_final
instance
ofmne.Epochs
The cleaned epochs object with outlier epochs removed
- epochs_final
See also
mne.Epochs
mne.Epochs.get_data
mne.Epochs.copy
Example
`python # Clean epochs with default parameters clean_epochs = task.gfp_clean_epochs() # Clean epochs with custom parameters and select a specific number of epochs clean_epochs = task.gfp_clean_epochs( gfp_threshold=2.5, number_of_epochs=40, random_seed=42 ) `
Notes
This method calculates the Global Field Power (GFP) for each epoch, identifies epochs with abnormal GFP values (outliers), and removes them from the dataset. GFP is calculated as the standard deviation across all scalp electrodes at each time point, providing a measure of the spatial variability of the electric field.
The method focuses on scalp electrodes for GFP calculation, excluding non-EEG channels like EOG or reference electrodes. It can also optionally select a random subset of the cleaned epochs, which is useful for ensuring a consistent number of epochs across subjects or conditions.
The method generates visualization plots showing the GFP distribution and outliers, which are saved to the output directory if a run_id is specified in the configuration.