# mne.time_frequency.psd_welch¶

mne.time_frequency.psd_welch(inst, fmin=0, fmax=inf, tmin=None, tmax=None, n_fft=256, n_overlap=0, n_per_seg=None, picks=None, proj=False, n_jobs=1, reject_by_annotation=True, average='mean', verbose=None)[source]

Compute the power spectral density (PSD) using Welch’s method.

Calculates periodograms for a sliding window over the time dimension, then averages them together for each channel/epoch.

Parameters
instinstance of Epochs or Raw or Evoked

The data for PSD calculation.

fminfloat

Min frequency of interest.

fmaxfloat

Max frequency of interest.

tmin

Min time of interest.

tmax

Max time of interest.

n_fftint

The length of FFT used, must be >= n_per_seg (default: 256). The segments will be zero-padded if n_fft > n_per_seg. If n_per_seg is None, n_fft must be <= number of time points in the data.

n_overlapint

The number of points of overlap between segments. Will be adjusted to be <= n_per_seg. The default value is 0.

n_per_seg

Length of each Welch segment (windowed with a Hamming window). Defaults to None, which sets n_per_seg equal to n_fft.

picks

Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g., ['MEG0111', 'MEG2623'] will pick the given channels. Can also be the string values “all” to pick all channels, or “data” to pick data channels. None (default) will pick good data channels(excluding reference MEG channels).

projbool

Apply SSP projection vectors. If inst is ndarray this is not used.

n_jobsint

The number of jobs to run in parallel (default 1). Requires the joblib package.

reject_by_annotationbool

Whether to omit bad segments from the data while computing the PSD. If True, annotated segments with a description that starts with ‘bad’ are omitted. Has no effect if inst is an Epochs or Evoked object. Defaults to True.

New in version 0.15.0.

average

How to average the segments. If mean (default), calculate the arithmetic mean. If median, calculate the median, corrected for its bias relative to the mean. If None, returns the unaggregated segments.

New in version 0.19.0.

verbose

If not None, override default verbose level (see mne.verbose() and Logging documentation for more).

Returns
psdsndarray, shape (…, n_freqs) or (…, n_freqs, n_segments)

The power spectral densities. If average='mean or average='median' and input is of type Raw or Evoked, then psds will be of shape (n_channels, n_freqs); if input is of type Epochs, then psds will be of shape (n_epochs, n_channels, n_freqs). If average=None, the returned array will have an additional dimension corresponding to the unaggregated segments.

freqsndarray, shape (n_freqs,)

The frequencies.

Notes

New in version 0.12.0.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.23224061727523804, "perplexity": 13336.2666725351}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-16/segments/1585370521876.48/warc/CC-MAIN-20200404103932-20200404133932-00088.warc.gz"}