API reference#

Automatic sleep staging & events detection#

SleepStaging

Automatic sleep staging of polysomnography data.

art_detect

Automatic artifact rejection.

rem_detect

Rapid eye movements (REMs) detection.

REMResults

Output class for REMs detection.

spindles_detect

Spindles detection.

SpindlesResults

Output class for spindles detection.

sw_detect

Slow-waves detection.

SWResults

Output class for slow-waves detection.

compare_detection

Determine correctness of detected events against ground-truth events.

Hypnogram & sleep statistics#

hypno_upsample_to_data

Upsample an hypnogram to a given sampling frequency and fit the resulting hypnogram to corresponding EEG data, such that the hypnogram and EEG data have the exact same number of samples.

hypno_upsample_to_sf

Upsample the hypnogram to a given sampling frequency.

hypno_str_to_int

Convert a string hypnogram array to integer.

hypno_int_to_str

Convert an integer hypnogram array to a string array.

hypno_find_periods

Find sequences of consecutive values exceeding a certain duration in hypnogram.

load_profusion_hypno

Load a Compumedics Profusion hypnogram (.xml).

plot_hypnogram

Plot a hypnogram.

plot_spectrogram

Plot a full-night multi-taper spectrogram, optionally with the hypnogram on top.

transition_matrix

Create a state-transition matrix from an hypnogram.

sleep_statistics

Compute standard sleep statistics from an hypnogram.

Hypnogram

Experimental class for manipulating hypnogram in YASA (dev).

simulate_hypnogram

Simulate a hypnogram based on transition probabilities.

EpochByEpochAgreement

Evaluate agreement between two hypnograms or two collections of hypnograms.

SleepStatsAgreement

Evaluate agreement between sleep statistics reported by two different scorers.

Spectral analyses#

bandpower

Calculate the Welch bandpower for each channel and, if specified, for each sleep stage.

bandpower_from_psd

Compute the average power of the EEG in specified frequency band(s) given a pre-computed PSD.

bandpower_from_psd_ndarray

Compute bandpowers in N-dimensional PSD.

irasa

Separate the aperiodic (= fractal, or 1/f) and oscillatory component of the power spectra of EEG data using the IRASA method.

moving_transform

Moving transformation of one or two time-series.

plot_spectrogram

Plot a full-night multi-taper spectrogram, optionally with the hypnogram on top.

sliding_window

Calculate a sliding window of a 1D or 2D EEG signal.

stft_power

Compute the pointwise power via STFT and interpolation.

topoplot

Topoplot.

Heart rate analysis#

hrv_stage

Calculate heart rate and heart rate variability (HRV) features from an ECG.