mne.viz.plot_raw_psd#
- mne.viz.plot_raw_psd(raw, fmin=0, fmax=inf, tmin=None, tmax=None, proj=False, n_fft=None, n_overlap=0, reject_by_annotation=True, picks=None, ax=None, color='black', xscale='linear', area_mode='std', area_alpha=0.33, dB=True, estimate='power', show=True, n_jobs=None, average=False, line_alpha=None, spatial_colors=True, sphere=None, window='hamming', exclude='bads', verbose=None)[source]#
Warning
LEGACY: New code should use Raw.compute_psd().plot().
Plot power or amplitude spectra.
Separate plots are drawn for each channel type. When the data have been processed with a bandpass, lowpass or highpass filter, dashed lines (╎) indicate the boundaries of the filter. The line noise frequency is also indicated with a dashed line (⋮). If
average=False
, the plot will be interactive, and click-dragging on the spectrum will generate a scalp topography plot for the chosen frequency range in a new figure.- Parameters:
- rawinstance of
Raw
The raw object.
- fmin, fmax
float
The lower- and upper-bound on frequencies of interest. Default is
fmin=0, fmax=np.inf
(spans all frequencies present in the data).- tmin, tmax
float
|None
First and last times to include, in seconds.
None
uses the first or last time present in the data. Default istmin=None, tmax=None
(all times).- projbool
Whether to apply SSP projection vectors before spectral estimation. Default is
False
.- n_fft
int
|None
Number of points to use in Welch FFT calculations. Default is
None
, which uses the minimum of 2048 and the number of time points.- n_overlap
int
The number of points of overlap between blocks. The default value is 0 (no overlap).
- reject_by_annotationbool
Whether to omit bad spans of data before spectral estimation. If
True
, spans with annotations whose description begins withbad
will be omitted.- picks
str
| array_like |slice
|None
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). Note that channels ininfo['bads']
will be included if their names or indices are explicitly provided.- axinstance of
Axes
|list
ofAxes
|None
The axes to plot into. If
None
, a newFigure
will be created with the correct number of axes. IfAxes
are provided (either as a single instance or alist
of axes), the number of axes provided must match the number of channel types present in the object.. Default isNone
.- color
str
|tuple
A matplotlib-compatible color to use. Has no effect when spatial_colors=True.
- xscale‘linear’ | ‘log’
Scale of the frequency axis. Default is
'linear'
.- area_mode
str
|None
Mode for plotting area. If ‘std’, the mean +/- 1 STD (across channels) will be plotted. If ‘range’, the min and max (across channels) will be plotted. Bad channels will be excluded from these calculations. If None, no area will be plotted. If average=False, no area is plotted.
- area_alpha
float
Alpha for the area.
- dBbool
Plot Power Spectral Density (PSD), in units (amplitude**2/Hz (dB)) if
dB=True
, andestimate='power'
orestimate='auto'
. Plot PSD in units (amplitude**2/Hz) ifdB=False
and,estimate='power'
. Plot Amplitude Spectral Density (ASD), in units (amplitude/sqrt(Hz)), ifdB=False
andestimate='amplitude'
orestimate='auto'
. Plot ASD, in units (amplitude/sqrt(Hz) (dB)), ifdB=True
andestimate='amplitude'
.- estimate
str
, {‘power’, ‘amplitude’} Can be “power” for power spectral density (PSD; default), “amplitude” for amplitude spectrum density (ASD).
- showbool
Show the figure if
True
.- n_jobs
int
|None
The number of jobs to run in parallel. If
-1
, it is set to the number of CPU cores. Requires thejoblib
package.None
(default) is a marker for ‘unset’ that will be interpreted asn_jobs=1
(sequential execution) unless the call is performed under ajoblib.parallel_config
context manager that sets another value forn_jobs
.- averagebool
If False, the PSDs of all channels is displayed. No averaging is done and parameters area_mode and area_alpha are ignored. When False, it is possible to paint an area (hold left mouse button and drag) to plot a topomap.
- line_alpha
float
|None
Alpha for the PSD line. Can be None (default) to use 1.0 when
average=True
and 0.1 whenaverage=False
.- spatial_colorsbool
Whether to color spectrum lines by channel location. Ignored if
average=True
.- sphere
float
| array_like | instance ofConductorModel
|None
| ‘auto’ | ‘eeglab’ The sphere parameters to use for the head outline. Can be array-like of shape (4,) to give the X/Y/Z origin and radius in meters, or a single float to give just the radius (origin assumed 0, 0, 0). Can also be an instance of a spherical
ConductorModel
to use the origin and radius from that object. If'auto'
the sphere is fit to digitization points. If'eeglab'
the head circle is defined by EEG electrodes'Fpz'
,'Oz'
,'T7'
, and'T8'
(if'Fpz'
is not present, it will be approximated from the coordinates of'Oz'
).None
(the default) is equivalent to'auto'
when enough extra digitization points are available, and (0, 0, 0, 0.095) otherwise.New in v0.20.
Changed in version 1.1: Added
'eeglab'
option.- window
str
|float
|tuple
Windowing function to use. See
scipy.signal.get_window()
.New in v0.22.0.
- exclude
list
ofstr
| ‘bads’ Channels names to exclude from being shown. If ‘bads’, the bad channels are excluded. Pass an empty list to plot all channels (including channels marked “bad”, if any).
New in v0.24.0.
- verbosebool |
str
|int
|None
Control verbosity of the logging output. If
None
, use the default verbosity level. See the logging documentation andmne.verbose()
for details. Should only be passed as a keyword argument.
- rawinstance of
- Returns:
- figinstance of
Figure
Figure with frequency spectra of the data channels.
- figinstance of
Notes
This function exists to support legacy code; for new code the preferred idiom is
inst.compute_psd().plot()
(whereinst
is an instance ofRaw
,Epochs
, orEvoked
).