API reference

Automatic sleep staging & events detection

SleepStaging(raw, eeg_name, *[, eog_name, ...])

Automatic sleep staging of polysomnography data.

art_detect(data[, sf, window, hypno, ...])

Automatic artifact rejection.

rem_detect(loc, roc, sf[, hypno, include, ...])

Rapid eye movements (REMs) detection.

REMResults(events, data, sf, ch_names, ...)

Output class for REMs detection.

spindles_detect(data[, sf, ch_names, hypno, ...])

Spindles detection.

SpindlesResults(events, data, sf, ch_names, ...)

Output class for spindles detection.

sw_detect(data[, sf, ch_names, hypno, ...])

Slow-waves detection.

SWResults(events, data, sf, ch_names, hypno, ...)

Output class for slow-waves detection.

compare_detection(indices_detection, ...[, ...])

Determine correctness of detected events against ground-truth events.

Hypnogram & sleep statistics

hypno_upsample_to_data(hypno, sf_hypno, 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(hypno, sf_hypno, sf_data)

Upsample the hypnogram to a given sampling frequency.

hypno_str_to_int(hypno[, mapping_dict])

Convert a string hypnogram array to integer.

hypno_int_to_str(hypno[, mapping_dict])

Convert an integer hypnogram array to a string array.

hypno_find_periods(hypno, sf_hypno[, ...])

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

load_profusion_hypno(fname[, replace])

Load a Compumedics Profusion hypnogram (.xml).

plot_hypnogram(hyp[, sf_hypno, highlight, ...])

Plot a hypnogram.

plot_spectrogram(data, sf[, hypno, win_sec, ...])

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

transition_matrix(hypno)

Create a state-transition matrix from an hypnogram.

sleep_statistics(hypno, sf_hyp)

Compute standard sleep statistics from an hypnogram.

Hypnogram(values[, n_stages, freq, start, ...])

Experimental class for manipulating hypnogram in YASA (dev).

simulate_hypnogram([tib, trans_probas, ...])

Simulate a hypnogram based on transition probabilities.

EpochByEpochAgreement(ref_hyps, obs_hyps)

Evaluate agreement between two hypnograms or two collections of hypnograms.

SleepStatsAgreement(ref_data, obs_data, *[, ...])

Evaluate agreement between sleep statistics reported by two different scorers.

Spectral analyses

bandpower(data[, sf, ch_names, hypno, ...])

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

bandpower_from_psd(psd, freqs[, ch_names, ...])

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

bandpower_from_psd_ndarray(psd, freqs[, ...])

Compute bandpowers in N-dimensional PSD.

irasa(data[, sf, ch_names, band, hset, ...])

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

moving_transform(x[, y, sf, window, step, ...])

Moving transformation of one or two time-series.

plot_spectrogram(data, sf[, hypno, win_sec, ...])

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

sliding_window(data, sf, window[, step, axis])

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

stft_power(data, sf[, window, step, band, ...])

Compute the pointwise power via STFT and interpolation.

topoplot(data[, montage, vmin, vmax, mask, ...])

Topoplot.

Heart rate analysis

hrv_stage(data, sf, *[, hypno, include, ...])

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