yasa.SpindlesResults
-
class
yasa.SpindlesResults(events, data, sf, ch_names, hypno, data_filt)[source] Output class for spindles detection.
- Attributes
- _events
pandas.DataFrame Output detection dataframe
- _dataarray_like
Original EEG data of shape (n_chan, n_samples).
- _data_filtarray_like
Sigma-filtered EEG data of shape (n_chan, n_samples).
- _sffloat
Sampling frequency of data.
- _ch_nameslist
Channel names.
- _hypnoarray_like or None
Sleep staging vector.
- _events
-
__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, hue, …])Plot the average spindle.
plot_detection(self)Plot an overlay of the detected spindles on the EEG signal.
summary(self[, grp_chan, grp_stage, …])Return a summary of the spindles detection, optionally grouped across channels and/or 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=1, time_after=1, 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 center peak of the spindles.
- 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, andfilt=(None, 40)will apply a 40 Hz lowpass filter. Filtering is done using default parameters in themne.filter.filter_data()function.
- Returns
- df_sync
pandas.DataFrame 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 'Stage': Sleep stage in which the events occured (if available)
- df_sync
-
plot_average(self, center='Peak', hue='Channel', time_before=1, time_after=1, filt=None, None, figsize=6, 4.5, **kwargs)[source] Plot the average spindle.
- Parameters
- centerstr
Landmark of the event to synchronize the timing on. Default is to use the most prominent peak of the spindle.
- huestr
Grouping variable that will produce lines with different colors. Can be either ‘Channel’ or ‘Stage’.
- 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, andfilt=(None, 40)will apply a 40 Hz lowpass filter. Filtering is done using default parameters in themne.filter.filter_data()function.- figsizetuple
Figure size in inches.
- **kwargsdict
Optional argument that are passed to
seaborn.lineplot().
-
plot_detection(self)[source] Plot an overlay of the detected spindles on the EEG signal.
This only works in Jupyter and it requires the ipywidgets (https://ipywidgets.readthedocs.io/en/latest/) package.
To activate the interactive mode, make sure to run:
>>> %matplotlib widget
New in version 0.4.0.
-
summary(self, grp_chan=False, grp_stage=False, aggfunc='mean', sort=True)[source] Return a summary of the spindles detection, optionally grouped across channels and/or stage.
- Parameters
- grp_chanbool
If True, group by channel (for multi-channels detection only).
- 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.
