mne.time_frequency.RawTFRArray#
- class mne.time_frequency.RawTFRArray(info, data, times, freqs, *, method=None, weights=None)[source]#
- Data object for precomputed spectrotemporal representations of continuous data. - Parameters:
- infomne.Info
- The - mne.Infoobject with information about the sensors and methods of measurement.
- 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. 
- methodstr|None
- Comment on the method used to compute the data, e.g., - "hilbert". Default is- None.
- weightsarray, shape (n_tapers, n_freqs) |None
- The weights for each taper. Must be provided if - datahas a taper dimension, such as for complex or phase multitaper data.- New in v1.10.0. 
 
- info
- Attributes:
- baselinearray_like, shape (2,)
- Start and end of the baseline period (in seconds). 
- ch_names- list
- The channel names. 
- freqs- array
- The frequencies at which power estimates were computed. 
- infomne.Info
- The - mne.Infoobject with information about the sensors and methods of measurement.
- method- str
- The method used to compute the time-frequency power estimates. 
- sfreq- int|- float
- Sampling frequency of the data. 
- shape- tupleof- int
- Data shape. 
- weights- array, shape (n_tapers, n_freqs) |- None
- The weights used for each taper in the time-frequency estimates. 
 
 - Methods - __add__(other)- Add two TFR instances. - __contains__(ch_type)- Check channel type membership. - __getitem__(item)- Get RawTFR data. - __mul__(num)- Multiply a TFR instance by a scalar. - __sub__(other)- Subtract two TFR instances. - add_channels(add_list[, force_update_info])- Append new channels from other MNE objects to the instance. - add_reference_channels(ref_channels)- Add reference channels to data that consists of all zeros. - apply_baseline(baseline[, mode, verbose])- Baseline correct the data. - copy()- Return copy of the TFR instance. - crop([tmin, tmax, fmin, fmax, include_tmax])- Crop data to a given time interval in place. - decimate(decim[, offset, verbose])- Decimate the time-series data. - drop_channels(ch_names[, on_missing])- Drop channel(s). - get_channel_types([picks, unique, only_data_chs])- Get a list of channel type for each channel. - get_data([picks, exclude, fmin, fmax, tmin, ...])- Get time-frequency data in NumPy array format. - pick(picks[, exclude, verbose])- Pick a subset of channels. - pick_channels(ch_names[, ordered, verbose])- pick_types([meg, eeg, stim, eog, ecg, emg, ...])- plot([picks, exclude, tmin, tmax, fmin, ...])- Plot TFRs as two-dimensional time-frequency images. - plot_joint(*[, timefreqs, picks, exclude, ...])- Plot TFRs as a two-dimensional image with topomap highlights. - plot_topo([picks, baseline, mode, tmin, ...])- Plot a TFR image for each channel in a sensor layout arrangement. - plot_topomap([tmin, tmax, fmin, fmax, ...])- Plot topographic maps of specific time-frequency intervals of TFR data. - reorder_channels(ch_names)- Reorder channels. - save(fname, *[, overwrite, verbose])- Save time-frequency data to disk (in HDF5 format). - shift_time(tshift[, relative])- Shift time scale in epoched or evoked data. - time_as_index(times[, use_rounding])- Convert time to indices. - to_data_frame([picks, index, long_format, ...])- Export data in tabular structure as a pandas DataFrame. - __add__(other)[source]#
- Add two TFR instances. - Parameters:
- otherinstance of RawTFR| instance ofEpochsTFR| instance ofAverageTFR
- The TFR instance to add. Must have the same type as - self, and matching- .timesand- .freqsattributes.
 
- otherinstance of 
- Returns:
- tfrinstance of RawTFR| instance ofEpochsTFR| instance ofAverageTFR
- A new TFR instance, of the same type as - self.
 
- tfrinstance of 
 
 - __contains__(ch_type)[source]#
- Check channel type membership. - Parameters:
- ch_typestr
- 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 
 - __getitem__(item)[source]#
- Get RawTFR data. - Parameters:
- itemint|slice| array_like
- Indexing is similar to a - NumPy array; see Notes.
 
- item
- Returns:
- %(getitem_tfr_return)s
 
 - Notes - The last axis is always time, the next-to-last axis is always frequency, and the first axis is always channel. If - method='multitaper'and- output='complex'then the second axis will be taper index.- Integer-, list-, and slice-based indexing is possible: - raw_tfr[[0, 2]]gives the whole time-frequency plane for the first and third channels.
- raw_tfr[..., :3, :]gives the first 3 frequency bins and all times for all channels (and tapers, if present).
- raw_tfr[..., :100]gives the first 100 time samples in all frequency bins for all channels (and tapers).
- raw_tfr[(4, 7)]is the same as- raw_tfr[4, 7].
 
 - __mul__(num)[source]#
- Multiply a TFR instance by a scalar. - Parameters:
- Returns:
- tfrinstance of RawTFR| instance ofEpochsTFR| instance ofAverageTFR
- A new TFR instance, of the same type as - self.
 
- tfrinstance of 
 
 - __sub__(other)[source]#
- Subtract two TFR instances. - Parameters:
- otherinstance of RawTFR| instance ofEpochsTFR| instance ofAverageTFR
- The TFR instance to subtract. Must have the same type as - self, and matching- .timesand- .freqsattributes.
 
- otherinstance of 
- Returns:
- tfrinstance of RawTFR| instance ofEpochsTFR| instance ofAverageTFR
- A new TFR instance, of the same type as - self.
 
- tfrinstance of 
 
 - add_channels(add_list, force_update_info=False)[source]#
- Append new channels from other MNE objects to the instance. - Parameters:
- add_listlist
- A list of MNE objects to append to the current instance. The channels contained in the other instances are appended to the channels of the current instance. Therefore, all other instances must be of the same type as the current object. See notes on how to add data coming from an array. 
- force_update_infobool
- If True, force the info for objects to be appended to match the values of the current instance. This should generally only be used when adding stim channels for which important metadata won’t be overwritten. - New in v0.12. 
 
- add_list
- Returns:
 - See also - Notes - If - selfis a Raw instance that has been preloaded into a- numpy.memmapinstance, the memmap will be resized.- This function expects an MNE object to be appended (e.g. - Raw,- Epochs,- Evoked). If you simply want to add a channel based on values of an np.ndarray, you need to create a- RawArray. See <https://mne.tools/mne-project-template/auto_examples/plot_mne_objects_from_arrays.html>`_
 - add_reference_channels(ref_channels)[source]#
- Add reference channels to data that consists of all zeros. - Adds reference channels to data that were not included during recording. This is useful when you need to re-reference your data to different channels. These added channels will consist of all zeros. - Parameters:
- Returns:
 
 - apply_baseline(baseline, mode='mean', verbose=None)[source]#
- Baseline correct the data. - Parameters:
- baselineNone|tupleof length 2
- The time interval to consider as “baseline” when applying baseline correction. If - None, do not apply baseline correction. If a tuple- (a, b), the interval is between- aand- b(in seconds), including the endpoints. If- ais- None, the beginning of the data is used; and if- bis- None, it is set to the end of the data. If- (None, None), the entire time interval is used.- Note - The baseline - (a, b)includes both endpoints, i.e. all timepoints- tsuch that- a <= t <= b.- How baseline is computed is determined by the - modeparameter.
- 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|None
- Control verbosity of the logging output. If - None, use the default verbosity level. See the logging documentation and- mne.verbose()for details. Should only be passed as a keyword argument.
 
- baseline
- Returns:
- instinstance of RawTFR,EpochsTFR, orAverageTFR
- The modified instance. 
 
- instinstance of 
 
 - property baseline#
- Start and end of the baseline period (in seconds). 
 - property ch_names#
- The channel names. 
 - property compensation_grade#
- The current gradient compensation grade. 
 - crop(tmin=None, tmax=None, fmin=None, fmax=None, include_tmax=True)[source]#
- Crop data to a given time interval in place. - Parameters:
- tmin, tmaxfloat|None
- First and last times to include, in seconds. - Noneuses the first or last time present in the data. Default is- tmin=None, tmax=None(all times).
- fminfloat|None
- Lowest frequency of selection in Hz. - New in v0.18.0. 
- fmaxfloat|None
- Highest frequency of selection in Hz. - New in v0.18.0. 
- include_tmaxbool
- If True (default), include tmax. If False, exclude tmax (similar to how Python indexing typically works). - New in v0.19. 
 
- tmin, tmax
- Returns:
- instinstance of RawTFR,EpochsTFR, orAverageTFR
- The modified instance. 
 
- instinstance of 
 
 - property data#
- The time-frequency-resolved power estimates. 
 - decimate(decim, offset=0, *, verbose=None)[source]#
- Decimate the time-series data. - Parameters:
- decimint
- Factor by which to subsample the data. - Warning - Low-pass filtering is not performed, this simply selects every Nth sample (where N is the value passed to - decim), i.e., it compresses the signal (see Notes). If the data are not properly filtered, aliasing artifacts may occur. See Resampling and decimating data for more information.
- offsetint
- Apply an offset to where the decimation starts relative to the sample corresponding to t=0. The offset is in samples at the current sampling rate. - New in v0.12. 
- verbosebool | str|int|None
- Control verbosity of the logging output. If - None, use the default verbosity level. See the logging documentation and- mne.verbose()for details. Should only be passed as a keyword argument.
 
- decim
- Returns:
- instMNE-object
- The decimated object. 
 
 - See also - Notes - For historical reasons, - decim/ “decimation” refers to simply subselecting samples from a given signal. This contrasts with the broader signal processing literature, where decimation is defined as (quoting [1], p. 172; which cites [2]):- “… a general system for downsampling by a factor of M is the one shown in Figure 4.23. Such a system is called a decimator, and downsampling by lowpass filtering followed by compression [i.e, subselecting samples] has been termed decimation (Crochiere and Rabiner, 1983).” - Hence “decimation” in MNE is what is considered “compression” in the signal processing community. - Decimation can be done multiple times. For example, - inst.decimate(2).decimate(2)will be the same as- inst.decimate(4).- If - decimis 1, this method does not copy the underlying data.- New in v0.10.0. - References 
 - drop_channels(ch_names, on_missing='raise')[source]#
- Drop channel(s). - Parameters:
- Returns:
 - See also - Notes - New in v0.9.0. 
 - property freqs#
- The frequencies at which power estimates were computed. 
 - get_channel_types(picks=None, unique=False, only_data_chs=False)[source]#
- Get a list of channel type for each channel. - Parameters:
- picksstr| array_like |slice|None
- Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., - ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g.,- ['MEG0111', 'MEG2623']will pick the given channels. Can also be the string values- 'all'to pick all channels, or- 'data'to pick data channels. None (default) will pick all channels. Note that channels in- info['bads']will be included if their names or indices are explicitly provided.
- uniquebool
- Whether to return only unique channel types. Default is - False.
- only_data_chsbool
- Whether to ignore non-data channels. Default is - False.
 
- picks
- Returns:
- channel_typeslist
- The channel types. 
 
- channel_types
 
 - get_data(picks=None, exclude='bads', fmin=None, fmax=None, tmin=None, tmax=None, return_times=False, return_freqs=False, return_tapers=False)[source]#
- Get time-frequency data in NumPy array format. - Parameters:
- picksstr| array_like |slice|None
- Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., - ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g.,- ['MEG0111', 'MEG2623']will pick the given channels. Can also be the string values- 'all'to pick all channels, or- 'data'to pick data channels. None (default) will pick good data channels (excluding reference MEG channels). Note that channels in- info['bads']will be included if their names or indices are explicitly provided.
- excludelistofstr| ‘bads’
- Channel names to exclude. If - 'bads', channels in- spectrum.info['bads']are excluded; pass an empty list to include all channels (including “bad” channels, if any).
- fmin, fmaxfloat
- The lower- and upper-bound on frequencies of interest. Default is - Nonewhich is equivalent to- fmin=0, fmax=np.inf(spans all frequencies present in the data).
- tmin, tmaxfloat|None
- First and last times to include, in seconds. - Noneuses the first or last time present in the data. Default is- tmin=None, tmax=None(all times).
- return_timesbool
- Whether to return the time values for the requested time range. Default is - False.
- return_freqsbool
- Whether to return the frequency bin values for the requested frequency range. Default is - False.
- return_tapersbool
- Whether to return the taper numbers. Default is - False.- New in v1.10.0. 
 
- picks
- Returns:
- dataarray
- The requested data in a NumPy array. 
- timesarray
- The time values for the requested data range. Only returned if - return_timesis- True.
- freqsarray
- The frequency values for the requested data range. Only returned if - return_freqsis- True.
- tapersarray|None
- The taper numbers. Only returned if - return_tapersis- True. Will be- Noneif a taper dimension is not present in the data.
 
- data
 - Notes - Returns a copy of the underlying data (not a view). 
 - property method#
- The method used to compute the time-frequency power estimates. 
 - pick(picks, exclude=(), *, verbose=None)[source]#
- Pick a subset of channels. - Parameters:
- picksstr| array_like |slice|None
- Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., - ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g.,- ['MEG0111', 'MEG2623']will pick the given channels. Can also be the string values- 'all'to pick all channels, or- 'data'to pick data channels. None (default) will pick all channels. Note that channels in- info['bads']will be included if their names or indices are explicitly provided.
- excludelist|str
- Set of channels to exclude, only used when picking based on types (e.g., exclude=”bads” when picks=”meg”). 
- verbosebool | str|int|None
- Control verbosity of the logging output. If - None, use the default verbosity level. See the logging documentation and- mne.verbose()for details. Should only be passed as a keyword argument.- New in v0.24.0. 
 
- picks
- Returns:
 
 - pick_channels(ch_names, ordered=True, *, verbose=None)[source]#
- Warning - LEGACY: New code should use inst.pick(…). - Pick some channels. - Parameters:
- ch_nameslist
- The list of channels to select. 
- orderedbool
- If True (default), ensure that the order of the channels in the modified instance matches the order of - ch_names.- New in v0.20.0. - Changed in version 1.7: The default changed from False in 1.6 to True in 1.7. 
- verbosebool | str|int|None
- Control verbosity of the logging output. If - None, use the default verbosity level. See the logging documentation and- mne.verbose()for details. Should only be passed as a keyword argument.- New in v1.1. 
 
- ch_names
- Returns:
 - See also - Notes - If - orderedis- False, the channel names given via- ch_namesare assumed to be a set, that is, their order does not matter. In that case, the original order of the channels in the data is preserved. Apart from using- ordered=True, you may also use- reorder_channelsto set channel order, if necessary.- New in v0.9.0. 
 - pick_types(meg=False, 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, csd=False, dbs=False, temperature=False, gsr=False, eyetrack=False, include=(), exclude='bads', selection=None, verbose=None)[source]#
- Warning - LEGACY: New code should use inst.pick(…). - Pick some channels by type and names. - Parameters:
- megbool | str
- If True include MEG channels. 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_megbool | str
- If True include CTF / 4D reference channels. If ‘auto’, reference channels are included if compensations are present and - megis not False. Can also be the string options for the- megparameter.
- miscbool
- If True include miscellaneous analog channels. 
- respbool
- If - Trueinclude respiratory channels.
- 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). 
- csdbool
- EEG-CSD channels. 
- dbsbool
- Deep brain stimulation channels. 
- temperaturebool
- Temperature channels. 
- gsrbool
- Galvanic skin response channels. 
- eyetrackbool | str
- Eyetracking channels. If True include all eyetracking channels. If False (default) include none. If string it can be ‘eyegaze’ (to include eye position channels) or ‘pupil’ (to include pupil-size channels). 
- includelistofstr
- List of additional channels to include. If empty do not include any. 
- excludelistofstr|str
- List of channels to exclude. If ‘bads’ (default), exclude channels in - info['bads'].
- selectionlistofstr
- Restrict sensor channels (MEG, EEG, etc.) to this list of channel names. 
- verbosebool | str|int|None
- Control verbosity of the logging output. If - None, use the default verbosity level. See the logging documentation and- mne.verbose()for details. Should only be passed as a keyword argument.
 
- megbool | 
- Returns:
 - See also - Notes - New in v0.9.0. 
 - plot(picks=None, *, exclude=(), tmin=None, tmax=None, fmin=0.0, fmax=inf, baseline=None, mode='mean', dB=False, combine=None, layout=None, yscale='auto', vlim=(None, None), cnorm=None, cmap=None, colorbar=True, title=None, mask=None, mask_style=None, mask_cmap='Greys', mask_alpha=0.1, axes=None, show=True, verbose=None)[source]#
- Plot TFRs as two-dimensional time-frequency images. - Parameters:
- picksstr| array_like |slice|None
- Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., - ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g.,- ['MEG0111', 'MEG2623']will pick the given channels. Can also be the string values- 'all'to pick all channels, or- 'data'to pick data channels. None (default) will pick good data channels. Note that channels in- info['bads']will be included if their names or indices are explicitly provided.
- excludelistofstr| ‘bads’
- Channel names to exclude from being drawn. If - 'bads', channels in- spectrum.info['bads']are excluded; pass an empty list to include all channels (including “bad” channels, if any).
- tmin, tmaxfloat|None
- First and last times to include, in seconds. - Noneuses the first or last time present in the data. Default is- tmin=None, tmax=None(all times).
- fmin, fmaxfloat
- The lower- and upper-bound on frequencies of interest. Default is - Nonewhich is equivalent to- fmin=0, fmax=np.inf(spans all frequencies present in the data).
- baselineNone|tupleof length 2
- The time interval to consider as “baseline” when applying baseline correction. If - None, do not apply baseline correction. If a tuple- (a, b), the interval is between- aand- b(in seconds), including the endpoints. If- ais- None, the beginning of the data is used; and if- bis- None, it is set to the end of the data. If- (None, None), the entire time interval is used.- Note - The baseline - (a, b)includes both endpoints, i.e. all timepoints- tsuch that- a <= t <= b.- How baseline is computed is determined by the - modeparameter.
- mode‘mean’ | ‘ratio’ | ‘logratio’ | ‘percent’ | ‘zscore’ | ‘zlogratio’
- Perform baseline correction by - subtracting the mean of baseline values (‘mean’) (default) 
- 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’) 
 
- dBbool
- Whether to plot on a decibel scale. If - True, plots 10 × log₁₀(data).
- combine‘mean’ | ‘rms’ | callable()|None
- How to aggregate across channels. If - None, plot one figure per selected channel. If a string,- "mean"uses- numpy.mean(),- "rms"computes the root-mean-square. If- callable(), it must operate on an- arrayof shape- (n_channels, n_freqs, n_times)and return an array of shape- (n_freqs, n_times). Defaults to- None.- Changed in version 1.3: Added support for - callable.
- layoutinstance of Layout|None
- Layout instance specifying sensor positions (does not need to be specified for Neuromag data). If - None(default), the layout is inferred from the data (if possible).
- yscale‘auto’ | ‘linear’ | ‘log’
- The scale of the y (frequency) axis. ‘linear’ gives linear y axis, ‘log’ gives log-spaced y axis and ‘auto’ detects if frequencies are log-spaced and if so sets the y axis to ‘log’. Default is ‘auto’. - New in v0.14.0. 
- vlimtupleof length 2
- Lower and upper bounds of the colormap, typically a numeric value in the same units as the data. If both entries are - None, the bounds are set at ± the maximum absolute value of the data (yielding a colormap with midpoint at 0), or- (0, max(abs(data)))if the (possibly baselined) data are all-positive. Providing- Nonefor just one entry will set the corresponding boundary at the min/max of the data. Defaults to- (None, None).
- cnormmatplotlib.colors.Normalize|None
- How to normalize the colormap. If - None, standard linear normalization is performed. If not- None,- vminand- vmaxwill be ignored. See Matplotlib docs for more details on colormap normalization, and the ERDs example for an example of its use.- New in v0.24. 
- 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,- 'Reds'is used for data that is either all-positive or all-negative, and- 'RdBu_r'is used otherwise.- 'interactive'is equivalent to- (None, True). Defaults to- None.- Warning - Interactive mode works smoothly only for a small amount of topomaps. Interactive mode is disabled by default for more than 2 topomaps. 
- colorbarbool
- Whether to add a colorbar to the plot. Default is - True.
- titlestr| ‘auto’ |None
- Title for the plot. If - "auto", will use the channel name (if- combineis- None) or state the number and method of combined channels used to generate the plot. If- None, no title is shown. Default is- None.
- maskndarray|None
- An - arrayof- booleanvalues, of the same shape as the data. Data that corresponds to- Falseentries in the mask are plotted differently, as determined by- mask_style,- mask_alpha, and- mask_cmap. Useful for, e.g., highlighting areas of statistical significance.- New in v0.16.0. 
- mask_styleNone| ‘both’ | ‘contour’ | ‘mask’
- How to distinguish the masked/unmasked regions of the plot. If - "contour", a line is drawn around the areas where the mask is- True. If- "mask", areas where the mask is- Falsewill be (partially) transparent, as determined by- mask_alpha. If- "both", both a contour and transparency are used. Default is- None, which is silently ignored if- maskis- Noneand is interpreted like- "both"otherwise.- New in v0.17. 
- mask_cmapmatplotlib colormap | str|None
- Colormap to use for masked areas of the plot. If a - str, must be a valid Matplotlib colormap name. If None,- cmapis used for both masked and unmasked areas. Ignored if- maskis- None. Default is- 'Greys'.- New in v0.17. 
- mask_alphafloat
- Relative opacity of the masked region versus the unmasked region, given as a - floatbetween 0 and 1 (i.e., 0 means masked areas are not visible at all). Defaults to- 0.1.- New in v0.16.0. 
- axesinstance of Axes|listofAxes|None
- The axes to plot into. If - None, a new- Figurewill be created with the correct number of axes. If- Axesare provided (either as a single instance or a- listof axes), the number of axes provided must match the number of picks. If- combineis not None,- axesmust either be an instance of Axes, or a list of length 1. Default is- None.
- showbool
- Show the figure if - True.
- verbosebool | str|int|None
- Control verbosity of the logging output. If - None, use the default verbosity level. See the logging documentation and- mne.verbose()for details. Should only be passed as a keyword argument.
 
- picks
- Returns:
- figslistof instances ofmatplotlib.figure.Figure
- A list of figures containing the time-frequency power. 
 
- figs
 
 - plot_joint(*, timefreqs=None, picks=None, exclude=(), combine='mean', tmin=None, tmax=None, fmin=None, fmax=None, baseline=None, mode='mean', dB=False, yscale='auto', vlim=(None, None), cnorm=None, cmap=None, colorbar=True, title=None, show=True, topomap_args=None, image_args=None, verbose=None)[source]#
- Plot TFRs as a two-dimensional image with topomap highlights. - Parameters:
- timefreqsNone|listoftuple|dictoftuple
- The time-frequency point(s) for which topomaps will be plotted. See Notes. 
- picksstr| array_like |slice|None
- Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., - ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g.,- ['MEG0111', 'MEG2623']will pick the given channels. Can also be the string values- 'all'to pick all channels, or- 'data'to pick data channels. None (default) will pick good data channels. Note that channels in- info['bads']will be included if their names or indices are explicitly provided.
- excludelistofstr| ‘bads’
- Channel names to exclude. If - 'bads', channels in- info['bads']are excluded; pass an empty list to include all channels (including “bad” channels, if any). Default is an empty- tuplewhich includes all channels.
- combine‘mean’ | ‘rms’ | callable()
- How to aggregate across channels. If a string, - "mean"uses- numpy.mean(),- "rms"computes the root-mean-square. If- callable(), it must operate on an- arrayof shape- (n_channels, n_freqs, n_times)and return an array of shape- (n_freqs, n_times). Defaults to- "mean".- Changed in version 1.3: Added support for - callable.
- tmin, tmaxfloat|None
- First and last times to include, in seconds. - Noneuses the first or last time present in the data. Default is- tmin=None, tmax=None(all times).
- fmin, fmaxfloat
- The lower- and upper-bound on frequencies of interest. Default is - Nonewhich is equivalent to- fmin=0, fmax=np.inf(spans all frequencies present in the data).
- baselineNone|tupleof length 2
- The time interval to consider as “baseline” when applying baseline correction. If - None, do not apply baseline correction. If a tuple- (a, b), the interval is between- aand- b(in seconds), including the endpoints. If- ais- None, the beginning of the data is used; and if- bis- None, it is set to the end of the data. If- (None, None), the entire time interval is used.- Note - The baseline - (a, b)includes both endpoints, i.e. all timepoints- tsuch that- a <= t <= b.- How baseline is computed is determined by the - modeparameter.
- mode‘mean’ | ‘ratio’ | ‘logratio’ | ‘percent’ | ‘zscore’ | ‘zlogratio’
- Perform baseline correction by - subtracting the mean of baseline values (‘mean’) (default) 
- 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’) 
 
- dBbool
- Whether to plot on a decibel scale. If - True, plots 10 × log₁₀(data).
- yscale‘auto’ | ‘linear’ | ‘log’
- The scale of the y (frequency) axis. ‘linear’ gives linear y axis, ‘log’ gives log-spaced y axis and ‘auto’ detects if frequencies are log-spaced and if so sets the y axis to ‘log’. Default is ‘auto’. 
- vlimtupleof length 2
- Lower and upper bounds of the colormap, typically a numeric value in the same units as the data. If both entries are - None, the bounds are set at ± the maximum absolute value of the data (yielding a colormap with midpoint at 0), or- (0, max(abs(data)))if the (possibly baselined) data are all-positive. Providing- Nonefor just one entry will set the corresponding boundary at the min/max of the data. To specify the colormap separately for the topomap annotations, see- topomap_args. Defaults to- (None, None).
- cnormmatplotlib.colors.Normalize|None
- How to normalize the colormap. If - None, standard linear normalization is performed. If not- None,- vminand- vmaxwill be ignored. See Matplotlib docs for more details on colormap normalization, and the ERDs example for an example of its use.
- cmapmatplotlib colormap | str
- The - Colormapto use. If a- str, must be a valid Matplotlib colormap name. Default is- "RdBu_r".
- colorbarbool
- Whether to add a colorbar to the plot (for the topomap annotations). Not compatible with user-defined - axes. Default is- True.
- titlestr|None
- The title of the generated figure. If - None(default), no title is displayed.
- showbool
- Show the figure if - True.
- topomap_argsdict|None
- Keyword arguments to pass to - mne.viz.plot_topomap().- axesand- showare ignored. If- timesis not in this dict, automatic peak detection is used. Beyond that, if- None, no customizable arguments will be passed. Defaults to- None(i.e., an empty- dict).
- image_argsdict|None
- Keyword arguments to pass to - mne.time_frequency.AverageTFR.plot().- axesand- showare ignored. Defaults to- None(i.e., and empty- dict).
- verbosebool | str|int|None
- Control verbosity of the logging output. If - None, use the default verbosity level. See the logging documentation and- mne.verbose()for details. Should only be passed as a keyword argument.
 
- timefreqs
- Returns:
- figmatplotlib.figure.Figure
- The figure containing the topography. 
 
- fig
 - Notes - timefreqshas 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 ms 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 and 9 to 11 Hz. If - None, a single topomap will be plotted at the absolute peak across the time-frequency representation.- New in v0.16.0. 
 - 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', fig_background=None, font_color='w', yscale='auto', verbose=None)[source]#
- Plot a TFR image for each channel in a sensor layout arrangement. - Parameters:
- picksstr| array_like |slice|None
- Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., - ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g.,- ['MEG0111', 'MEG2623']will pick the given channels. Can also be the string values- 'all'to pick all channels, or- 'data'to pick data channels. None (default) will pick good data channels. Note that channels in- info['bads']will be included if their names or indices are explicitly provided.
- baselineNone|tupleof length 2
- The time interval to consider as “baseline” when applying baseline correction. If - None, do not apply baseline correction. If a tuple- (a, b), the interval is between- aand- b(in seconds), including the endpoints. If- ais- None, the beginning of the data is used; and if- bis- None, it is set to the end of the data. If- (None, None), the entire time interval is used.- Note - The baseline - (a, b)includes both endpoints, i.e. all timepoints- tsuch that- a <= t <= b.- How baseline is computed is determined by the - modeparameter.
- mode‘mean’ | ‘ratio’ | ‘logratio’ | ‘percent’ | ‘zscore’ | ‘zlogratio’
- Perform baseline correction by - subtracting the mean of baseline values (‘mean’) (default) 
- 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’) 
 
- tmin, tmaxfloat|None
- First and last times to include, in seconds. - Noneuses the first or last time present in the data. Default is- tmin=None, tmax=None(all times).
- fmin, fmaxfloat
- The lower- and upper-bound on frequencies of interest. Default is - Nonewhich is equivalent to- fmin=0, fmax=np.inf(spans all frequencies present in the data).
- vmin, vmaxfloat|None
- Lower and upper bounds of the colormap, in the same units as the data. If - vminand- vmaxare both- None, the bounds are set at ± the maximum absolute value of the data (yielding a colormap with midpoint at 0). If only one of- vmin,- vmaxis- None, will use- min(data)or- max(data), respectively.
- layoutinstance of Layout|None
- Layout instance specifying sensor positions (does not need to be specified for Neuromag data). If - None(default), the layout is inferred from the data (if possible).
- cmapmatplotlib colormap | str
- The - Colormapto use. If a- str, must be a valid Matplotlib colormap name. Default is- "RdBu_r".
- titlestr|None
- The title of the generated figure. If - None(default), no title is displayed.
- dBbool
- Whether to plot on a decibel scale. If - True, plots 10 × log₁₀(data).
- colorbarbool
- Whether to add a colorbar to the plot. Default is - True.
- layout_scalefloat
- Scaling factor for adjusting the relative size of the layout on the canvas. 
- showbool
- Show the figure if - True.
- borderstr
- Matplotlib border style to be used for each sensor plot. 
- fig_facecolorstr|tuple
- A matplotlib-compatible color to use for the figure background. 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_colorcolor
- The color of tick labels in the colorbar. Defaults to white. 
- yscale‘auto’ | ‘linear’ | ‘log’
- The scale of the y (frequency) axis. ‘linear’ gives linear y axis, ‘log’ gives log-spaced y axis and ‘auto’ detects if frequencies are log-spaced and if so sets the y axis to ‘log’. Default is ‘auto’. 
- verbosebool | str|int|None
- Control verbosity of the logging output. If - None, use the default verbosity level. See the logging documentation and- mne.verbose()for details. Should only be passed as a keyword argument.
 
- picks
- Returns:
- figmatplotlib.figure.Figure
- The figure containing the topography. 
 
- fig
 
 - plot_topomap(tmin=None, tmax=None, fmin=0.0, fmax=inf, *, ch_type=None, baseline=None, mode='mean', sensors=True, show_names=False, mask=None, mask_params=None, contours=6, outlines='head', sphere=None, image_interp='cubic', extrapolate='auto', border='mean', res=64, size=2, cmap=None, vlim=(None, None), cnorm=None, colorbar=True, cbar_fmt='%1.1e', units=None, axes=None, show=True)[source]#
- Plot topographic maps of specific time-frequency intervals of TFR data. - Parameters:
- tmin, tmaxfloat|None
- First and last times to include, in seconds. - Noneuses the first or last time present in the data. Default is- tmin=None, tmax=None(all times).
- fmin, fmaxfloat
- The lower- and upper-bound on frequencies of interest. Default is - fmin=0, fmax=np.inf(spans all frequencies present in the data).
- ch_type‘mag’ | ‘grad’ | ‘planar1’ | ‘planar2’ | ‘eeg’ | None
- The channel type to plot. For - 'grad', the gradiometers are collected in pairs and the mean for each pair is plotted. If- Nonethe first available channel type from order shown above is used. Defaults to- None.
- baselinetupleorlistof 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) the whole time interval is used. 
- mode‘mean’ | ‘ratio’ | ‘logratio’ | ‘percent’ | ‘zscore’ | ‘zlogratio’ | None
- Perform baseline correction by - subtracting the mean baseline power (‘mean’) 
- dividing by the mean baseline power (‘ratio’) 
- dividing by the mean baseline power and taking the log (‘logratio’) 
- subtracting the mean baseline power followed by dividing by the mean baseline power (‘percent’) 
- subtracting the mean baseline power and dividing by the standard deviation of the baseline power (‘zscore’) 
- dividing by the mean baseline power, taking the log, and dividing by the standard deviation of the baseline power (‘zlogratio’) 
 - If None no baseline correction is applied. 
- sensorsbool | str
- Whether to add markers for sensor locations. If - str, should be a valid matplotlib format string (e.g.,- 'r+'for red plusses, see the Notes section of- plot()). If- True(the default), black circles will be used.
- show_namesbool | callable()
- If - True, show channel names next to each sensor marker. If callable, 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- maskis not- None, only non-masked sensor names will be shown.
- maskndarrayof bool, shape (n_channels, n_times) |None
- Array indicating channel-time combinations to highlight with a distinct plotting style (useful for, e.g. marking which channels at which times a statistical test of the data reaches significance). Array elements set to - Truewill be plotted with the parameters given in- mask_params. Defaults to- None, equivalent to an array of all- Falseelements.
- mask_paramsdict|None
- Additional plotting parameters for plotting significant sensors. Default (None) equals: - dict(marker='o', markerfacecolor='w', markeredgecolor='k', linewidth=0, markersize=4) 
- contoursint| array_like
- The number of contour lines to draw. If - 0, no contours will be drawn. If a positive integer, that number of contour levels are chosen using the matplotlib tick locator (may sometimes be inaccurate, use array for accuracy). If array-like, the array values are used as the contour levels. The values should be in µV for EEG, fT for magnetometers and fT/m for gradiometers. If- colorbar=True, the colorbar will have ticks corresponding to the contour levels. Default is- 6.
- outlines‘head’ | dict|None
- The outlines to be drawn. If ‘head’, the default head scheme will be drawn. If dict, each key refers to a tuple of x and y positions, the values in ‘mask_pos’ will serve as image mask. 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’. 
- spherefloat| array_like offloat| instance ofConductorModel|str|listofstr|None
- The sphere parameters to use for the head outline. Can be array-like of shape (4,) to give the X/Y/Z origin and radius in meters, or a single float to give just the radius (origin assumed 0, 0, 0). Can also be an instance of a spherical - ConductorModelto use the origin and radius from that object. Can also be a- str, in which case:- 'auto': the sphere is fit to external digitization points first, and to external + EEG digitization points if the former fails.
- 'eeglab': the head circle is defined by EEG electrodes- 'Fpz',- 'Oz',- 'T7', and- 'T8'(if- 'Fpz'is not present, it will be approximated from the coordinates of- 'Oz').- 'extra': the sphere is fit to external digitization points.
- 'eeg': the sphere is fit to EEG digitization points.
- 'cardinal': the sphere is fit to cardinal digitization points.
- 'hpi': the sphere is fit to HPI coil digitization points.
 
 - Can also be a list of - str, in which case the sphere is fit to the specified digitization points, which can be any combination of- 'extra',- 'eeg',- 'cardinal', and- 'hpi', as specified above.- None(the default) is equivalent to- 'auto'when enough extra digitization points are available, and (0, 0, 0, 0.095) otherwise.- New in v0.20. - Changed in version 1.1: Added - 'eeglab'option.- Changed in version 1.11: Added - 'extra',- 'eeg',- 'cardinal',- 'hpi'and list of- stroptions.
- image_interpstr
- The image interpolation to be used. Options are - 'cubic'(default) to use- scipy.interpolate.CloughTocher2DInterpolator,- 'nearest'to use- scipy.spatial.Voronoior- 'linear'to use- scipy.interpolate.LinearNDInterpolator.
- extrapolatestr
- Options: - 'box'
- 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. 
 
- 'local'(default for MEG sensors)
- Extrapolate only to nearby points (approximately to points closer than median inter-electrode distance). This will also set the mask to be polygonal based on the convex hull of the sensors. 
 
- 'head'(default for non-MEG sensors)
- Extrapolate out to the edges of the clipping circle. This will be on the head circle when the sensors are contained within the head circle, but it can extend beyond the head when sensors are plotted outside the head circle. 
 
 - Changed in version 0.21: - The default was changed to - 'local'for MEG sensors.
- 'local'was changed to use a convex hull mask
- 'head'was changed to extrapolate out to the clipping circle.
 
- borderfloat| ‘mean’
- Value to extrapolate to on the topomap borders. If - 'mean'(default), then each extrapolated point has the average value of its neighbours.- New in v0.20. 
- resint
- The resolution of the topomap image (number of pixels along each side). 
- sizefloat
- Side length of each subplot in inches. 
- 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,- 'Reds'is used for data that is either all-positive or all-negative, and- 'RdBu_r'is used otherwise.- 'interactive'is equivalent to- (None, True). Defaults to- None.- Warning - Interactive mode works smoothly only for a small amount of topomaps. Interactive mode is disabled by default for more than 2 topomaps. 
- vlimtupleof length 2
- Lower and upper bounds of the colormap, typically a numeric value in the same units as the data. If both entries are - None, the bounds are set at- (min(data), max(data)). Providing- Nonefor just one entry will set the corresponding boundary at the min/max of the data. Defaults to- (None, None).- New in v1.2. 
- cnormmatplotlib.colors.Normalize|None
- How to normalize the colormap. If - None, standard linear normalization is performed. If not- None,- vminand- vmaxwill be ignored. See Matplotlib docs for more details on colormap normalization, and the ERDs example for an example of its use.- New in v1.2. 
- colorbarbool
- Plot a colorbar in the rightmost column of the figure. 
- cbar_fmtstr
- Formatting string for colorbar tick labels. See Format Specification Mini-Language for details. 
- unitsstr|None
- The units to use for the colorbar label. Ignored if - colorbar=False. If- Nonethe label will be “AU” indicating arbitrary units. Default is- None.
- axesinstance of Axes|None
- The axes to plot into. If - None, a new- Figurewill be created. Default is- None.
- showbool
- Show the figure if - True.
 
- tmin, tmax
- Returns:
- figmatplotlib.figure.Figure
- The figure containing the topography. 
 
- fig
 
 - reorder_channels(ch_names)[source]#
- Reorder channels. - Parameters:
- ch_nameslist
- The desired channel order. 
 
- ch_names
- Returns:
 - See also - Notes - Channel names must be unique. Channels that are not in - ch_namesare dropped.- New in v0.16.0. 
 - save(fname, *, overwrite=False, verbose=None)[source]#
- Save time-frequency data to disk (in HDF5 format). - Parameters:
- fnamepath-like
- Path of file to save to, which should end with - -tfr.h5or- -tfr.hdf5.
- overwritebool
- If True (default False), overwrite the destination file if it exists. 
- verbosebool | str|int|None
- Control verbosity of the logging output. If - None, use the default verbosity level. See the logging documentation and- mne.verbose()for details. Should only be passed as a keyword argument.
 
 - See also 
 - property sfreq#
- Sampling frequency of the data. 
 - property shape#
- Data shape. 
 - shift_time(tshift, relative=True)[source]#
- Shift time scale in epoched or evoked data. - Parameters:
- tshiftfloat
- The (absolute or relative) time shift in seconds. If - relativeis True, positive tshift increases the time value associated with each sample, while negative tshift decreases it.
- relativebool
- If True, increase or decrease time values by - tshiftseconds. Otherwise, shift the time values such that the time of the first sample equals- tshift.
 
- tshift
- Returns:
- epochsMNE-object
- The modified instance. 
 
 - Notes - This method allows you to shift the time values associated with each data sample by an arbitrary amount. It does not resample the signal or change the data values in any way. 
 - property times#
- The time points present in the data (in seconds). 
 - property tmax#
- Last time point. 
 - property tmin#
- First time point. 
 - to_data_frame(picks=None, index=None, long_format=False, time_format=None, *, verbose=None)[source]#
- Export data in tabular structure as a pandas DataFrame. - Channels are converted to columns in the DataFrame. By default, additional columns - 'time',- 'freq',- 'taper',- 'epoch', and- 'condition'(epoch event description) are added, unless- indexis not- None(in which case the columns specified in- indexwill be used to form the DataFrame’s index instead).- 'epoch', and- 'condition'are not supported for- AverageTFR.- 'taper'is only supported when a taper dimensions is present, such as for complex or phase multitaper data.- Parameters:
- picksstr| array_like |slice|None
- Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., - ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g.,- ['MEG0111', 'MEG2623']will pick the given channels. Can also be the string values- 'all'to pick all channels, or- 'data'to pick data channels. None (default) will pick all channels. Note that channels in- info['bads']will be included if their names or indices are explicitly provided.
- indexstr|listofstr|None
- Kind of index to use for the DataFrame. If - None, a sequential integer index (- pandas.RangeIndex) will be used. If- 'time', a- pandas.Indexor- pandas.TimedeltaIndexwill be used (depending on the value of- time_format). If a list of two or more string values, a- pandas.MultiIndexwill be created. Valid string values are- 'time',- 'freq',- 'taper',- 'epoch', and- 'condition'for- EpochsTFRand- 'time',- 'freq', and- 'taper'for- AverageTFR. Defaults to- None.
- long_formatbool
- If True, the DataFrame is returned in long format where each row is one observation of the signal at a unique combination of time point, channel, epoch number, and condition. For convenience, a - ch_typecolumn is added to facilitate subsetting the resulting DataFrame. Defaults to- False.
- time_formatstr|None
- Desired time format. If - None, no conversion is applied, and time values remain as float values in seconds. If- 'ms', time values will be rounded to the nearest millisecond and converted to integers. If- 'timedelta', time values will be converted to- pandas.Timedeltavalues. Default is- Noneunless specified otherwise.- New in v0.23. 
- verbosebool | str|int|None
- Control verbosity of the logging output. If - None, use the default verbosity level. See the logging documentation and- mne.verbose()for details. Should only be passed as a keyword argument.
 
- picks
- Returns:
- dfinstance of pandas.DataFrame
- A dataframe suitable for usage with other statistical/plotting/analysis packages. 
 
- dfinstance of 
 
 - property weights#
- The weights used for each taper in the time-frequency estimates.