gedai.gedai.MultibandGedai🔗

class gedai.gedai.MultibandGedai(wavelet_type='haar', wavelet_level=8)[source]🔗

Multiband Generalized Eigenvalue De-Artifacting Instrument.

A multiband extension of the standard Gedai that applies GEDAI algorithm separately to different frequency bands (via wavelet decomposition). This approach allows for more targeted artifact removal while preserving neural signals. See [1].

Warning

For EEG channels, Gedai will set average reference internally to match the leadfield covariance reference. Gedai will not modify the input data in-place, but will create copies when necessary to ensure the original data remains unchanged.

Parameters:
wavelet_typestr

Wavelet to use for the decomposition. The default is 'haar'. See pywt.wavedec() for the list of available wavelets.

wavelet_levelint

Wavelet decomposition level. Must be greater than 0. The default is 4.

Attributes

ch_names

Get the channel names used during fitting.

Methods

fit_epochs(epochs[, picks, reference_cov, ...])

Fit the GEDAI model to the epochs data.

fit_raw(raw[, picks, duration, overlap, ...])

Fit the GEDAI model to the raw data.

plot_fit()

Plot the fitting results.

transform_epochs(epochs[, n_jobs, verbose])

Transform epochs data using the fitted model.

transform_raw(raw[, overlap, n_jobs, verbose])

Transform raw data using the fitted model.

References

fit_epochs(epochs, picks='eeg', reference_cov='leadfield', sensai_method='optimize', noise_multiplier=3.0, wavelet_low_cutoff='auto', n_jobs=None, verbose=None)[source]🔗

Fit the GEDAI model to the epochs data.

Parameters:
epochsmne.Epochs

The epochs data to fit the model to.

picksstr | list | slice

Channels to include. Note that all channels selected must have the same type. Slices and lists of integers will be interpreted as channel indices. In lists, channel name strings (e.g. ['Fp1', 'Fp2']) will pick the given channels. Can also be the string values "all" to pick all channels, or "data" to pick data channels. The default is "eeg" to pick all EEG channels.

reference_covstr | mne.Covariance

The reference covariance to use. If 'leadfield', use a pre-computed covariance. The precomputed covariance if computed from a leadfield made using 1005 EEG channels layout and fsaverage head model. If mne.Covariance, use a pre-computed covariance. See compute_covariance_from_forward() for more details on how to compute a covariance from a forward solution.

sensai_methodstr

The method to use for threshold optimization. Can be 'gridsearch' or 'optimize'. The default is 'optimize'.

noise_multiplierfloat

The noise multiplier to use for artefact threshold rejection optimization.

wavelet_low_cutofffloat | None

If a float is provided, zero out all wavelet levels whose upper frequency bound is below this cutoff frequency in Hz. If None, no frequency band is zeroed out. If "auto", the cutoff is automatically determined based on the info[‘highpass’] value of the fitted instance. While reading data from a file, info[‘highpass’] might be missing (i.e., equal to 0.0). If you know that your data has been high-pass filtered, make sure to set wavelet_low_cutoff to the high-pass cutoff frequency. The default is "auto".

n_jobsint | None

The number of jobs to run in parallel. If -1, use all available CPU cores. If 1 or None, computations are run serially.

verboseint | str | bool | None

Sets the verbosity level. The verbosity increases gradually between "CRITICAL", "ERROR", "WARNING", "INFO" and "DEBUG". If None is provided, the verbosity is set to "WARNING". If a bool is provided, the verbosity is set to "WARNING" for False and to "INFO" for True.

fit_raw(raw, picks='eeg', duration=1.0, overlap=0.75, reject_by_annotation=False, reference_cov='leadfield', sensai_method='optimize', noise_multiplier=3.0, wavelet_low_cutoff='auto', n_jobs=None, verbose=None)[source]🔗

Fit the GEDAI model to the raw data.

Parameters:
rawmne.io.BaseRaw

The raw data to fit the model to.

picksstr | list | slice

Channels to include. Note that all channels selected must have the same type. Slices and lists of integers will be interpreted as channel indices. In lists, channel name strings (e.g. ['Fp1', 'Fp2']) will pick the given channels. Can also be the string values "all" to pick all channels, or "data" to pick data channels. The default is "eeg" to pick all EEG channels.

durationfloat

Duration of each epoch in seconds. The default is 1.0.

overlapfloat

The overlap ratio between consecutive epochs, between 0 and 1. The default is 0.5 (50%% overlap). For example, 0.5 means 50%% overlap and 0.75 means 75%% overlap.

reject_by_annotationbool

Whether annotated bad segments should be rejected. It is recommended to set this to False for fitting, since the algorithm needs to learn from bad segments. The default is False.

reference_covstr | mne.Covariance

The reference covariance to use. If 'leadfield', use a pre-computed covariance. The precomputed covariance if computed from a leadfield made using 1005 EEG channels layout and fsaverage head model. If mne.Covariance, use a pre-computed covariance. See compute_covariance_from_forward() for more details on how to compute a covariance from a forward solution.

sensai_methodstr

The method to use for threshold optimization. Can be 'gridsearch' or 'optimize'. The default is 'optimize'.

noise_multiplierfloat

The noise multiplier to use for artefact threshold rejection optimization.

wavelet_low_cutofffloat | None

If a float is provided, zero out all wavelet levels whose upper frequency bound is below this cutoff frequency in Hz. If None, no frequency band is zeroed out. If "auto", the cutoff is automatically determined based on the info[‘highpass’] value of the fitted instance. While reading data from a file, info[‘highpass’] might be missing (i.e., equal to 0.0). If you know that your data has been high-pass filtered, make sure to set wavelet_low_cutoff to the high-pass cutoff frequency. The default is "auto".

n_jobsint | None

The number of jobs to run in parallel. If -1, use all available CPU cores. If 1 or None, computations are run serially.

verboseint | str | bool | None

Sets the verbosity level. The verbosity increases gradually between "CRITICAL", "ERROR", "WARNING", "INFO" and "DEBUG". If None is provided, the verbosity is set to "WARNING". If a bool is provided, the verbosity is set to "WARNING" for False and to "INFO" for True.

plot_fit()[source]🔗

Plot the fitting results.

Returns:
figslist of matplotlib.figure.Figure

A list of figures showing the fitting results for each wavelet band that was not ignored.

transform_epochs(epochs, n_jobs=None, verbose=None)[source]🔗

Transform epochs data using the fitted model.

Parameters:
epochsmne.Epochs

The epochs to transform.

n_jobsint | None

The number of jobs to run in parallel. If -1, use all available CPU cores. If 1 or None, computations are run serially.

verboseint | str | bool | None

Sets the verbosity level. The verbosity increases gradually between "CRITICAL", "ERROR", "WARNING", "INFO" and "DEBUG". If None is provided, the verbosity is set to "WARNING". If a bool is provided, the verbosity is set to "WARNING" for False and to "INFO" for True.

Returns:
epochsmne.Epochs

The transformed epochs.

transform_raw(raw, overlap=0.75, n_jobs=None, verbose=None)[source]🔗

Transform raw data using the fitted model.

Parameters:
rawmne.io.BaseRaw

The raw data to fit the model to.

overlapfloat

The overlap ratio between consecutive epochs, between 0 and 1. The default is 0.5 (50%% overlap). For example, 0.5 means 50%% overlap and 0.75 means 75%% overlap.

n_jobsint | None

The number of jobs to run in parallel. If -1, use all available CPU cores. If 1 or None, computations are run serially.

verboseint | str | bool | None

Sets the verbosity level. The verbosity increases gradually between "CRITICAL", "ERROR", "WARNING", "INFO" and "DEBUG". If None is provided, the verbosity is set to "WARNING". If a bool is provided, the verbosity is set to "WARNING" for False and to "INFO" for True.

Returns:
raw_correctedmne.io.BaseRaw

The corrected raw data.

property ch_names🔗

Get the channel names used during fitting.

Returns:
ch_nameslist of str

The channel names that were used during model fitting.