mne.time_frequency.AverageTFR

class mne.time_frequency.AverageTFR(info, data, times, freqs, nave, comment=None, method=None, verbose=None)[source]

Container for Time-Frequency data.

Can for example store induced power at sensor level or inter-trial coherence.

Parameters
infoInfo

The measurement info.

datandarray, shape (n_channels, n_freqs, n_times)

The data.

timesndarray, shape (n_times,)

The time values in seconds.

freqsndarray, shape (n_freqs,)

The frequencies in Hz.

naveint

The number of averaged TFRs.

commentstr | None, default None

Comment on the data, e.g., the experimental condition.

methodstr | None, default None

Comment on the method used to compute the data, e.g., morlet wavelet.

verbosebool, str, int, or None

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

Attributes
infoinstance of Info

Measurement info.

ch_nameslist

Channel names.

naveint

Number of averaged epochs.

datandarray, shape (n_channels, n_freqs, n_times)

The data array.

timesndarray, shape (n_times,)

The time values in seconds.

freqsndarray, shape (n_freqs,)

The frequencies in Hz.

commentstr

Comment on dataset. Can be the condition.

methodstr | None, default None

Comment on the method used to compute the data, e.g., morlet wavelet.

Methods

__add__(self, tfr)

Add instances.

__contains__(self, ch_type)

Check channel type membership.

__hash__(self)

Hash the object.

__sub__(self, tfr)

Subtract instances.

add_channels(self, add_list[, force_update_info])

Append new channels to the instance.

apply_baseline(self, baseline[, mode, verbose])

Baseline correct the data.

copy(self)

Return a copy of the instance.

crop(self[, tmin, tmax, fmin, fmax, …])

Crop data to a given time interval in place.

drop_channels(self, ch_names)

Drop channel(s).

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, baseline, mode, tmin, …])

Plot TFRs as a two-dimensional image(s).

plot_joint(self[, timefreqs, picks, …])

Plot TFRs as a two-dimensional image with topomaps.

plot_topo(self[, picks, baseline, mode, …])

Plot TFRs in a topography with images.

plot_topomap(self[, tmin, tmax, fmin, fmax, …])

Plot topographic maps of time-frequency intervals of TFR data.

reorder_channels(self, ch_names)

Reorder channels.

save(self, fname[, overwrite])

Save TFR object to hdf5 file.

__add__(self, tfr)[source]

Add instances.

__contains__(self, ch_type)[source]

Check channel type membership.

Parameters
ch_typestr

Channel type to check for. Can be e.g. ‘meg’, ‘eeg’, ‘stim’, etc.

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
__hash__(self)[source]

Hash the object.

Returns
hashint

The hash

__sub__(self, tfr)[source]

Subtract instances.

add_channels(self, add_list, force_update_info=False)[source]

Append new channels to the instance.

Parameters
add_listlist

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.

Returns
instinstance of Raw, Epochs, or Evoked

The modified instance.

See also

drop_channels

Notes

If self is a Raw instance that has been preloaded into a numpy.memmap instance, the memmap will be resized.

apply_baseline(self, baseline, mode='mean', verbose=None)[source]

Baseline correct the data.

Parameters
baselinearray_like, shape (2,)

The time interval to apply rescaling / 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.

mode‘mean’ | ‘ratio’ | ‘logratio’ | ‘percent’ | ‘zscore’ | ‘zlogratio’

Perform baseline correction by

  • subtracting the mean of baseline values (‘mean’)

  • dividing by the mean of baseline values (‘ratio’)

  • dividing by the mean of baseline values and taking the log (‘logratio’)

  • subtracting the mean of baseline values followed by dividing by the mean of baseline values (‘percent’)

  • subtracting the mean of baseline values and dividing by the standard deviation of baseline values (‘zscore’)

  • dividing by the mean of baseline values, taking the log, and dividing by the standard deviation of log baseline values (‘zlogratio’)

verbosebool, str, int, or None

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

Returns
instinstance of AverageTFR

The modified instance.

property ch_names

Channel names.

property compensation_grade

The current gradient compensation grade.

copy(self)[source]

Return a copy of the instance.

crop(self, tmin=None, tmax=None, fmin=None, fmax=None, include_tmax=True)[source]

Crop data to a given time interval in place.

Parameters
tminfloat | None

Start time of selection in seconds.

tmaxfloat | None

End time of selection in seconds.

fminfloat | None

Lowest frequency of selection in Hz.

New in version 0.18.0.

fmaxfloat | None

Highest frequency of selection in Hz.

New in version 0.18.0.

include_tmaxbool

If True (default), include tmax. If False, exclude tmax (similar to how Python indexing typically works).

New in version 0.19.

Returns
instinstance of AverageTFR

The modified instance.

drop_channels(self, ch_names)[source]

Drop channel(s).

Parameters
ch_namesiterable or str

Iterable (e.g. list) of channel name(s) or channel name to remove.

Returns
instinstance of Raw, Epochs, or Evoked

The modified instance.

Notes

New in version 0.9.0.

pick(self, picks, exclude=())[source]

Pick a subset of channels.

Parameters
picksstr | 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.

excludelist | str

Set of channels to exclude, only used when picking based on types (e.g., exclude=”bads” when picks=”meg”).

Returns
instinstance of Raw, Epochs, or Evoked

The modified instance.

pick_channels(self, ch_names)[source]

Pick some channels.

Parameters
ch_nameslist

The list of channels to select.

Returns
instinstance of Raw, Epochs, or Evoked

The modified instance.

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).

includelist of str

List of additional channels to include. If empty do not include any.

excludelist of str | str

List of channels to exclude. If ‘bads’ (default), exclude channels in info['bads'].

selectionlist of str

Restrict sensor channels (MEG, EEG) to this list of channel names.

verbosebool, str, int, or None

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

Returns
instinstance of Raw, Epochs, or Evoked

The modified instance.

See also

pick_channels

Notes

New in version 0.9.0.

plot(self, picks=None, baseline=None, mode='mean', tmin=None, tmax=None, fmin=None, fmax=None, vmin=None, vmax=None, cmap='RdBu_r', dB=False, colorbar=True, show=True, title=None, axes=None, layout=None, yscale='auto', mask=None, mask_style=None, mask_cmap='Greys', mask_alpha=0.1, combine=None, exclude=[], verbose=None)[source]

Plot TFRs as a two-dimensional image(s).

Parameters
picksstr | 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.

baselineNone (default) or tuple, shape (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.

mode‘mean’ | ‘ratio’ | ‘logratio’ | ‘percent’ | ‘zscore’ | ‘zlogratio’

Perform baseline correction by

  • subtracting the mean of baseline values (‘mean’)

  • dividing by the mean of baseline values (‘ratio’)

  • dividing by the mean of baseline values and taking the log (‘logratio’)

  • subtracting the mean of baseline values followed by dividing by the mean of baseline values (‘percent’)

  • subtracting the mean of baseline values and dividing by the standard deviation of baseline values (‘zscore’)

  • dividing by the mean of baseline values, taking the log, and dividing by the standard deviation of log baseline values (‘zlogratio’)

tminNone | float

The first time instant to display. If None the first time point available is used.

tmaxNone | float

The last time instant to display. If None the last time point available is used.

fminNone | float

The first frequency to display. If None the first frequency available is used.

fmaxNone | float

The last frequency to display. If None the last frequency available is used.

vminfloat | None

The minimum value an the color scale. If vmin is None, the data minimum value is used.

vmaxfloat | None

The maximum value an the color scale. If vmax is None, the data maximum value is used.

cmapmatplotlib colormap | ‘interactive’ | (colormap, bool)

The 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. Hitting space bar resets the range. Up and down arrows can be used to change the colormap. If ‘interactive’, translates to (‘RdBu_r’, True). Defaults to ‘RdBu_r’.

Warning

Interactive mode works smoothly only for a small amount of images.

dBbool

If True, 10*log10 is applied to the data to get dB.

colorbarbool

If true, colorbar will be added to the plot. For user defined axes, the colorbar cannot be drawn. Defaults to True.

showbool

Call pyplot.show() at the end.

titlestr | ‘auto’ | None

String for title. Defaults to None (blank/no title). If ‘auto’, automatically create a title that lists up to 6 of the channels used in the figure.

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 channels. If instance of Axes, there must be only one channel plotted.

layoutLayout | None

Layout instance specifying sensor positions. Used for interactive plotting of topographies on rectangle selection. If possible, the correct layout is inferred from the data.

yscale‘auto’ (default) | ‘linear’ | ‘log’

The scale of y (frequency) axis. ‘linear’ gives linear y axis, ‘log’ leads to log-spaced y axis and ‘auto’ detects if frequencies are log-spaced and only then sets the y axis to ‘log’.

New in version 0.14.0.

maskndarray | None

An array of booleans of the same shape as the data. Entries of the data that correspond to False in the mask are plotted transparently. Useful for, e.g., masking for statistical significance.

New in version 0.16.0.

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 not True in mask are shown transparently. If ‘both’, both a contour and transparency are used. If None, defaults to ‘both’ if mask is not None, and is ignored otherwise.

New in version 0.17.

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 to Greys. Not interactive. Otherwise, as cmap.

New in version 0.17.

mask_alphafloat

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 0.1.

New in version 0.16.0.

combine‘mean’ | ‘rms’ | None

Type of aggregation to perform across selected channels. If None, plot one figure per selected channel.

excludelist of str | ‘bads’

Channels names to exclude from being shown. If ‘bads’, the bad channels are excluded. Defaults to an empty list.

verbosebool, str, int, or None

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

Returns
figmatplotlib.figure.Figure

The figure containing the topography.

Examples using plot:

plot_joint(self, timefreqs=None, picks=None, baseline=None, mode='mean', tmin=None, tmax=None, fmin=None, fmax=None, vmin=None, vmax=None, cmap='RdBu_r', dB=False, colorbar=True, show=True, title=None, layout=None, yscale='auto', combine='mean', exclude=[], topomap_args=None, image_args=None, verbose=None)[source]

Plot TFRs as a two-dimensional image with topomaps.

Parameters
timefreqsNone | list of tuple | dict of tuple

The time-frequency point(s) for which topomaps will be plotted. See Notes.

picksstr | 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.

baselineNone (default) or 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. If b is None, then b is set to the end of the interval. If baseline is equal to (None, None), the entire time interval is used.

modeNone | str

If str, must be one of ‘ratio’, ‘zscore’, ‘mean’, ‘percent’, ‘logratio’ and ‘zlogratio’. Do baseline correction with ratio (power is divided by mean power during baseline) or zscore (power is divided by standard deviation of power during baseline after subtracting the mean, power = [power - mean(power_baseline)] / std(power_baseline)), mean simply subtracts the mean power, percent is the same as applying ratio then mean, logratio is the same as mean but then rendered in log-scale, zlogratio is the same as zscore but data is rendered in log-scale first. If None no baseline correction is applied.

tminNone | float

The first time instant to display. If None the first time point available is used.

tmaxNone | float

The last time instant to display. If None the last time point available is used.

fminNone | float

The first frequency to display. If None the first frequency available is used.

fmaxNone | float

The last frequency to display. If None the last frequency available is used.

vminfloat | None

The minimum value of the color scale for the image (for topomaps, see topomap_args). If vmin is None, the data absolute minimum value is used.

vmaxfloat | None

The maximum value of the color scale for the image (for topomaps, see topomap_args). If vmax is None, the data absolute maximum value is used.

cmapmatplotlib colormap

The colormap to use.

dBbool

If True, 10*log10 is applied to the data to get dB.

colorbarbool

If true, colorbar will be added to the plot (relating to the topomaps). For user defined axes, the colorbar cannot be drawn. Defaults to True.

showbool

Call pyplot.show() at the end.

titlestr | None

String for title. Defaults to None (blank/no title).

layoutLayout | None

Layout instance specifying sensor positions. Used for interactive plotting of topographies on rectangle selection. If possible, the correct layout is inferred from the data.

yscale‘auto’ (default) | ‘linear’ | ‘log’

The scale of y (frequency) axis. ‘linear’ gives linear y axis, ‘log’ leads to log-spaced y axis and ‘auto’ detects if frequencies are log-spaced and only then sets the y axis to ‘log’.

combine‘mean’ | ‘rms’

Type of aggregation to perform across selected channels.

excludelist of str | ‘bads’

Channels names to exclude from being shown. If ‘bads’, the bad channels are excluded. Defaults to an empty list, i.e., [].

topomap_argsNone | dict

A dict of kwargs that are forwarded to mne.viz.plot_topomap() to style the topomaps. axes and show are ignored. If times is not in this dict, automatic peak detection is used. Beyond that, if None, no customizable arguments will be passed. Defaults to None.

image_argsNone | dict

A dict of kwargs that are forwarded to AverageTFR.plot() to style the image. axes and show are ignored. Beyond that, if None, no customizable arguments will be passed. Defaults to None.

verbosebool, str, int, or None

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

Returns
figmatplotlib.figure.Figure

The figure containing the topography.

Notes

timefreqs has three different modes: tuples, dicts, and auto. For (list of) tuple(s) mode, each tuple defines a pair (time, frequency) in s and Hz on the TFR plot. For example, to look at 10 Hz activity 1 second into the epoch and 3 Hz activity 300 msec into the epoch,:

timefreqs=((1, 10), (.3, 3))

If provided as a dictionary, (time, frequency) tuples are keys and (time_window, frequency_window) tuples are the values - indicating the width of the windows (centered on the time and frequency indicated by the key) to be averaged over. For example,:

timefreqs={(1, 10): (0.1, 2)}

would translate into a window that spans 0.95 to 1.05 seconds, as well as 9 to 11 Hz. If None, a single topomap will be plotted at the absolute peak across the time-frequency representation.

New in version 0.16.0.

Examples using plot_joint:

plot_topo(self, picks=None, baseline=None, mode='mean', tmin=None, tmax=None, fmin=None, fmax=None, vmin=None, vmax=None, layout=None, cmap='RdBu_r', title=None, dB=False, colorbar=True, layout_scale=0.945, show=True, border='none', fig_facecolor='k', fig_background=None, font_color='w', yscale='auto')[source]

Plot TFRs in a topography with images.

Parameters
picksstr | 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.

baselineNone (default) or 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.

mode‘mean’ | ‘ratio’ | ‘logratio’ | ‘percent’ | ‘zscore’ | ‘zlogratio’

Perform baseline correction by

  • subtracting the mean of baseline values (‘mean’)

  • dividing by the mean of baseline values (‘ratio’)

  • dividing by the mean of baseline values and taking the log (‘logratio’)

  • subtracting the mean of baseline values followed by dividing by the mean of baseline values (‘percent’)

  • subtracting the mean of baseline values and dividing by the standard deviation of baseline values (‘zscore’)

  • dividing by the mean of baseline values, taking the log, and dividing by the standard deviation of log baseline values (‘zlogratio’)

tminNone | float

The first time instant to display. If None the first time point available is used.

tmaxNone | float

The last time instant to display. If None the last time point available is used.

fminNone | float

The first frequency to display. If None the first frequency available is used.

fmaxNone | float

The last frequency to display. If None the last frequency available is used.

vminfloat | None

The minimum value of the color scale. If vmin is None, the data minimum value is used.

vmaxfloat | None

The maximum value of the color scale. If vmax is None, the data maximum value is used.

layoutLayout | None

Layout instance specifying sensor positions. If possible, the correct layout is inferred from the data.

cmapmatplotlib colormap | str

The colormap to use. Defaults to ‘RdBu_r’.

titlestr

Title of the figure.

dBbool

If True, 10*log10 is applied to the data to get dB.

colorbarbool

If true, colorbar will be added to the plot

layout_scalefloat

Scaling factor for adjusting the relative size of the layout on the canvas.

showbool

Call pyplot.show() at the end.

borderstr

matplotlib borders style to be used for each sensor plot.

fig_facecolorcolor

The figure face color. Defaults to black.

fig_backgroundNone | array

A background image for the figure. This must be a valid input to matplotlib.pyplot.imshow. Defaults to None.

font_color: color

The color of tick labels in the colorbar. Defaults to white.

yscale‘auto’ (default) | ‘linear’ | ‘log’

The scale of y (frequency) axis. ‘linear’ gives linear y axis, ‘log’ leads to log-spaced y axis and ‘auto’ detects if frequencies are log-spaced and only then sets the y axis to ‘log’.

Returns
figmatplotlib.figure.Figure

The figure containing the topography.

Examples using plot_topo:

plot_topomap(self, tmin=None, tmax=None, fmin=None, fmax=None, ch_type=None, baseline=None, mode='mean', layout=None, vmin=None, vmax=None, cmap=None, sensors=True, colorbar=True, unit=None, res=64, size=2, cbar_fmt='%1.1e', show_names=False, title=None, axes=None, show=True, outlines='head', head_pos=None, contours=6)[source]

Plot topographic maps of time-frequency intervals of TFR data.

Parameters
tminNone | float

The first time instant to display. If None the first time point available is used.

tmaxNone | float

The last time instant to display. If None the last time point available is used.

fminNone | float

The first frequency to display. If None the first frequency available is used.

fmaxNone | float

The last frequency to display. If None the last frequency available is used.

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 first available channel type from order given above is used. Defaults to None.

baselinetuple or list of length 2

The time interval to apply rescaling / 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.

mode‘mean’ | ‘ratio’ | ‘logratio’ | ‘percent’ | ‘zscore’ | ‘zlogratio’

Perform baseline correction by

  • subtracting the mean of baseline values (‘mean’)

  • dividing by the mean of baseline values (‘ratio’)

  • dividing by the mean of baseline values and taking the log (‘logratio’)

  • subtracting the mean of baseline values followed by dividing by the mean of baseline values (‘percent’)

  • subtracting the mean of baseline values and dividing by the standard deviation of baseline values (‘zscore’)

  • dividing by the mean of baseline values, taking the log, and dividing by the standard deviation of log baseline values (‘zlogratio’)

layoutNone | 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.

vminfloat | 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) or in case data contains only positive values 0. If callable, the output equals vmin(data). Defaults to None.

vmaxfloat | callable() | None

The value specifying the upper bound of the color range. If None, the maximum 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. 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).

sensorsbool | str

Add markers for sensor locations to the plot. Accepts matplotlib plot format string (e.g., ‘r+’ for red plusses). If True, a circle will be used (via .add_artist). Defaults to True.

colorbarbool

Plot a colorbar.

unitdict | str | None

The unit of the channel type used for colorbar label. If scale is None the unit is automatically determined.

resint

The resolution of the topomap image (n pixels along each side).

sizefloat

Side length per topomap in inches.

cbar_fmtstr

String format for colorbar values.

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.

titlestr | None

Title. If None (default), no title is displayed.

axesinstance of Axes | None

The axes to plot to. If None the axes is defined automatically.

showbool

Call pyplot.show() at the end.

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’.

head_posdict | 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.

contoursint | array of float

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. If colorbar=True, the ticks in colorbar correspond to the contour levels. Defaults to 6.

Returns
figmatplotlib.figure.Figure

The figure containing the topography.

Examples using plot_topomap:

reorder_channels(self, ch_names)[source]

Reorder channels.

Parameters
ch_nameslist

The desired channel order.

Returns
instinstance of Raw, Epochs, or Evoked

The modified instance.

Notes

Channel names must be unique. Channels that are not in ch_names are dropped.

New in version 0.16.0.

save(self, fname, overwrite=False)[source]

Save TFR object to hdf5 file.

Parameters
fnamestr

The file name, which should end with -tfr.h5 .

overwritebool

If True, overwrite file (if it exists). Defaults to False