mne.EvokedArray¶
-
class
mne.
EvokedArray
(data, info, tmin=0.0, comment='', nave=1, kind='average', verbose=None)[source]¶ Evoked object from numpy array.
- Parameters
- data
array
of shape (n_channels, n_times) The channels’ evoked response. See notes for proper units of measure.
- infoinstance of
Info
Info dictionary. Consider using
create_info
to populate this structure.- tmin
float
Start time before event. Defaults to 0.
- comment
str
Comment on dataset. Can be the condition. Defaults to ‘’.
- nave
int
Number of averaged epochs. Defaults to 1.
- kind
str
Type of data, either average or standard_error. Defaults to ‘average’.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more).
- data
See also
Notes
Proper units of measure: * V: eeg, eog, seeg, emg, ecg, bio, ecog * T: mag * T/m: grad * M: hbo, hbr * Am: dipole * AU: misc
Attributes
Channel names.
The current gradient compensation grade.
The data matrix.
Whether or not projections are active.
Methods
__contains__
(self, ch_type)Check channel type membership.
__hash__
(self)Hash the object.
__neg__
(self)Negate channel responses.
add_channels
(self, add_list[, force_update_info])Append new channels to the instance.
add_proj
(self, projs[, remove_existing, verbose])Add SSP projection vectors.
animate_topomap
(self[, ch_type, times, …])Make animation of evoked data as topomap timeseries.
anonymize
(self)Anonymize measurement information in place.
apply_baseline
(self[, baseline, verbose])Baseline correct evoked data.
apply_hilbert
(self[, picks, envelope, …])Compute analytic signal or envelope for a subset of channels.
apply_proj
(self)Apply the signal space projection (SSP) operators to the data.
as_type
(self[, ch_type, mode])Compute virtual evoked using interpolated fields.
copy
(self)Copy the instance of evoked.
crop
(self[, tmin, tmax])Crop data to a given time interval.
decimate
(self, decim[, offset])Decimate the evoked data.
del_proj
(self[, idx])Remove SSP projection vector.
detrend
(self[, order, picks])Detrend data.
drop_channels
(self, ch_names)Drop channel(s).
filter
(self, l_freq, h_freq[, picks, …])Filter a subset of channels.
get_peak
(self[, ch_type, tmin, tmax, mode, …])Get location and latency of peak amplitude.
interpolate_bads
(self[, reset_bads, mode, …])Interpolate bad MEG and EEG channels.
pick
(self, picks[, exclude])Pick a subset of channels.
pick_channels
(self, ch_names)Pick some channels.
pick_types
(self[, meg, eeg, stim, eog, ecg, …])Pick some channels by type and names.
plot
(self[, picks, exclude, unit, show, …])Plot evoked data using butterfly plots.
plot_field
(self, surf_maps[, time, …])Plot MEG/EEG fields on head surface and helmet in 3D.
plot_image
(self[, picks, exclude, unit, …])Plot evoked data as images.
plot_joint
(self[, times, title, picks, …])Plot evoked data as butterfly plot and add topomaps for time points.
plot_projs_topomap
(self[, ch_type, layout, axes])Plot SSP vector.
plot_sensors
(self[, kind, ch_type, title, …])Plot sensor positions.
plot_topo
(self[, layout, layout_scale, …])Plot 2D topography of evoked responses.
plot_topomap
(self[, times, ch_type, layout, …])Plot topographic maps of specific time points of evoked data.
plot_white
(self, noise_cov[, show, rank, …])Plot whitened evoked response.
rename_channels
(self, mapping)Rename channels.
reorder_channels
(self, ch_names)Reorder channels.
resample
(self, sfreq[, npad, window, …])Resample data.
save
(self, fname)Save dataset to file.
savgol_filter
(self, h_freq[, verbose])Filter the data using Savitzky-Golay polynomial method.
set_channel_types
(self, mapping)Define the sensor type of channels.
set_eeg_reference
(self[, ref_channels, …])Specify which reference to use for EEG data.
set_montage
(self, montage[, set_dig, verbose])Set EEG sensor configuration and head digitization.
shift_time
(self, tshift[, relative])Shift time scale in evoked data.
time_as_index
(self, times[, use_rounding])Convert time to indices.
to_data_frame
(self[, picks, index, …])Export data in tabular structure as a pandas DataFrame.
-
__contains__
(self, ch_type)[source]¶ Check channel type membership.
- Parameters
- ch_type
str
Channel type to check for. Can be e.g. ‘meg’, ‘eeg’, ‘stim’, etc.
- ch_type
- Returns
- inbool
Whether or not the instance contains the given channel type.
Examples
Channel type membership can be tested as:
>>> 'meg' in inst True >>> 'seeg' in inst False
-
__neg__
(self)[source]¶ Negate channel responses.
- Returns
- evoked_neginstance of
Evoked
The Evoked instance with channel data negated and ‘-‘ prepended to the comment.
- evoked_neginstance of
-
add_channels
(self, add_list, force_update_info=False)[source]¶ Append new channels to the instance.
- Parameters
- add_list
list
A list of objects to append to self. Must contain all the same type as the current object
- force_update_infobool
If True, force the info for objects to be appended to match the values in self. This should generally only be used when adding stim channels for which important metadata won’t be overwritten.
New in version 0.12.
- add_list
- Returns
See also
Notes
If
self
is a Raw instance that has been preloaded into anumpy.memmap
instance, the memmap will be resized.
-
add_proj
(self, projs, remove_existing=False, verbose=None)[source]¶ Add SSP projection vectors.
- Parameters
- projs
list
List with projection vectors.
- remove_existingbool
Remove the projection vectors currently in the file.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). Defaults to self.verbose.
- projs
- Returns
-
animate_topomap
(self, ch_type=None, times=None, frame_rate=None, butterfly=False, blit=True, show=True, time_unit='s')[source]¶ Make animation of evoked data as topomap timeseries.
The animation can be paused/resumed with left mouse button. Left and right arrow keys can be used to move backward or forward in time.
- Parameters
- ch_type
str
|None
Channel type to plot. Accepted data types: ‘mag’, ‘grad’, ‘eeg’. If None, first available channel type from (‘mag’, ‘grad’, ‘eeg’) is used. Defaults to None.
- times
array
offloat
|None
The time points to plot. If None, 10 evenly spaced samples are calculated over the evoked time series. Defaults to None.
- frame_rate
int
|None
Frame rate for the animation in Hz. If None, frame rate = sfreq / 10. Defaults to None.
- butterflybool
Whether to plot the data as butterfly plot under the topomap. Defaults to False.
- blitbool
Whether to use blit to optimize drawing. In general, it is recommended to use blit in combination with
show=True
. If you intend to save the animation it is better to disable blit. Defaults to True.- showbool
Whether to show the animation. Defaults to True.
- time_unit
str
The units for the time axis, can be “ms” (default in 0.16) or “s” (will become the default in 0.17).
New in version 0.16.
- ch_type
- Returns
- figinstance of
matplotlib.figure.Figure
The figure.
- animinstance of
matplotlib.animation.FuncAnimation
Animation of the topomap.
- figinstance of
Notes
New in version 0.12.0.
-
anonymize
(self)[source]¶ Anonymize measurement information in place.
Reset ‘subject_info’, ‘meas_date’, ‘file_id’, and ‘meas_id’ keys if they exist in
info
.- Returns
- infoinstance of
Info
Measurement information for the dataset.
- infoinstance of
Notes
Operates in place.
New in version 0.13.0.
-
apply_baseline
(self, baseline=(None, 0), verbose=None)[source]¶ Baseline correct evoked data.
- Parameters
- baseline
tuple
of length 2 The time interval to apply baseline correction. If None do not apply it. If baseline is (a, b) the interval is between “a (s)” and “b (s)”. If a is None the beginning of the data is used and if b is None then b is set to the end of the interval. If baseline is equal to (None, None) all the time interval is used. Correction is applied by computing mean of the baseline period and subtracting it from the data. The baseline (a, b) includes both endpoints, i.e. all timepoints t such that a <= t <= b.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). Defaults to self.verbose.
- baseline
- Returns
- evokedinstance of
Evoked
The baseline-corrected Evoked object.
- evokedinstance of
Notes
Baseline correction can be done multiple times.
New in version 0.13.0.
-
apply_hilbert
(self, picks=None, envelope=False, n_jobs=1, n_fft='auto', verbose=None)[source]¶ Compute analytic signal or envelope for a subset of channels.
- Parameters
- picks
str
|list
|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 all data channels(excluding reference MEG channels).- envelopebool (default:
False
) Compute the envelope signal of each channel. See Notes.
- n_jobs: int
Number of jobs to run in parallel.
- n_fft
int
|None
|str
Points to use in the FFT for Hilbert transformation. The signal will be padded with zeros before computing Hilbert, then cut back to original length. If None, n == self.n_times. If ‘auto’, the next highest fast FFT length will be use.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). Defaults to self.verbose.
- picks
- Returns
Notes
Parameters
If
envelope=False
, the analytic signal for the channels defined inpicks
is computed and the data of the Raw object is converted to a complex representation (the analytic signal is complex valued).If
envelope=True
, the absolute value of the analytic signal for the channels defined inpicks
is computed, resulting in the envelope signal.If envelope=False, more memory is required since the original raw data as well as the analytic signal have temporarily to be stored in memory. If n_jobs > 1, more memory is required as
len(picks) * n_times
additional time points need to be temporaily stored in memory.Also note that the
n_fft
parameter will allow you to pad the signal with zeros before performing the Hilbert transform. This padding is cut off, but it may result in a slightly different result (particularly around the edges). Use at your own risk.Analytic signal
The analytic signal “x_a(t)” of “x(t)” is:
x_a = F^{-1}(F(x) 2U) = x + i y
where “F” is the Fourier transform, “U” the unit step function, and “y” the Hilbert transform of “x”. One usage of the analytic signal is the computation of the envelope signal, which is given by “e(t) = abs(x_a(t))”. Due to the linearity of Hilbert transform and the MNE inverse solution, the enevlope in source space can be obtained by computing the analytic signal in sensor space, applying the MNE inverse, and computing the envelope in source space.
-
apply_proj
(self)[source]¶ Apply the signal space projection (SSP) operators to the data.
Notes
Once the projectors have been applied, they can no longer be removed. It is usually not recommended to apply the projectors at too early stages, as they are applied automatically later on (e.g. when computing inverse solutions). Hint: using the copy method individual projection vectors can be tested without affecting the original data. With evoked data, consider the following example:
projs_a = mne.read_proj('proj_a.fif') projs_b = mne.read_proj('proj_b.fif') # add the first, copy, apply and see ... evoked.add_proj(a).copy().apply_proj().plot() # add the second, copy, apply and see ... evoked.add_proj(b).copy().apply_proj().plot() # drop the first and see again evoked.copy().del_proj(0).apply_proj().plot() evoked.apply_proj() # finally keep both
-
as_type
(self, ch_type='grad', mode='fast')[source]¶ Compute virtual evoked using interpolated fields.
Warning
Using virtual evoked to compute inverse can yield unexpected results. The virtual channels have ‘_v’ appended at the end of the names to emphasize that the data contained in them are interpolated.
- Parameters
- Returns
- evokedinstance of
mne.Evoked
The transformed evoked object containing only virtual channels.
- evokedinstance of
Notes
New in version 0.9.0.
-
property
ch_names
¶ Channel names.
-
property
compensation_grade
¶ The current gradient compensation grade.
-
crop
(self, tmin=None, tmax=None)[source]¶ Crop data to a given time interval.
- Parameters
- Returns
- evokedinstance of
Evoked
The cropped Evoked object.
- evokedinstance of
Notes
Unlike Python slices, MNE time intervals include both their end points; crop(tmin, tmax) returns the interval tmin <= t <= tmax.
-
property
data
¶ The data matrix.
-
decimate
(self, decim, offset=0)[source]¶ Decimate the evoked data.
Note
No filtering is performed. To avoid aliasing, ensure your data are properly lowpassed.
- Parameters
- Returns
- evokedinstance of
Evoked
The decimated Evoked object.
- evokedinstance of
Notes
Decimation can be done multiple times. For example,
evoked.decimate(2).decimate(2)
will be the same asevoked.decimate(4)
.New in version 0.13.0.
-
del_proj
(self, idx='all')[source]¶ Remove SSP projection vector.
- Note: The projection vector can only be removed if it is inactive
(has not been applied to the data).
-
detrend
(self, order=1, picks=None)[source]¶ Detrend data.
This function operates in-place.
- Parameters
- order
int
Either 0 or 1, the order of the detrending. 0 is a constant (DC) detrend, 1 is a linear detrend.
- picks
str
|list
|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.
- order
- Returns
- evokedinstance of
Evoked
The detrended evoked object.
- evokedinstance of
-
drop_channels
(self, ch_names)[source]¶ Drop channel(s).
- Parameters
- Returns
See also
Notes
New in version 0.9.0.
-
filter
(self, l_freq, h_freq, picks=None, filter_length='auto', l_trans_bandwidth='auto', h_trans_bandwidth='auto', n_jobs=1, method='fir', iir_params=None, phase='zero', fir_window='hamming', fir_design='firwin', pad='edge', verbose=None)[source]¶ Filter a subset of channels.
- Parameters
- l_freq
float
|None
For FIR filters, the lower pass-band edge; for IIR filters, the upper cutoff frequency. If None the data are only low-passed.
- h_freq
float
|None
For FIR filters, the upper pass-band edge; for IIR filters, the upper cutoff frequency. If None the data are only low-passed.
- picks
str
|list
|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 all data channels.- filter_length
str
|int
Length of the FIR filter to use (if applicable):
‘auto’ (default): The filter length is chosen based on the size of the transition regions (6.6 times the reciprocal of the shortest transition band for fir_window=’hamming’ and fir_design=”firwin2”, and half that for “firwin”).
str: A human-readable time in units of “s” or “ms” (e.g., “10s” or “5500ms”) will be converted to that number of samples if
phase="zero"
, or the shortest power-of-two length at least that duration forphase="zero-double"
.int: Specified length in samples. For fir_design=”firwin”, this should not be used.
- l_trans_bandwidth
float
|str
Width of the transition band at the low cut-off frequency in Hz (high pass or cutoff 1 in bandpass). Can be “auto” (default) to use a multiple of
l_freq
:min(max(l_freq * 0.25, 2), l_freq)
Only used for
method='fir'
.- h_trans_bandwidth
float
|str
Width of the transition band at the high cut-off frequency in Hz (low pass or cutoff 2 in bandpass). Can be “auto” (default in 0.14) to use a multiple of
h_freq
:min(max(h_freq * 0.25, 2.), info['sfreq'] / 2. - h_freq)
Only used for
method='fir'
.- n_jobs
int
|str
Number of jobs to run in parallel. Can be ‘cuda’ if
cupy
is installed properly and method=’fir’.- method
str
‘fir’ will use overlap-add FIR filtering, ‘iir’ will use IIR forward-backward filtering (via filtfilt).
- iir_params
dict
|None
Dictionary of parameters to use for IIR filtering. If iir_params is None and method=”iir”, 4th order Butterworth will be used. For more information, see
mne.filter.construct_iir_filter()
.- phase
str
Phase of the filter, only used if
method='fir'
. Symmetric linear-phase FIR filters are constructed, and ifphase='zero'
(default), the delay of this filter is compensated for, making it non-causal. Ifphase=='zero-double'
, then this filter is applied twice, once forward, and once backward (also making it non-causal). If ‘minimum’, then a minimum-phase filter will be constricted and applied, which is causal but has weaker stop-band suppression.New in version 0.13.
- fir_window
str
The window to use in FIR design, can be “hamming” (default), “hann” (default in 0.13), or “blackman”.
New in version 0.15.
- fir_design
str
Can be “firwin” (default) to use
scipy.signal.firwin()
, or “firwin2” to usescipy.signal.firwin2()
. “firwin” uses a time-domain design technique that generally gives improved attenuation using fewer samples than “firwin2”.New in version 0.15.
- pad
str
The type of padding to use. Supports all
numpy.pad()
mode
options. Can also be “reflect_limited”, which pads with a reflected version of each vector mirrored on the first and last values of the vector, followed by zeros. Only used formethod='fir'
. The default is'edge'
, which pads with the edge values of each vector.- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). Defaults to self.verbose.
- l_freq
- Returns
See also
Notes
Applies a zero-phase low-pass, high-pass, band-pass, or band-stop filter to the channels selected by
picks
. The data are modified inplace.The object has to have the data loaded e.g. with
preload=True
orself.load_data()
.l_freq
andh_freq
are the frequencies below which and above which, respectively, to filter out of the data. Thus the uses are:l_freq < h_freq
: band-pass filterl_freq > h_freq
: band-stop filterl_freq is not None and h_freq is None
: high-pass filterl_freq is None and h_freq is not None
: low-pass filter
self.info['lowpass']
andself.info['highpass']
are only updated with picks=None.Note
If n_jobs > 1, more memory is required as
len(picks) * n_times
additional time points need to be temporaily stored in memory.New in version 0.15.
-
get_peak
(self, ch_type=None, tmin=None, tmax=None, mode='abs', time_as_index=False, merge_grads=False, return_amplitude=False)[source]¶ Get location and latency of peak amplitude.
- Parameters
- ch_type‘mag’, ‘grad’, ‘eeg’, ‘seeg’, ‘ecog’, ‘hbo’, hbr’, ‘misc’,
None
The channel type to use. Defaults to None. If more than one sensor Type is present in the data the channel type has to be explicitly set.
- tmin
float
|None
The minimum point in time to be considered for peak getting. If None (default), the beginning of the data is used.
- tmax
float
|None
The maximum point in time to be considered for peak getting. If None (default), the end of the data is used.
- mode{‘pos’, ‘neg’, ‘abs’}
How to deal with the sign of the data. If ‘pos’ only positive values will be considered. If ‘neg’ only negative values will be considered. If ‘abs’ absolute values will be considered. Defaults to ‘abs’.
- time_as_indexbool
Whether to return the time index instead of the latency in seconds.
- merge_gradsbool
If True, compute peak from merged gradiometer data.
- return_amplitudebool
If True, return also the amplitude at the maximum response.
New in version 0.16.
- ch_type‘mag’, ‘grad’, ‘eeg’, ‘seeg’, ‘ecog’, ‘hbo’, hbr’, ‘misc’,
- Returns
-
interpolate_bads
(self, reset_bads=True, mode='accurate', origin=(0.0, 0.0, 0.04), verbose=None)[source]¶ Interpolate bad MEG and EEG channels.
Operates in place.
- Parameters
- reset_badsbool
If True, remove the bads from info.
- mode
str
Either
'accurate'
or'fast'
, determines the quality of the Legendre polynomial expansion used for interpolation of MEG channels.- originarray_like, shape (3,) |
str
Origin of the sphere in the head coordinate frame and in meters. Can be
'auto'
, which means a head-digitization-based origin fit. Default is(0., 0., 0.04)
.New in version 0.17.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). Defaults to self.verbose.
- Returns
Notes
New in version 0.9.0.
-
pick
(self, picks, exclude=())[source]¶ Pick a subset of channels.
- Parameters
- picks
str
|list
|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 all channels.- exclude
list
|str
Set of channels to exclude, only used when picking based on types (e.g., exclude=”bads” when picks=”meg”).
- picks
- Returns
-
pick_channels
(self, ch_names)[source]¶ Pick some channels.
- Parameters
- ch_names
list
The list of channels to select.
- ch_names
- Returns
See also
Notes
The channel names given are assumed to be a set, i.e. the order does not matter. The original order of the channels is preserved. You can use
reorder_channels
to set channel order if necessary.New in version 0.9.0.
-
pick_types
(self, meg=True, eeg=False, stim=False, eog=False, ecg=False, emg=False, ref_meg='auto', misc=False, resp=False, chpi=False, exci=False, ias=False, syst=False, seeg=False, dipole=False, gof=False, bio=False, ecog=False, fnirs=False, include=(), exclude='bads', selection=None, verbose=None)[source]¶ Pick some channels by type and names.
- Parameters
- megbool |
str
If True include all MEG channels. If False include None If string it can be ‘mag’, ‘grad’, ‘planar1’ or ‘planar2’ to select only magnetometers, all gradiometers, or a specific type of gradiometer.
- eegbool
If True include EEG channels.
- stimbool
If True include stimulus channels.
- eogbool
If True include EOG channels.
- ecgbool
If True include ECG channels.
- emgbool
If True include EMG channels.
- ref_meg: bool | str
If True include CTF / 4D reference channels. If ‘auto’, the reference channels are only included if compensations are present.
- miscbool
If True include miscellaneous analog channels.
- respbool
If True include response-trigger channel. For some MEG systems this is separate from the stim channel.
- chpibool
If True include continuous HPI coil channels.
- excibool
Flux excitation channel used to be a stimulus channel.
- iasbool
Internal Active Shielding data (maybe on Triux only).
- systbool
System status channel information (on Triux systems only).
- seegbool
Stereotactic EEG channels.
- dipolebool
Dipole time course channels.
- gofbool
Dipole goodness of fit channels.
- biobool
Bio channels.
- ecogbool
Electrocorticography channels.
- fnirsbool |
str
Functional near-infrared spectroscopy channels. If True include all fNIRS channels. If False (default) include none. If string it can be ‘hbo’ (to include channels measuring oxyhemoglobin) or ‘hbr’ (to include channels measuring deoxyhemoglobin).
- include
list
ofstr
List of additional channels to include. If empty do not include any.
- exclude
list
ofstr
|str
List of channels to exclude. If ‘bads’ (default), exclude channels in
info['bads']
.- selection
list
ofstr
Restrict sensor channels (MEG, EEG) to this list of channel names.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). Defaults to self.verbose.
- megbool |
- Returns
See also
Notes
New in version 0.9.0.
-
plot
(self, picks=None, exclude='bads', unit=True, show=True, ylim=None, xlim='tight', proj=False, hline=None, units=None, scalings=None, titles=None, axes=None, gfp=False, window_title=None, spatial_colors=False, zorder='unsorted', selectable=True, noise_cov=None, time_unit='s', verbose=None)[source]¶ Plot evoked data using butterfly plots.
Left click to a line shows the channel name. Selecting an area by clicking and holding left mouse button plots a topographic map of the painted area.
Note
If bad channels are not excluded they are shown in red.
- Parameters
- picks
str
|list
|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 all channels.- exclude
list
ofstr
| ‘bads’ Channels names to exclude from being shown. If ‘bads’, the bad channels are excluded.
- unitbool
Scale plot with channel (SI) unit.
- showbool
Show figure if True.
- ylim
dict
|None
ylim for plots (after scaling has been applied). e.g. ylim = dict(eeg=[-20, 20]) Valid keys are eeg, mag, grad, misc. If None, the ylim parameter for each channel equals the pyplot default.
- xlim‘tight’ |
tuple
|None
xlim for plots.
- projbool | ‘interactive’
If true SSP projections are applied before display. If ‘interactive’, a check box for reversible selection of SSP projection vectors will be shown.
- hline
list
offloat
|None
The values at which to show an horizontal line.
- units
dict
|None
The units of the channel types used for axes labels. If None, defaults to dict(eeg=’uV’, grad=’fT/cm’, mag=’fT’).
- scalings
dict
|None
The scalings of the channel types to be applied for plotting. If None, defaults to
dict(eeg=1e6, grad=1e13, mag=1e15)
.- titles
dict
|None
The titles associated with the channels. If None, defaults to dict(eeg=’EEG’, grad=’Gradiometers’, mag=’Magnetometers’).
- axesinstance of
Axes
|list
|None
The axes to plot to. If list, the list must be a list of Axes of the same length as the number of channel types. If instance of Axes, there must be only one channel type plotted.
- gfpbool | ‘only’
Plot GFP in green if True or “only”. If “only”, then the individual channel traces will not be shown.
- window_title
str
|None
The title to put at the top of the figure.
- spatial_colorsbool
If True, the lines are color coded by mapping physical sensor coordinates into color values. Spatially similar channels will have similar colors. Bad channels will be dotted. If False, the good channels are plotted black and bad channels red. Defaults to False.
- zorder
str
|callable()
Which channels to put in the front or back. Only matters if spatial_colors is used. If str, must be std or unsorted (defaults to unsorted). If std, data with the lowest standard deviation (weakest effects) will be put in front so that they are not obscured by those with stronger effects. If unsorted, channels are z-sorted as in the evoked instance. If callable, must take one argument: a numpy array of the same dimensionality as the evoked raw data; and return a list of unique integers corresponding to the number of channels.
New in version 0.13.0.
- selectablebool
Whether to use interactive features. If True (default), it is possible to paint an area to draw topomaps. When False, the interactive features are disabled. Disabling interactive features reduces memory consumption and is useful when using
axes
parameter to draw multiaxes figures.New in version 0.13.0.
- noise_covinstance of
Covariance
|str
|None
Noise covariance used to whiten the data while plotting. Whitened data channel names are shown in italic. Can be a string to load a covariance from disk. See also
mne.Evoked.plot_white()
for additional inspection of noise covariance properties when whitening evoked data. For data processed with SSS, the effective dependence between magnetometers and gradiometers may introduce differences in scaling, consider usingmne.Evoked.plot_white()
.New in version 0.16.0.
- time_unit
str
The units for the time axis, can be “ms” or “s” (default).
New in version 0.16.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more).
- picks
- Returns
- figinstance of
matplotlib.figure.Figure
Figure containing the butterfly plots.
- figinstance of
See also
-
plot_field
(self, surf_maps, time=None, time_label='t = %0.0f ms', n_jobs=1)[source]¶ Plot MEG/EEG fields on head surface and helmet in 3D.
- Parameters
- surf_maps
list
The surface mapping information obtained with make_field_map.
- time
float
|None
The time point at which the field map shall be displayed. If None, the average peak latency (across sensor types) is used.
- time_label
str
How to print info about the time instant visualized.
- n_jobs
int
The number of jobs to run in parallel (default 1). Requires the joblib package.
- surf_maps
- Returns
- figinstance of
mayavi.mlab.Figure
The mayavi figure.
- figinstance of
-
plot_image
(self, picks=None, exclude='bads', unit=True, show=True, clim=None, xlim='tight', proj=False, units=None, scalings=None, titles=None, axes=None, cmap='RdBu_r', colorbar=True, mask=None, mask_style=None, mask_cmap='Greys', mask_alpha=0.25, time_unit='s', show_names=None, group_by=None)[source]¶ Plot evoked data as images.
- Parameters
- picks
str
|list
|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 all channels. This parameter can also be used to set the order the channels are shown in, as the channel image is sorted by the order of picks.- exclude
list
ofstr
| ‘bads’ Channels names to exclude from being shown. If ‘bads’, the bad channels are excluded.
- unitbool
Scale plot with channel (SI) unit.
- showbool
Show figure if True.
- clim
dict
|None
clim for plots (after scaling has been applied). e.g. clim = dict(eeg=[-20, 20]) Valid keys are eeg, mag, grad, misc. If None, the clim parameter for each channel equals the pyplot default.
- xlim‘tight’ |
tuple
|None
xlim for plots.
- projbool | ‘interactive’
If true SSP projections are applied before display. If ‘interactive’, a check box for reversible selection of SSP projection vectors will be shown.
- units
dict
|None
The units of the channel types used for axes labels. If None, defaults to
dict(eeg='uV', grad='fT/cm', mag='fT')
.- scalings
dict
|None
The scalings of the channel types to be applied for plotting. If None,` defaults to
dict(eeg=1e6, grad=1e13, mag=1e15)
.- titles
dict
|None
The titles associated with the channels. If None, defaults to
dict(eeg='EEG', grad='Gradiometers', mag='Magnetometers')
.- axesinstance of
Axes
|list
|dict
|None
The axes to plot to. If list, the list must be a list of Axes of the same length as the number of channel types. If instance of Axes, there must be only one channel type plotted. If group_by is a dict, this cannot be a list, but it can be a dict of lists of axes, with the keys matching those of group_by. In that case, the provided axes will be used for the corresponding groups. Defaults to None.
- cmapmatplotlib colormap | (colormap, bool) | ‘interactive’
Colormap. If tuple, the first value indicates the colormap to use and the second value is a boolean defining interactivity. In interactive mode the colors are adjustable by clicking and dragging the colorbar with left and right mouse button. Left mouse button moves the scale up and down and right mouse button adjusts the range. Hitting space bar resets the scale. Up and down arrows can be used to change the colormap. If ‘interactive’, translates to
('RdBu_r', True)
. Defaults to'RdBu_r'
.- colorbarbool
If True, plot a colorbar. Defaults to True.
New in version 0.16.
- mask
ndarray
|None
An array of booleans of the same shape as the data. Entries of the data that correspond to
`False
in the mask are masked (see do_mask below). Useful for, e.g., masking for statistical significance.New in version 0.16.
- mask_style: None | ‘both’ | ‘contour’ | ‘mask’
If mask is not None: if ‘contour’, a contour line is drawn around the masked areas (
True
in mask). If ‘mask’, entries notTrue
in mask are shown transparently. If ‘both’, both a contour and transparency are used. IfNone
, defaults to ‘both’ if mask is not None, and is ignored otherwise.New in version 0.16.
- mask_cmapmatplotlib colormap | (colormap, bool) | ‘interactive’
The colormap chosen for masked parts of the image (see below), if mask is not
None
. If None, cmap is reused. Defaults toGreys
. Not interactive. Otherwise, as cmap.- mask_alpha
float
A float between 0 and 1. If mask is not None, this sets the alpha level (degree of transparency) for the masked-out segments. I.e., if 0, masked-out segments are not visible at all. Defaults to .25.
New in version 0.16.
- time_unit
str
The units for the time axis, can be “ms” or “s” (default).
New in version 0.16.
- show_namesbool |
str
Determines if channel names should be plotted on the y axis. If False, no names are shown. If True, ticks are set automatically and the corresponding channel names are shown. If str, must be “auto” or “all”. If “all”, all channel names are shown. If “auto”, is set to False if picks is
None
; toTrue
if picks is notNone
and fewer than 25 picks are shown; to “all” if picks is notNone
and contains fewer than 25 entries.- group_by
None
|dict
If a dict, the values must be picks, and axes must also be a dict with matching keys, or None. If axes is None, one figure and one axis will be created for each entry in group_by. Then, for each entry, the picked channels will be plotted to the corresponding axis. If titles are None, keys will become plot titles. This is useful for e.g. ROIs. Each entry must contain only one channel type. For example:
group_by=dict(Left_ROI=[1, 2, 3, 4], Right_ROI=[5, 6, 7, 8])
If None, all picked channels are plotted to the same axis.
- picks
- Returns
- figinstance of
matplotlib.figure.Figure
Figure containing the images.
- figinstance of
-
plot_joint
(self, times='peaks', title='', picks=None, exclude='bads', show=True, ts_args=None, topomap_args=None)[source]¶ Plot evoked data as butterfly plot and add topomaps for time points.
Note
Axes to plot in can be passed by the user through
ts_args
ortopomap_args
. In that case bothts_args
andtopomap_args
axes have to be used. Be aware that when the axes are provided, their position may be slightly modified.- Parameters
- times
float
|array
offloat
| “auto” | “peaks” The time point(s) to plot. If
"auto"
, 5 evenly spaced topographies between the first and last time instant will be shown. If"peaks"
, finds time points automatically by checking for 3 local maxima in Global Field Power. Defaults to"peaks"
.- title
str
|None
The title. If
None
, suppress printing channel type title. If an empty string, a default title is created. Defaults to ‘’. If custom axes are passed make sure to settitle=None
, otherwise some of your axes may be removed during placement of the title axis.- picks
str
|list
|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 all channels.- exclude
None
|list
ofstr
| ‘bads’ Channels names to exclude from being shown. If
'bads'
, the bad channels are excluded. Defaults toNone
.- showbool
Show figure if
True
. Defaults toTrue
.- ts_args
None
|dict
A dict of
kwargs
that are forwarded tomne.Evoked.plot()
to style the butterfly plot. If they are not in this dict, the following defaults are passed:spatial_colors=True
,zorder='std'
.show
andexclude
are illegal. IfNone
, no customizable arguments will be passed. Defaults toNone
.- topomap_args
None
|dict
A dict of kwargs that are forwarded to
mne.Evoked.plot_topomap()
to style the topomaps. If it is not in this dict,outlines='skirt'
will be passed.show
,times
,colorbar
are illegal. IfNone
, no customizable arguments will be passed. Defaults toNone
.
- times
- Returns
- figinstance of
matplotlib.figure.Figure
|list
The figure object containing the plot. If
evoked
has multiple channel types, a list of figures, one for each channel type, is returned.
- figinstance of
Notes
New in version 0.12.0.
-
plot_projs_topomap
(self, ch_type=None, layout=None, axes=None)[source]¶ Plot SSP vector.
- Parameters
- ch_type‘mag’ | ‘grad’ | ‘planar1’ | ‘planar2’ | ‘eeg’ |
None
|list
The channel type to plot. For ‘grad’, the gradiometers are collec- ted in pairs and the RMS for each pair is plotted. If None (default), it will return all channel types present. If a list of ch_types is provided, it will return multiple figures.
- layout
None
|Layout
|list
ofLayout
Layout instance specifying sensor positions (does not need to be specified for Neuromag data). If possible, the correct layout file is inferred from the data; if no appropriate layout file was found, the layout is automatically generated from the sensor locations. Or a list of Layout if projections are from different sensor types.
- axesinstance of
Axes
|list
|None
The axes to plot to. If list, the list must be a list of Axes of the same length as the number of projectors. If instance of Axes, there must be only one projector. Defaults to None.
- ch_type‘mag’ | ‘grad’ | ‘planar1’ | ‘planar2’ | ‘eeg’ |
- Returns
- figinstance of
Figure
Figure distributing one image per channel across sensor topography.
- figinstance of
-
plot_sensors
(self, kind='topomap', ch_type=None, title=None, show_names=False, ch_groups=None, to_sphere=True, axes=None, block=False, show=True)[source]¶ Plot sensor positions.
- Parameters
- kind
str
Whether to plot the sensors as 3d, topomap or as an interactive sensor selection dialog. Available options ‘topomap’, ‘3d’, ‘select’. If ‘select’, a set of channels can be selected interactively by using lasso selector or clicking while holding control key. The selected channels are returned along with the figure instance. Defaults to ‘topomap’.
- ch_type
None
|str
The channel type to plot. Available options ‘mag’, ‘grad’, ‘eeg’, ‘seeg’, ‘ecog’, ‘all’. If
'all'
, all the available mag, grad, eeg, seeg and ecog channels are plotted. If None (default), then channels are chosen in the order given above.- title
str
|None
Title for the figure. If None (default), equals to
'Sensor positions (%s)' % ch_type
.- show_namesbool |
array
ofstr
Whether to display all channel names. If an array, only the channel names in the array are shown. Defaults to False.
- ch_groups‘position’ |
array
of shape (n_ch_groups, n_picks) |None
Channel groups for coloring the sensors. If None (default), default coloring scheme is used. If ‘position’, the sensors are divided into 8 regions. See
order
kwarg ofmne.viz.plot_raw()
. If array, the channels are divided by picks given in the array.New in version 0.13.0.
- to_spherebool
Whether to project the 3d locations to a sphere. When False, the sensor array appears similar as to looking downwards straight above the subject’s head. Has no effect when kind=‘3d’. Defaults to True.
New in version 0.14.0.
- axesinstance of
Axes
| instance ofAxes3D
|None
Axes to draw the sensors to. If
kind='3d'
, axes must be an instance of Axes3D. If None (default), a new axes will be created.New in version 0.13.0.
- blockbool
Whether to halt program execution until the figure is closed. Defaults to False.
New in version 0.13.0.
- showbool
Show figure if True. Defaults to True.
- kind
- Returns
See also
Notes
This function plots the sensor locations from the info structure using matplotlib. For drawing the sensors using mayavi see
mne.viz.plot_alignment()
.New in version 0.12.0.
-
plot_topo
(self, layout=None, layout_scale=0.945, color=None, border='none', ylim=None, scalings=None, title=None, proj=False, vline=[0.0], fig_background=None, merge_grads=False, legend=True, axes=None, background_color='w', noise_cov=None, show=True)[source]¶ Plot 2D topography of evoked responses.
Clicking on the plot of an individual sensor opens a new figure showing the evoked response for the selected sensor.
- Parameters
- layoutinstance of
Layout
|None
Layout instance specifying sensor positions (does not need to be specified for Neuromag data). If possible, the correct layout is inferred from the data.
- layout_scale: float
Scaling factor for adjusting the relative size of the layout on the canvas
- color
list
of color | color |None
Everything matplotlib accepts to specify colors. If not list-like, the color specified will be repeated. If None, colors are automatically drawn.
- border
str
matplotlib borders style to be used for each sensor plot.
- ylim
dict
|None
ylim for plots (after scaling has been applied). The value determines the upper and lower subplot limits. e.g. ylim = dict(eeg=[-20, 20]). Valid keys are eeg, mag, grad, misc. If None, the ylim parameter for each channel is determined by the maximum absolute peak.
- scalings
dict
|None
The scalings of the channel types to be applied for plotting. If None,` defaults to dict(eeg=1e6, grad=1e13, mag=1e15).
- title
str
Title of the figure.
- projbool | ‘interactive’
If true SSP projections are applied before display. If ‘interactive’, a check box for reversible selection of SSP projection vectors will be shown.
- vline
list
offloat
|None
The values at which to show a vertical line.
- fig_background
None
|ndarray
A background image for the figure. This must work with a call to plt.imshow. Defaults to None.
- merge_gradsbool
Whether to use RMS value of gradiometer pairs. Only works for Neuromag data. Defaults to False.
- legendbool |
int
|str
|tuple
If True, create a legend based on evoked.comment. If False, disable the legend. Otherwise, the legend is created and the parameter value is passed as the location parameter to the matplotlib legend call. It can be an integer (e.g. 0 corresponds to upper right corner of the plot), a string (e.g. ‘upper right’), or a tuple (x, y coordinates of the lower left corner of the legend in the axes coordinate system). See matplotlib documentation for more details.
- axesinstance of matplotlib
Axes
|None
Axes to plot into. If None, axes will be created.
- background_colorcolor
Background color. Typically ‘k’ (black) or ‘w’ (white; default).
New in version 0.15.0.
- noise_covinstance of
Covariance
|str
|None
Noise covariance used to whiten the data while plotting. Whitened data channel names are shown in italic. Can be a string to load a covariance from disk.
New in version 0.16.0.
- showbool
Show figure if True.
- layoutinstance of
- Returns
- figinstance of
matplotlib.figure.Figure
Images of evoked responses at sensor locations
- figinstance of
Notes
New in version 0.10.0.
-
plot_topomap
(self, times='auto', ch_type=None, layout=None, vmin=None, vmax=None, cmap=None, sensors=True, colorbar=True, scalings=None, units=None, res=64, size=1, cbar_fmt='%3.1f', time_unit='s', time_format=None, proj=False, show=True, show_names=False, title=None, mask=None, mask_params=None, outlines='head', contours=6, image_interp='bilinear', average=None, head_pos=None, axes=None, extrapolate='box')[source]¶ Plot topographic maps of specific time points of evoked data.
- Parameters
- times
float
|array
offloat
| “auto” | “peaks” | “interactive” The time point(s) to plot. If “auto”, the number of
axes
determines the amount of time point(s). Ifaxes
is also None, at most 10 topographies will be shown with a regular time spacing between the first and last time instant. If “peaks”, finds time points automatically by checking for local maxima in global field power. If “interactive”, the time can be set interactively at run-time by using a slider.- ch_type‘mag’ | ‘grad’ | ‘planar1’ | ‘planar2’ | ‘eeg’ |
None
The channel type to plot. For ‘grad’, the gradiometers are collected in pairs and the RMS for each pair is plotted. If None, then channels are chosen in the order given above.
- layout
None
|Layout
Layout instance specifying sensor positions (does not need to be specified for Neuromag data). If possible, the correct layout file is inferred from the data; if no appropriate layout file was found, the layout is automatically generated from the sensor locations.
- vmin
float
|callable()
|None
The value specifying the lower bound of the color range. If None, and vmax is None, -vmax is used. Else np.min(data). If callable, the output equals vmin(data). Defaults to None.
- vmax
float
|callable()
|None
The value specifying the upper bound of the color range. If None, the maximum absolute value is used. If callable, the output equals vmax(data). Defaults to None.
- cmapmatplotlib colormap | (colormap, bool) | ‘interactive’ |
None
Colormap to use. If tuple, the first value indicates the colormap to use and the second value is a boolean defining interactivity. In interactive mode the colors are adjustable by clicking and dragging the colorbar with left and right mouse button. Left mouse button moves the scale up and down and right mouse button adjusts the range (zoom). The mouse scroll can also be used to adjust the range. Hitting space bar resets the range. Up and down arrows can be used to change the colormap. If None (default), ‘Reds’ is used for all positive data, otherwise defaults to ‘RdBu_r’. If ‘interactive’, translates to (None, True).
Warning
Interactive mode works smoothly only for a small amount of topomaps. Interactive mode is disabled by default for more than 2 topomaps.
- sensorsbool |
str
Add markers for sensor locations to the plot. Accepts matplotlib plot format string (e.g., ‘r+’ for red plusses). If True (default), circles will be used.
- colorbarbool |
None
Plot a colorbar in the rightmost column of the figure. None (default) is the same as True, but emits a warning if custom
axes
are provided to remind the user that the colorbar will occupy the lastmatplotlib.axes.Axes
instance.- scalings
dict
|float
|None
The scalings of the channel types to be applied for plotting. If None, defaults to
dict(eeg=1e6, grad=1e13, mag=1e15)
.- units
dict
|str
|None
The unit of the channel type used for colorbar label. If scale is None the unit is automatically determined.
- res
int
The resolution of the topomap image (n pixels along each side).
- size
float
Side length per topomap in inches.
- cbar_fmt
str
String format for colorbar values.
- time_unit
str
The units for the time axis, can be “ms” or “s” (default).
New in version 0.16.
- time_format
str
|None
String format for topomap values. Defaults (None) to “%01d ms” if
time_unit='ms'
, “%0.3f s” iftime_unit='s'
, and “%g” otherwise.- projbool | ‘interactive’
If true SSP projections are applied before display. If ‘interactive’, a check box for reversible selection of SSP projection vectors will be show.
- showbool
Show figure if True.
- show_namesbool |
callable()
If True, show channel names on top of the map. If a callable is passed, channel names will be formatted using the callable; e.g., to delete the prefix ‘MEG ‘ from all channel names, pass the function lambda x: x.replace(‘MEG ‘, ‘’). If mask is not None, only significant sensors will be shown.
- title
str
|None
Title. If None (default), no title is displayed.
- mask
ndarray
of bool, shape (n_channels, n_times) |None
The channels to be marked as significant at a given time point. Indices set to True will be considered. Defaults to None.
- mask_params
dict
|None
Additional plotting parameters for plotting significant sensors. Default (None) equals:
dict(marker='o', markerfacecolor='w', markeredgecolor='k', linewidth=0, markersize=4)
- outlines‘head’ | ‘skirt’ |
dict
|None
The outlines to be drawn. If ‘head’, the default head scheme will be drawn. If ‘skirt’ the head scheme will be drawn, but sensors are allowed to be plotted outside of the head circle. If dict, each key refers to a tuple of x and y positions, the values in ‘mask_pos’ will serve as image mask, and the ‘autoshrink’ (bool) field will trigger automated shrinking of the positions due to points outside the outline. Alternatively, a matplotlib patch object can be passed for advanced masking options, either directly or as a function that returns patches (required for multi-axis plots). If None, nothing will be drawn. Defaults to ‘head’.
- contours
int
|array
offloat
The number of contour lines to draw. If 0, no contours will be drawn. When an integer, matplotlib ticker locator is used to find suitable values for the contour thresholds (may sometimes be inaccurate, use array for accuracy). If an array, the values represent the levels for the contours. The values are in uV for EEG, fT for magnetometers and fT/m for gradiometers. If colorbar=True, the ticks in colorbar correspond to the contour levels. Defaults to 6.
- image_interp
str
The image interpolation to be used. All matplotlib options are accepted.
- average
float
|None
The time window around a given time to be used for averaging (seconds). For example, 0.01 would translate into window that starts 5 ms before and ends 5 ms after a given time point. Defaults to None, which means no averaging.
- head_pos
dict
|None
If None (default), the sensors are positioned such that they span the head circle. If dict, can have entries ‘center’ (tuple) and ‘scale’ (tuple) for what the center and scale of the head should be relative to the electrode locations.
- axesinstance of
Axes
|list
|None
The axes to plot to. If list, the list must be a list of Axes of the same length as
times
(unlesstimes
is None). If instance of Axes,times
must be a float or a list of one float. Defaults to None.- extrapolate
str
If ‘box’ (default) extrapolate to four points placed to form a square encompassing all data points, where each side of the square is three times the range of the data in the respective dimension. If ‘head’ extrapolate to the edges of the head circle (or to the edges of the skirt if
outlines='skirt'
). If ‘local’ extrapolate only to nearby points (approximately to points closer than median inter-electrode distance).New in version 0.18.
- times
- Returns
- figinstance of
matplotlib.figure.Figure
The figure.
- figinstance of
-
plot_white
(self, noise_cov, show=True, rank=None, time_unit='s', verbose=None)[source]¶ Plot whitened evoked response.
Plots the whitened evoked response and the whitened GFP as described in [1]. This function is especially useful for investigating noise covariance properties to determine if data are properly whitened (e.g., achieving expected values in line with model assumptions, see Notes below).
- Parameters
- noise_cov
list
| instance ofCovariance
|str
The noise covariance. Can be a string to load a covariance from disk.
- showbool
Show figure if True.
- rank
None
|dict
| ‘info’ | ‘full’ This controls the rank computation that can be read from the measurement info or estimated from the data. See
Notes
ofmne.compute_rank()
for details.The default is None.- time_unit
str
The units for the time axis, can be “ms” or “s” (default).
New in version 0.16.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more).
- noise_cov
- Returns
- figinstance of
matplotlib.figure.Figure
The figure object containing the plot.
- figinstance of
See also
Notes
If baseline signals match the assumption of Gaussian white noise, values should be centered at 0, and be within 2 standard deviations (±1.96) for 95% of the time points. For the global field power (GFP), we expect it to fluctuate around a value of 1.
If one single covariance object is passed, the GFP panel (bottom) will depict different sensor types. If multiple covariance objects are passed as a list, the left column will display the whitened evoked responses for each channel based on the whitener from the noise covariance that has the highest log-likelihood. The left column will depict the whitened GFPs based on each estimator separately for each sensor type. Instead of numbers of channels the GFP display shows the estimated rank. Note. The rank estimation will be printed by the logger (if
verbose=True
) for each noise covariance estimator that is passed.References
- 1
Engemann D. and Gramfort A. (2015) Automated model selection in covariance estimation and spatial whitening of MEG and EEG signals, vol. 108, 328-342, NeuroImage.
-
property
proj
¶ Whether or not projections are active.
-
rename_channels
(self, mapping)[source]¶ Rename channels.
- Parameters
- mapping
dict
|callable()
a dictionary mapping the old channel to a new channel name e.g. {‘EEG061’ : ‘EEG161’}. Can also be a callable function that takes and returns a string (new in version 0.10.0).
- mapping
Notes
New in version 0.9.0.
-
reorder_channels
(self, ch_names)[source]¶ Reorder channels.
- Parameters
- ch_names
list
The desired channel order.
- ch_names
- Returns
See also
Notes
Channel names must be unique. Channels that are not in
ch_names
are dropped.New in version 0.16.0.
-
resample
(self, sfreq, npad='auto', window='boxcar', n_jobs=1, pad='edge', verbose=None)[source]¶ Resample data.
Note
Data must be loaded.
- Parameters
- sfreq
float
New sample rate to use.
- npad
int
|str
Amount to pad the start and end of the data. Can also be “auto” to use a padding that will result in a power-of-two size (can be much faster).
- window
str
|tuple
Frequency-domain window to use in resampling. See
scipy.signal.resample()
.- n_jobs
int
|str
Number of jobs to run in parallel. Can be ‘cuda’ if
cupy
is installed properly.- pad
str
The type of padding to use. Supports all
numpy.pad()
mode
options. Can also be “reflect_limited”, which pads with a reflected version of each vector mirrored on the first and last values of the vector, followed by zeros. Only used formethod='fir'
. The default is'edge'
, which pads with the edge values of each vector.New in version 0.15.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). Defaults to self.verbose.
- sfreq
- Returns
See also
Notes
For some data, it may be more accurate to use npad=0 to reduce artifacts. This is dataset dependent – check your data!
-
save
(self, fname)[source]¶ Save dataset to file.
- Parameters
- fname
str
The name of the file, which should end with -ave.fif or -ave.fif.gz.
- fname
Notes
To write multiple conditions into a single file, use
mne.write_evokeds()
.
-
savgol_filter
(self, h_freq, verbose=None)[source]¶ Filter the data using Savitzky-Golay polynomial method.
- Parameters
- h_freq
float
Approximate high cut-off frequency in Hz. Note that this is not an exact cutoff, since Savitzky-Golay filtering [1] is done using polynomial fits instead of FIR/IIR filtering. This parameter is thus used to determine the length of the window over which a 5th-order polynomial smoothing is used.
- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). Defaults to self.verbose.
- h_freq
- Returns
See also
Notes
For Savitzky-Golay low-pass approximation, see:
New in version 0.9.0.
References
- 1
Savitzky, A., Golay, M.J.E. (1964). “Smoothing and Differentiation of Data by Simplified Least Squares Procedures”. Analytical Chemistry 36 (8): 1627-39.
Examples
>>> import mne >>> from os import path as op >>> evoked_fname = op.join(mne.datasets.sample.data_path(), 'MEG', 'sample', 'sample_audvis-ave.fif') # doctest:+SKIP >>> evoked = mne.read_evokeds(evoked_fname, baseline=(None, 0))[0] # doctest:+SKIP >>> evoked.savgol_filter(10.) # low-pass at around 10 Hz # doctest:+SKIP >>> evoked.plot() # doctest:+SKIP
-
set_channel_types
(self, mapping)[source]¶ Define the sensor type of channels.
- Note: The following sensor types are accepted:
ecg, eeg, emg, eog, exci, ias, misc, resp, seeg, stim, syst, ecog, hbo, hbr
- Parameters
- mapping
dict
a dictionary mapping a channel to a sensor type (str) {‘EEG061’: ‘eog’}.
- mapping
Notes
New in version 0.9.0.
-
set_eeg_reference
(self, ref_channels='average', projection=False, verbose=None)[source]¶ Specify which reference to use for EEG data.
By default, MNE-Python will automatically re-reference the EEG signal to use an average reference (see below). Use this function to explicitly specify the desired reference for EEG. This can be either an existing electrode or a new virtual channel. This function will re-reference the data according to the desired reference and prevent MNE-Python from automatically adding an average reference projection.
Some common referencing schemes and the corresponding value for the
ref_channels
parameter:- No re-referencing:
If the EEG data is already using the proper reference, set
ref_channels=[]
. This will prevent MNE-Python from automatically adding an average reference projection.- Average reference:
A new virtual reference electrode is created by averaging the current EEG signal by setting
ref_channels='average'
. Bad EEG channels are automatically excluded if they are properly set ininfo['bads']
.- A single electrode:
Set
ref_channels
to a list containing the name of the channel that will act as the new reference, for exampleref_channels=['Cz']
.- The mean of multiple electrodes:
A new virtual reference electrode is created by computing the average of the current EEG signal recorded from two or more selected channels. Set
ref_channels
to a list of channel names, indicating which channels to use. For example, to apply an average mastoid reference, when using the 10-20 naming scheme, setref_channels=['M1', 'M2']
.
- Parameters
- ref_channels
list
ofstr
|str
The name(s) of the channel(s) used to construct the reference. To apply an average reference, specify
'average'
here (default). If an empty list is specified, the data is assumed to already have a proper reference and MNE will not attempt any re-referencing of the data. Defaults to an average reference.- projectionbool
If
ref_channels='average'
this argument specifies if the average reference should be computed as a projection (True) or not (False; default). Ifprojection=True
, the average reference is added as a projection and is not applied to the data (it can be applied afterwards with theapply_proj
method). Ifprojection=False
, the average reference is directly applied to the data. Ifref_channels
is not'average'
,projection
must be set toFalse
(the default in this case).- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). Defaults to self.verbose.
- ref_channels
- Returns
See also
mne.set_bipolar_reference
Convenience function for creating bipolar references.
Notes
If a reference is requested that is not the average reference, this function removes any pre-existing average reference projections.
During source localization, the EEG signal should have an average reference.
In order to apply a reference, the data must be preloaded. This is not necessary if
ref_channels='average'
andprojection=True
.For an average reference, bad EEG channels are automatically excluded if they are properly set in
info['bads']
.
New in version 0.9.0.
-
set_montage
(self, montage, set_dig=True, verbose=None)[source]¶ Set EEG sensor configuration and head digitization.
- Parameters
- montageinstance of
Montage
| instance ofDigMontage
|str
|None
The montage to use (None removes any location information).
- set_digbool
If True, update the digitization information (
info['dig']
) in addition to the channel positions (info['chs'][idx]['loc']
).- verbosebool,
str
,int
, orNone
If not None, override default verbose level (see
mne.verbose()
and Logging documentation for more). Defaults to self.verbose.
- montageinstance of
Notes
Operates in place.
New in version 0.9.0.
-
shift_time
(self, tshift, relative=True)[source]¶ Shift time scale in evoked data.
- Parameters
- tshift
float
The amount of time shift to be applied if relative is True else the first time point. When relative is True, positive value of tshift moves the data forward while negative tshift moves it backward.
- relativebool
If true, move the time backwards or forwards by specified amount. Else, set the starting time point to the value of tshift.
- tshift
Notes
Maximum accuracy of time shift is 1 / evoked.info[‘sfreq’]
-
to_data_frame
(self, picks=None, index=None, scaling_time=1000.0, scalings=None, copy=True, start=None, stop=None, long_format=False)[source]¶ Export data in tabular structure as a pandas DataFrame.
Columns and indices will depend on the object being converted. Generally this will include as much relevant information as possible for the data type being converted. This makes it easy to convert data for use in packages that utilize dataframes, such as statsmodels or seaborn.
- Parameters
- picks
str
|list
|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 all channels.- index
tuple
ofstr
|None
Column to be used as index for the data. Valid string options are ‘epoch’, ‘time’ and ‘condition’. If None, all three info columns will be included in the table as categorial data.
- scaling_time
float
Scaling to be applied to time units.
- scalings
dict
|None
Scaling to be applied to the channels picked. If None, defaults to
scalings=dict(eeg=1e6, grad=1e13, mag=1e15, misc=1.0)
.- copybool
If true, data will be copied. Else data may be modified in place.
- start
int
|None
If it is a Raw object, this defines a starting index for creating the dataframe from a slice. The times will be interpolated from the index and the sampling rate of the signal.
- stop
int
|None
If it is a Raw object, this defines a stop index for creating the dataframe from a slice. The times will be interpolated from the index and the sampling rate of the signal.
- long_formatbool
If True, the dataframe is returned in long format where each row is one observation of the signal at a unique coordinate of channels, time points, epochs and conditions. The number of factors depends on the data container. For convenience, a ch_type column is added when using this option that will facilitate subsetting the resulting dataframe. Defaults to False.
- picks
- Returns
- dfinstance of
pandas.DataFrame
A dataframe suitable for usage with other statistical/plotting/analysis packages. Column/Index values will depend on the object type being converted, but should be human-readable.
- dfinstance of