sleepless.data.transforms#
Signal transformations for our pipelines.
Classes
|
Extract feature from a py:class:DelayedSample list. |
|
Extract feature from a py:class:DelayedSample list. |
|
Transform Raw and Annotation objects to Epochs object, with some preprocessing options. |
|
Resample |
|
Build Torch dataset from a py:class:DelayedSample list. |
- class sleepless.data.transforms.RawToEpochs(event_id, chunk_duration, picks_chan=None, no_overlapping=True, crop_wake_time=0.0, wake_stage_name=None)[source]#
Bases:
object
Transform Raw and Annotation objects to Epochs object, with some preprocessing options. Data are not loaded in memory until mne.Epochs.get_data() is call.
This class was inspired from version 1.4 of https://mne.tools/stable/auto_tutorials/clinical/60_sleep.html
- Parameters:
raw_obj – A mne raw object
annot_obj – A mne object for annotating segments of raw data
event_id (
dict
[str
,int
]) – Map stage_name (str=keys) and interger event codes (int=values)chunk_duration (
float
) – The window time (in seconde) that was used to annotatedpicks_chan (
UnionType
[str
,list
[str
],None
]) – List of channels to keep (e.g. [‘eeg’,’eog’,’emg’]), if None (default)no_overlapping (
bool
) – If True remove last sample from epoch to avoid overlapping, Default (False)crop_wake_time (
float
) – Wake time (in minute) to keep at the begining and the end, in some case it is usefull to crop a part of the wake time if it is too long regarding the other stage or not usefull (e.g. walking time)wake_stage_name (
Optional
[str
]) – Only needed for crop_wake_time. (e.g. “Sleep stage W”)
- class sleepless.data.transforms.EEGPowerBand(pick_chan=None)[source]#
Bases:
object
Extract feature from a py:class:DelayedSample list.
This class was copied and modified from https://mne.tools/stable/auto_tutorials/clinical/60_sleep.html v1.4
Modification: change to class, adding pick_chan attribute, management division by zero
- class sleepless.data.transforms.ToTorchDataset(normalize=False, pick_chan=None, n_past_epochs=0)[source]#
Bases:
object
Build Torch dataset from a py:class:DelayedSample list.
- Parameters:
normalize (
bool
) – If True, normalized the samplepick_chan (
list
[str
]) – the channel type (e.g. “eeg”,”eog”) or name (e.g. “Fpz-Cz”) whom extract the features, if None default compute features for all EEG channels.n_past_epochs (
int
) – number of precedent epochs to include in the ListSampleDataset object (by concatenation).
- Returns:
torch.utils.data.dataset.ConcatDataset
of all samples
- class sleepless.data.transforms.ResampleEpochs(sampling_freq)[source]#
Bases:
object
Resample
mne.Epochs
object from a py:class:DelayedSample list.- Parameters:
sampling_freq (
int
) – sampling frequency to which resample- Returns:
py:class:DelayedSample list with resampled data
- class sleepless.data.transforms.FeatureExtractorChambon(pick_chan=None)[source]#
Bases:
object
Extract feature from a py:class:DelayedSample list. 26 manually chosen features (total power (5), relative power (5), power ratio (10), spectral entropy, mean, variance, skewness, kurtosis, 75% quantile.)
This class was copied and modified from https://mne.tools/stable/auto_tutorials/clinical/60_sleep.html v1.4
Modification: change to class, adding pick_chan attribute, management division by zero, adding computation of more features
Reference: [Chambon-2018]