borsar.freq.compute_rest_psd

borsar.freq.compute_rest_psd(raw, events=None, event_id=None, tmin=None, tmax=None, winlen=2.0, step=0.5)[source]

Compute power spectral density (psd) for given time segments for all channels of given raw file. The segments (if more than one) are averaged taking into account the artifact-free range of each segment. Signal during _BAD annotations (parts of signal marked as artifacts) is excluded by default in mne.time_frequency.psd_welch which can lead to some segments ‘donating’ more data than others. This has to be taken into account during segments averaging - so the segments are weighted with the percentage of welch windows that had artifact free data (and thus were not rejected in mne.time_frequency.psd_welch).

Parameters:
raw: mne.Raw

Raw file to use.

events: numpy array | None

Mne events array of shape (n_events, 3). If None (default) tmin and tmax are not calculated with respect to events but the whole time range of the raw file.

event_id: list | numpy array

Event types to use in defining segments for which psd is computed. If None (default) and events were passed all event types are used.

tmin: float

Lower edge of each segment in seconds. If events are given the lower edge is with respect to each event. If events are not given only one segment is used and tmin denotes the lower edge of the whole raw file.

tmax: float

Higher edge of each segment in seconds. If events are given the higher edge is with respect to each event. If events are not given only one segment is used and tmax denotes the higher edge of the whole raw file.

winlen: float

Length of the welch window in seconds.

step: float

Step of the welch window in seconds.

Returns:
psd : numpy array

Power spectral density in <FIX: check shape> matrix.

freq : numpy array

Frequencies for which psd was calculated.