yasa.REMResults

class yasa.REMResults(events, data, sf, ch_names, hypno, data_filt)[source]

Output class for REMs detection.

Attributes
_eventspandas.DataFrame

Output detection dataframe

_dataarray_like

EOG data of shape (n_chan, n_samples), where the two channels are LOC and ROC.

_data_filtarray_like

Filtered EOG data of shape (n_chan, n_samples), where the two channels are LOC and ROC.

_sffloat

Sampling frequency of data.

_ch_nameslist

Channel names (= ['LOC', 'ROC'])

_hypnoarray_like or None

Sleep staging vector.

__init__(self, events, data, sf, ch_names, hypno, data_filt)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self, events, data, sf, ch_names, …)

Initialize self.

get_mask(self)

Return a boolean array indicating for each sample in data if this sample is part of a detected event (True) or not (False).

get_sync_events(self[, center, time_before, …])

Return the raw or filtered data of each detected event after centering to a specific timepoint.

plot_average(self[, center, time_before, …])

Plot the average REM.

plot_detection(self)

Plot an overlay of the detected events on the signal.

summary(self[, grp_stage, aggfunc, sort])

Return a summary of the REM detection, optionally grouped across stage.

get_mask(self)[source]

Return a boolean array indicating for each sample in data if this sample is part of a detected event (True) or not (False).

get_sync_events(self, center='Peak', time_before=0.4, time_after=0.4, filt=None, None)[source]

Return the raw or filtered data of each detected event after centering to a specific timepoint.

Parameters
centerstr

Landmark of the event to synchronize the timing on. Default is to use the peak of the REM.

time_beforefloat

Time (in seconds) before center.

time_afterfloat

Time (in seconds) after center.

filttuple

Optional filtering to apply to data. For instance, filt=(1, 30) will apply a 1 to 30 Hz bandpass filter, and filt=(None, 40) will apply a 40 Hz lowpass filter. Filtering is done using default parameters in the mne.filter.filter_data() function.

Returns
df_syncpandas.DataFrame

Ouput long-format dataframe:

'Event' : Event number
'Time' : Timing of the events (in seconds)
'Amplitude' : Raw or filtered data for event
'Channel' : Channel
'IdxChannel' : Index of channel in data
plot_average(self, center='Peak', time_before=0.4, time_after=0.4, filt=None, None, figsize=6, 4.5, **kwargs)[source]

Plot the average REM.

Parameters
centerstr

Landmark of the event to synchronize the timing on. Default is to use the peak of the REM.

time_beforefloat

Time (in seconds) before center.

time_afterfloat

Time (in seconds) after center.

filttuple

Optional filtering to apply to data. For instance, filt=(1, 30) will apply a 1 to 30 Hz bandpass filter, and filt=(None, 40) will apply a 40 Hz lowpass filter. Filtering is done using default parameters in the mne.filter.filter_data() function.

figsizetuple

Figure size in inches.

**kwargsdict

Optional argument that are passed to seaborn.lineplot().

summary(self, grp_stage=False, aggfunc='mean', sort=True)[source]

Return a summary of the REM detection, optionally grouped across stage.

Parameters
grp_stagebool

If True, group by sleep stage (provided that an hypnogram was used).

aggfuncstr or function

Averaging function (e.g. 'mean' or 'median').

sortbool

If True, sort group keys when grouping.