spectrogram¶
- spectrogram(line: BaseEpochs, freqs: ndarray, baseline: BaseEpochs = None, n_cycles: ndarray = None, pad: str = '0s', correction: str = 'ratio', verbose: int = None, **kwargs) AverageTFRArray[source][source]¶
- spectrogram(line: BaseRaw, freqs: ndarray, line_event: str, tmin: float, tmax: float, base_event: str = None, base_tmin: float = None, base_tmax: float = None, n_cycles: ndarray = None, pad: str = '500ms', correction: str = 'ratio', **kwargs) AverageTFRArray
Calculate the multitapered, baseline corrected spectrogram
- Parameters:
line (
Epochs) – The data to be processedfreqs (
array-like | None) – The frequencies at which to compute the power estimates. Must be an array of shape (n_freqs,).None(the default) only works when using__setstate__and will raise an error otherwise.baseline (
Epochs) – The baseline to be used for correctionn_cycles (
int | arrayofint,shape (n_freqs,)) – Number of cycles in the wavelet, either a fixed number or one per frequency. The number of cyclesn_cyclesand the frequencies of interestfreqsdefine the temporal window length. See notes for additional information about the relationship between those arguments and about time and frequency smoothing.pad (
str) – The amount of padding to be removed in the spectrogramcorrection (
str) – The type of baseline correction to be usedverbose (
bool | str | int | None) – Control verbosity of the logging output. IfNone, use the default verbosity level. See the logging documentation andmne.verbose()for details. Should only be passed as a keyword argument.
- Return type:
Notes
In MNE-Python’s multitaper functions, the frequency bandwidth is additionally affected by the parameter
time_bandwidth. Then_cyclesparameter determines the temporal window length based on the frequencies of interest: \(T = \frac{\mathtt{n\_cycles}}{\mathtt{freqs}}\). Thetime_bandwidthparameter defines the “time-bandwidth product”, which is the product of the temporal window length (in seconds) and the frequency bandwidth (in Hz). Thus oncen_cycleshas been set, frequency bandwidth is determined by \(\frac{\mathrm{time~bandwidth}}{\mathrm{time~window}}\), and thus passing a largertime_bandwidthvalue will increase the frequency bandwidth (thereby decreasing the frequency resolution).The increased frequency bandwidth is reached by averaging spectral estimates obtained from multiple tapers. Thus,
time_bandwidthalso determines the number of tapers used. MNE-Python uses only “good” tapers (tapers with minimal leakage from far-away frequencies); the number of good tapers isfloor(time_bandwidth - 1). This means there is another trade-off at play, between frequency resolution and the variance reduction that multitaper analysis provides. Striving for finer frequency resolution (by settingtime_bandwidthlow) means fewer tapers will be used, which undermines what is unique about multitaper methods — namely their ability to improve accuracy / reduce noise in the power estimates by using several (orthogonal) tapers.Warning
In
tfr_array_multitaperandtfr_multitaper,time_bandwidthdefines the product of the temporal window length with the full frequency bandwidth For example, a full bandwidth of 4 Hz at a frequency of interest of 10 Hz will “smear” the frequency estimate between 8 Hz and 12 Hz.This is not the case for
psd_array_multitaperwhere the argumentbandwidthdefines the half frequency bandwidth. In the example above, the half-frequency bandwidth is 2 Hz.- Returns:
power – The multitapered, baseline corrected spectrogram
- Return type:
AverageTFR- Parameters:
line (BaseEpochs)
freqs (ndarray)
baseline (BaseEpochs)
n_cycles (ndarray)
pad (str)
correction (str)
verbose (int)