mne.time_frequency.AverageTFR

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

Container for Time-Frequency data

Can for example store induced power at sensor level or intertrial coherence.

Parameters:

info : Info

The measurement info.

data : ndarray, shape (n_channels, n_freqs, n_times)

The data.

times : ndarray, shape (n_times,)

The time values in seconds.

freqs : ndarray, shape (n_freqs,)

The frequencies in Hz.

nave : int

The number of averaged TFRs.

comment : str | None

Comment on the data, e.g., the experimental condition. Defaults to None.

method : str | None

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

verbose : bool, str, int, or None

If not None, override default verbose level (see mne.verbose).

Attributes:

ch_names : list

The names of the channels.

Methods

add_channels(add_list[, copy]) Append new channels to the instance.
apply_baseline(baseline[, mode]) Baseline correct the data
copy() Return a copy of the instance.
crop([tmin, tmax, copy]) Crop data to a given time interval
drop_channels(ch_names[, copy]) Drop some channels
pick_channels(ch_names[, copy]) Pick some channels
pick_types([meg, eeg, stim, eog, ecg, emg, ...]) Pick some channels by type and names
plot([picks, baseline, mode, tmin, tmax, ...]) Plot TFRs in a topography with images
plot_topo([picks, baseline, mode, tmin, ...]) Plot TFRs in a topography with images
plot_topomap([tmin, tmax, fmin, fmax, ...]) Plot topographic maps of time-frequency intervals of TFR data
save(fname[, overwrite]) Save TFR object to hdf5 file
__init__(info, data, times, freqs, nave, comment=None, method=None, verbose=None)
add_channels(add_list, copy=False)

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

copy : bool

Whether to return a new instance or modify in place

Returns:

out : MNE object of type(self)

An object with new channels appended (will be the same object if copy==False)

apply_baseline(baseline, mode='mean')

Baseline correct the data

Parameters:

baseline : tuple 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 : ‘logratio’ | ‘ratio’ | ‘zscore’ | ‘mean’ | ‘percent’

Do baseline correction with ratio (power is divided by mean power during baseline) or z-score (power is divided by standard deviation of power during baseline after subtracting the mean, power = [power - mean(power_baseline)] / std(power_baseline)) If None, baseline no correction will be performed.

copy()

Return a copy of the instance.

crop(tmin=None, tmax=None, copy=False)

Crop data to a given time interval

Parameters:

tmin : float | None

Start time of selection in seconds.

tmax : float | None

End time of selection in seconds.

copy : bool

If False epochs is cropped in place.

drop_channels(ch_names, copy=False)

Drop some channels

Parameters:

ch_names : list

The list of channels to remove.

copy : bool

If True, returns new instance. Else, modifies in place. Defaults to False.

See also

pick_channels

Notes

New in version 0.9.0.

pick_channels(ch_names, copy=False)

Pick some channels

Parameters:

ch_names : list

The list of channels to select.

copy : bool

If True, returns new instance. Else, modifies in place. Defaults to False.

See also

drop_channels

Notes

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, include=[], exclude='bads', selection=None, copy=False)

Pick some channels by type and names

Parameters:

meg : bool | 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.

eeg : bool

If True include EEG channels.

stim : bool

If True include stimulus channels.

eog : bool

If True include EOG channels.

ecg : bool

If True include ECG channels.

emg : bool

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.

misc : bool

If True include miscellaneous analog channels.

resp : bool

If True include response-trigger channel. For some MEG systems this is separate from the stim channel.

chpi : bool

If True include continuous HPI coil channels.

exci : bool

Flux excitation channel used to be a stimulus channel.

ias : bool

Internal Active Shielding data (maybe on Triux only).

syst : bool

System status channel information (on Triux systems only).

seeg : bool

Stereotactic EEG channels.

include : list of string

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

exclude : list of string | str

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

selection : list of string

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

copy : bool

If True, returns new instance. Else, modifies in place. Defaults to False.

Notes

New in version 0.9.0.

plot(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, verbose=None)

Plot TFRs in a topography with images

Parameters:

picks : array-like of int | None

The indices of the channels to plot.

baseline : None (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 ot (None, None) all the time interval is used.

mode : None | ‘logratio’ | ‘ratio’ | ‘zscore’ | ‘mean’ | ‘percent’

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)). If None no baseline correction is applied.

tmin : None | float

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

tmax : None | float

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

fmin : None | float

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

fmax : None | float

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

vmin : float | None

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

vmax : float | None

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

cmap : matplotlib colormap | str

The colormap to use. Defaults to ‘RdBu_r’.

dB : bool

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

colorbar : bool

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

show : bool

Call pyplot.show() at the end.

title : str | None

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

axes : instance 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.

layout : Layout | 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.

verbose : bool, str, int, or None

If not None, override default verbose level (see mne.verbose).

Returns:

fig : matplotlib.figure.Figure

The figure containing the topography.

plot_topo(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', font_color='w')

Plot TFRs in a topography with images

Parameters:

picks : array-like of int | None

The indices of the channels to plot. If None all available channels are displayed.

baseline : None (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 ot (None, None) all the time interval is used.

mode : None | ‘logratio’ | ‘ratio’ | ‘zscore’ | ‘mean’ | ‘percent’

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)). If None no baseline correction is applied.

tmin : None | float

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

tmax : None | float

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

fmin : None | float

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

fmax : None | float

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

vmin : float | None

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

vmax : float | None

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

layout : Layout | None

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

cmap : matplotlib colormap | str

The colormap to use. Defaults to ‘RdBu_r’.

title : str

Title of the figure.

dB : bool

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

colorbar : bool

If true, colorbar will be added to the plot

layout_scale : float

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

show : bool

Call pyplot.show() at the end.

border : str

matplotlib borders style to be used for each sensor plot.

fig_facecolor : str | obj

The figure face color. Defaults to black.

font_color: str | obj :

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

Returns:

fig : matplotlib.figure.Figure

The figure containing the topography.

plot_topomap(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)

Plot topographic maps of time-frequency intervals of TFR data

Parameters:

tmin : None | float

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

tmax : None | float

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

fmin : None | float

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

fmax : None | 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 channels are chosen in the order given above.

baseline : tuple 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 : ‘logratio’ | ‘ratio’ | ‘zscore’ | ‘mean’ | ‘percent’

Do baseline correction with ratio (power is divided by mean power during baseline) or z-score (power is divided by standard deviation of power during baseline after subtracting the mean, power = [power - mean(power_baseline)] / std(power_baseline)) If None, baseline no correction will be performed.

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

cmap : matplotlib colormap | None

Colormap. If None and the plotted data is all positive, defaults to ‘Reds’. If None and data contains also negative values, defaults to ‘RdBu_r’. Defaults to None.

sensors : bool | 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.

colorbar : bool

Plot a colorbar.

unit : 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.

show_names : bool | 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.

axes : instance of Axes | None

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

show : bool

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

Returns:

fig : matplotlib.figure.Figure

The figure containing the topography.

save(fname, overwrite=False)

Save TFR object to hdf5 file

Parameters:

fname : str

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

overwrite : bool

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