artifacts.ArtifactsMixin#
- class autoclean.mixins.signal_processing.artifacts.ArtifactsMixin[source]#
Mixin class providing artifact detection and rejection functionality for EEG data.
- detect_dense_oscillatory_artifacts(data=None, window_size_ms=100, channel_threshold_uv=45, min_channels=75, padding_ms=500, annotation_label='BAD_REF_AF')[source]#
Detect smaller, dense oscillatory multichannel artifacts.
This method identifies oscillatory artifacts that affect multiple channels simultaneously, while excluding large single deflections.
- Parameters:
- data
mne.io.Raw
,Optional
The raw data to detect artifacts from. If None, uses self.raw.
- window_size_ms
int
,Optional
Window size in milliseconds for artifact detection, by default 100.
- channel_threshold_uv
float
,Optional
Threshold for peak-to-peak amplitude in microvolts, by default 45.
- min_channels
int
,Optional
Minimum number of channels that must exhibit oscillations, by default 75.
- padding_ms
float
,Optional
Amount of padding in milliseconds to add before and after each detected artifact, by default 500.
- annotation_label
str
,Optional
Label to use for the annotations, by default “BAD_REF_AF”.
- stage_name
str
,Optional
Name for saving and metadata, by default “detect_dense_oscillatory_artifacts”.
- data
- Returns:
- result_raw
instance
ofmne.io.Raw
The raw data object with updated artifact annotations. Note the self.raw is updated in place. So the return value is optional.
- result_raw
Notes
This method is intended to find reference artifacts but may also be triggered by other artifacts.
Examples
>>> #Inside a task class that uses the autoclean framework >>> self.detect_dense_oscillatory_artifacts() >>> #Or with custom parameters >>> self.detect_dense_oscillatory_artifacts(window_size_ms=200, channel_threshold_uv=50, min_channels=100, padding_ms=1000, annotation_label="BAD_CUSTOM_ARTIFACT")
- detect_muscle_beta_focus(data=None, freq_band=(20, 30), scale_factor=3.0, window_length=1.0, window_overlap=0.5, annotation_description='BAD_MOVEMENT')[source]#
Detect muscle artifacts in continuous Raw data and add annotations.
This method detects muscle artifacts in continuous EEG data by analyzing high-frequency activity in peripheral electrodes. It automatically adds annotations to the Raw object marking segments with detected artifacts.
- Parameters:
- data
mne.io.Raw
,Optional
The raw data to detect artifacts from. If None, uses self.raw.
- freq_band
tuple
,Optional
Frequency band for filtering (min, max), by default (20, 30).
- scale_factor
float
,Optional
Scale factor for threshold calculation, by default 3.0.
- window_length
float
,Optional
Length of sliding window in seconds, by default 1.0.
- window_overlap
float
,Optional
Overlap between windows as a fraction (0-1), by default 0.5.
- annotation_description
str
,Optional
Description for the annotations, by default “BAD_MOVEMENT”.
- Returns
- ——-
- results_raw
instance
ofmne.io.Raw
The raw data object with updated artifact annotations. Note the self.raw is updated in place. So the return value is optional.
- data
Examples
>>> #Inside a task class that uses the autoclean framework >>> self.detect_muscle_beta_focus() >>> #Or with custom parameters >>> self.detect_muscle_beta_focus(freq_band=(20, 30), scale_factor=4.0, window_length=2.0, window_overlap=0.7, annotation_description="BAD_CUSTOM_ARTIFACT")
- reject_bad_segments(data=None, bad_label=None, stage_name='bad_segment_rejection')[source]#
Remove all time spans annotated with a specific label or all ‘BAD’ segments.
This method removes segments marked as bad and concatenates the remaining good segments.
- Parameters:
- data
mne.io.Raw
,Optional
The raw data to detect artifacts from. If None, uses self.raw.
- bad_label
str
,Optional
- Specific label of annotations to reject. If None, rejects all segments
where description starts with ‘BAD’
- stage_name
str
,Optional
Name for saving and metadata, by default “bad_segment_rejection”.
- data
- Returns:
- raw_cleaned
instance
ofmne.io.Raw
The raw data object with updated artifact annotations. Note the self.raw is updated in place. So the return value is optional..
- raw_cleaned
Examples
>>> #Inside a task class that uses the autoclean framework >>> self.reject_bad_segments() >>> #Or with custom label >>> self.reject_bad_segments(bad_label="BAD_CUSTOM_ARTIFACT")