mne.
Evoked
(fname, condition=None, proj=True, kind='average', allow_maxshield=False, verbose=None)[source]¶Evoked data.
Parameters: |
|
---|
Notes
Evoked objects contain a single condition only.
Attributes: |
|
---|
Methods
__contains__ (ch_type) |
Check channel type membership. |
__hash__ () |
Hash the object. |
__neg__ () |
Negate channel responses. |
add_channels (add_list[, force_update_info]) |
Append new channels to the instance. |
add_proj (projs[, remove_existing, verbose]) |
Add SSP projection vectors. |
animate_topomap ([ch_type, times, …]) |
Make animation of evoked data as topomap timeseries. |
anonymize () |
Anonymize measurement information in place. |
apply_baseline ([baseline, verbose]) |
Baseline correct evoked data. |
apply_proj () |
Apply the signal space projection (SSP) operators to the data. |
as_type ([ch_type, mode]) |
Compute virtual evoked using interpolated fields. |
copy () |
Copy the instance of evoked. |
crop ([tmin, tmax]) |
Crop data to a given time interval. |
decimate (decim[, offset]) |
Decimate the evoked data. |
del_proj ([idx]) |
Remove SSP projection vector. |
detrend ([order, picks]) |
Detrend data. |
drop_channels (ch_names) |
Drop some channels. |
filter (l_freq, h_freq[, picks, …]) |
Filter a subset of channels. |
get_peak ([ch_type, tmin, tmax, mode, …]) |
Get location and latency of peak amplitude. |
interpolate_bads ([reset_bads, mode, verbose]) |
Interpolate bad MEG and EEG channels. |
pick_channels (ch_names) |
Pick some channels. |
pick_types ([meg, eeg, stim, eog, ecg, emg, …]) |
Pick some channels by type and names. |
plot ([picks, exclude, unit, show, ylim, …]) |
Plot evoked data using butterfly plots. |
plot_field (surf_maps[, time, time_label, n_jobs]) |
Plot MEG/EEG fields on head surface and helmet in 3D. |
plot_image ([picks, exclude, unit, show, …]) |
Plot evoked data as images. |
plot_joint ([times, title, picks, exclude, …]) |
Plot evoked data as butterfly plot and add topomaps for time points. |
plot_projs_topomap ([ch_type, layout, axes]) |
Plot SSP vector. |
plot_sensors ([kind, ch_type, title, …]) |
Plot sensor positions. |
plot_topo ([layout, layout_scale, color, …]) |
Plot 2D topography of evoked responses. |
plot_topomap ([times, ch_type, layout, vmin, …]) |
Plot topographic maps of specific time points of evoked data. |
plot_white (noise_cov[, show, rank, …]) |
Plot whitened evoked response. |
rename_channels (mapping) |
Rename channels. |
reorder_channels (ch_names) |
Reorder channels. |
resample (sfreq[, npad, window, n_jobs, pad, …]) |
Resample data. |
save (fname) |
Save dataset to file. |
savgol_filter (h_freq[, verbose]) |
Filter the data using Savitzky-Golay polynomial method. |
set_channel_types (mapping) |
Define the sensor type of channels. |
set_eeg_reference ([ref_channels, …]) |
Specify which reference to use for EEG data. |
set_montage (montage[, set_dig, verbose]) |
Set EEG sensor configuration and head digitization. |
shift_time (tshift[, relative]) |
Shift time scale in evoked data. |
time_as_index (times[, use_rounding]) |
Convert time to indices. |
to_data_frame ([picks, index, scaling_time, …]) |
Export data in tabular structure as a pandas DataFrame. |
__contains__
(ch_type)[source]¶Check channel type membership.
Parameters: |
|
---|---|
Returns: |
|
Examples
Channel type membership can be tested as:
>>> 'meg' in inst
True
>>> 'seeg' in inst
False
__neg__
()[source]¶Negate channel responses.
Returns: |
|
---|
add_channels
(add_list, force_update_info=False)[source]¶Append new channels to the instance.
Parameters: |
|
---|---|
Returns: |
|
See also
add_proj
(projs, remove_existing=False, verbose=None)[source]¶Add SSP projection vectors.
Parameters: |
|
---|---|
Returns: |
|
animate_topomap
(ch_type=None, times=None, frame_rate=None, butterfly=False, blit=True, show=True, time_unit=None)[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: |
|
---|---|
Returns: |
|
Notes
New in version 0.12.0.
anonymize
()[source]¶Anonymize measurement information in place.
Reset ‘subject_info’, ‘meas_date’, ‘file_id’, and ‘meas_id’ keys if they
exist in info
.
Returns: |
|
---|
Notes
Operates in place.
New in version 0.13.0.
apply_baseline
(baseline=(None, 0), verbose=None)[source]¶Baseline correct evoked data.
Parameters: |
|
---|---|
Returns: |
|
Notes
Baseline correction can be done multiple times.
New in version 0.13.0.
apply_proj
()[source]¶Apply the signal space projection (SSP) operators to the data.
Returns: |
|
---|
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
(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: |
|
Notes
New in version 0.9.0.
ch_names
¶Channel names.
compensation_grade
¶The current gradient compensation grade.
crop
(tmin=None, tmax=None)[source]¶Crop data to a given time interval.
Parameters: |
|
---|---|
Returns: |
|
Notes
Unlike Python slices, MNE time intervals include both their end points; crop(tmin, tmax) returns the interval tmin <= t <= tmax.
data
¶The data matrix.
decimate
(decim, offset=0)[source]¶Decimate the evoked data.
Note
No filtering is performed. To avoid aliasing, ensure your data are properly lowpassed.
Parameters: |
|
---|---|
Returns: |
|
See also
Notes
Decimation can be done multiple times. For example,
evoked.decimate(2).decimate(2)
will be the same as
evoked.decimate(4)
.
New in version 0.13.0.
del_proj
(idx='all')[source]¶Remove SSP projection vector.
Parameters: |
|
---|---|
Returns: |
|
detrend
(order=1, picks=None)[source]¶Detrend data.
This function operates in-place.
Parameters: |
|
---|---|
Returns: |
|
drop_channels
(ch_names)[source]¶Drop some channels.
Parameters: |
|
---|---|
Returns: |
|
See also
Notes
New in version 0.9.0.
filter
(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.
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
or self.load_data()
.
l_freq
and h_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']
and self.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.
Parameters: |
|
---|---|
Returns: |
|
Notes
New in version 0.15.
get_peak
(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: |
|
---|---|
Returns: |
|
interpolate_bads
(reset_bads=True, mode='accurate', verbose=None)[source]¶Interpolate bad MEG and EEG channels.
Operates in place.
Parameters: |
|
---|---|
Returns: |
|
Notes
New in version 0.9.0.
pick_channels
(ch_names)[source]¶Pick some channels.
Parameters: |
|
---|---|
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
(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: |
|
---|---|
Returns: |
|
See also
Notes
New in version 0.9.0.
plot
(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=None, 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: |
|
---|---|
Returns: |
|
See also
plot_field
(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: |
|
---|---|
Returns: |
|
plot_image
(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=None)[source]¶Plot evoked data as images.
Parameters: |
|
---|---|
Returns: |
|
plot_joint
(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.
Parameters: |
|
---|---|
Returns: |
|
Notes
New in version 0.12.0.
plot_projs_topomap
(ch_type=None, layout=None, axes=None)[source]¶Plot SSP vector.
Parameters: |
|
---|---|
Returns: |
|
plot_sensors
(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: |
|
---|---|
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
(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: |
|
---|---|
Returns: |
|
Notes
New in version 0.10.0.
plot_topomap
(times='auto', ch_type=None, layout=None, vmin=None, vmax=None, cmap=None, sensors=True, colorbar=True, scalings=None, scaling_time=None, units=None, res=64, size=1, cbar_fmt='%3.1f', time_unit=None, 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)[source]¶Plot topographic maps of specific time points of evoked data.
Parameters: |
|
---|---|
Returns: |
|
plot_white
(noise_cov, show=True, rank=None, time_unit=None, 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: |
|
---|---|
Returns: |
|
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] | (1, 2) 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. |
proj
¶Whether or not projections are active.
rename_channels
(mapping)[source]¶Rename channels.
Parameters: |
|
---|
Notes
New in version 0.9.0.
reorder_channels
(ch_names)[source]¶Reorder channels.
Parameters: |
|
---|---|
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
(sfreq, npad='auto', window='boxcar', n_jobs=1, pad='edge', verbose=None)[source]¶Resample data.
Note
Data must be loaded.
Parameters: |
|
---|---|
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
(fname)[source]¶Save dataset to file.
Parameters: |
|
---|
Notes
To write multiple conditions into a single file, use
mne.write_evokeds()
.
savgol_filter
(h_freq, verbose=None)[source]¶Filter the data using Savitzky-Golay polynomial method.
Parameters: |
|
---|---|
Returns: |
|
See also
Notes
For Savitzky-Golay low-pass approximation, see:
New in version 0.9.0.
References
[1] | (1, 2) 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')
>>> evoked = mne.read_evokeds(evoked_fname, baseline=(None, 0))[0]
>>> evoked.savgol_filter(10.) # low-pass at around 10 Hz
>>> evoked.plot()
set_channel_types
(mapping)[source]¶Define the sensor type of channels.
Parameters: |
|
---|
Notes
New in version 0.9.0.
set_eeg_reference
(ref_channels='average', projection=None, 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:
ref_channels=[]
. This will prevent MNE-Python from
automatically adding an average reference projection.ref_channels='average'
. Bad EEG
channels are automatically excluded if they are properly set in
info['bads']
.ref_channels
to a list containing the name of the channel
that will act as the new reference, for example
ref_channels=['Cz']
.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, set
ref_channels=['M1', 'M2']
.Note
In case of ref_channels='average'
in combination with
projection=True
, the reference is added as a projection
and it is not applied automatically. For it to take effect,
apply with method apply_proj
.
Other references are directly applied (this behavior will
change in MNE 0.16).
Parameters: |
|
---|---|
Returns: |
|
See also
mne.set_bipolar_reference
Notes
ref_channels='average'
and projection=True
.info['bads']
.New in version 0.9.0.
set_montage
(montage, set_dig=True, verbose=None)[source]¶Set EEG sensor configuration and head digitization.
Parameters: |
|
---|
Notes
Operates in place.
New in version 0.9.0.
shift_time
(tshift, relative=True)[source]¶Shift time scale in evoked data.
Parameters: |
|
---|
Notes
Maximum accuracy of time shift is 1 / evoked.info[‘sfreq’]
time_as_index
(times, use_rounding=False)[source]¶Convert time to indices.
Parameters: |
|
---|---|
Returns: |
|
to_data_frame
(picks=None, index=None, scaling_time=1000.0, scalings=None, copy=True, start=None, stop=None)[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: |
|
---|---|
Returns: |
|