eegunity.utils package

Submodules

eegunity.utils.con_udatasets module

eegunity.utils.con_udatasets.con_udatasets(datasets)[source]

Concatenates the locator DataFrames of the given UnifiedDataset objects, and returns a new UnifiedDataset with the concatenated locator.

The function checks if all elements in the input list are instances of the ‘UnifiedDataset’ class. It then calls the get_locator() method of each dataset, concatenates them, and sets the new locator in a copied version of the first dataset using set_locator().

Parameters:

datasets (list of UnifiedDataset) – A list of UnifiedDataset instances to concatenate their locators.

Returns:

A new UnifiedDataset with the concatenated locator.

Return type:

UnifiedDataset

Raises:

ValueError – If any element in the list is not an instance of ‘UnifiedDataset’.

eegunity.utils.h5 module

class eegunity.utils.h5.h5Dataset(path: Path, name: str)[source]

Bases: object

addAttributes(src: Dataset | Group, attrName: str, attrValue)[source]
addDataset(grp: Group, dsName: str, arr: array, chunks: tuple | None = None, **kwargs)[source]
addGroup(grpName: str)[source]
property name
save()[source]

eegunity.utils.normalize module

eegunity.utils.normalize.normalize_mne(mne_raw: Raw) Raw[source]

Normalize each channel of the given MNE Raw object so that its mean is 0 and its standard deviation is 1.

This function processes the data from the MNE Raw object and normalizes each channel independently. The mean of each channel will be set to 0, and the standard deviation will be set to 1, effectively standardizing the data across channels.

Parameters:

mne_rawmne.io.Raw

An instance of the MNE Raw object containing EEG/MEG data to be normalized.

Returns:

mne.io.Raw

The input MNE Raw object with its data normalized per channel.

Notes:

The normalization is done in place, meaning the original data in mne_raw is modified.

Example:

>>> raw = mne.io.read_raw_fif('sample_data.fif')
>>> raw_normalized = normalize_mne(raw)
>>> print(raw_normalized.get_data())

eegunity.utils.pipeline module

class eegunity.utils.pipeline.Pipeline(functions)[source]

Bases: object

A pipeline that applies a list of functions sequentially to an input.

The Pipeline class allows users to define a sequence of transformations (functions) that are applied to an input one after the other.

functions

A list of functions to be applied in sequence.

Type:

list

Example usage (EEG processing):
>>> import mne
>>> def bandpass_filter(raw, l_freq, h_freq):
...     return raw.filter(l_freq=l_freq, h_freq=h_freq)
>>> def notch_filter(raw, freqs):
...     return raw.notch_filter(freqs=freqs)
>>> def resample(raw, sfreq):
...     return raw.resample(sfreq=sfreq)
>>> # Load sample data
>>> # raw = mne.io.read_raw_fif(mne.datasets.sample.data_path() + '/MEG/sample/sample_audvis_raw.fif', preload=True)
>>> # Define processing functions for the pipeline
>>> functions = [
...     lambda raw: bandpass_filter(raw, 0.1, 75),
...     lambda raw: notch_filter(raw, freqs=50),
...     lambda raw: resample(raw, sfreq=200)
... ]
>>> # Initialize and apply the pipeline
>>> pipeline = Pipeline(functions)
>>> processed_raw = pipeline.forward(raw)
>>> print(processed_raw.info['sfreq'])
forward(X)[source]

Module contents