yasa.hypno_upsample_to_data#

yasa.hypno_upsample_to_data(hypno, sf_hypno, data, sf_data=None, verbose=True)#

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.

Added in version 0.1.5.

Parameters:
hypnoarray_like

The sleep staging (hypnogram) 1D array.

sf_hypnofloat

The current sampling frequency of the hypnogram, in Hz, e.g.

  • 1/30 = 1 value per each 30 seconds of EEG data,

  • 1 = 1 value per second of EEG data

dataarray_like or mne.io.BaseRaw

1D or 2D EEG data. Can also be a mne.io.BaseRaw, in which case data and sf_data will be automatically extracted.

sf_datafloat

The sampling frequency of data, in Hz (e.g. 100 Hz, 256 Hz, …). Can be omitted if data is a mne.io.BaseRaw.

verbosebool or str

Verbose level. Default (False) will only print warning and error messages. The logging levels are ‘debug’, ‘info’, ‘warning’, ‘error’, and ‘critical’. For most users the choice is between ‘info’ (or verbose=True) and warning (verbose=False).

Returns:
hypnoarray_like

The hypnogram, upsampled to sf_data and cropped/padded to max(data.shape).

Warns:
UserWarning

If the upsampled hypno is shorter / longer than max(data.shape) and therefore needs to be padded/cropped respectively. This output can be disabled by passing verbose='ERROR'.