API reference

Detection

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

Rapid Eye Movements (REMs) detection.

spindles_detect(data, sf[, hypno, include, …])

Spindles detection.

spindles_detect_multi(data[, sf, ch_names, …])

Multi-channel spindles detection.

sw_detect(data, sf[, hypno, include, …])

Slow-waves detection.

sw_detect_multi(data[, sf, ch_names])

Multi-channel slow-waves detection.

get_bool_vector([data, sf, detection])

Return a Boolean vector given the original data and sf and a YASA’s detection dataframe.

get_sync_events([data, sf, detection, …])

Return the raw data of each detected slow-waves / spindles, after centering to a specific timepoint.

Hypnogram

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.

transition_matrix(hypno)

Create a state-transition matrix from an hypnogram.

sleep_statistics(hypno, sf_hyp)

Compute sleep stats from an hypnogram vector.

Signal processing

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

Moving transformation of one or two time-series.

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

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

trimbothstd(x[, cut])

Slices off a proportion of items from both ends of an array and then compute the sample standard deviation.

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.

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.

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

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

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

Compute the pointwise power via STFT and interpolation.