Skip to content

Commit 9fa97b6

Browse files
committed
put back plot_topomap
1 parent 06bcd59 commit 9fa97b6

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

mne/time_frequency/tfr.py

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,135 @@ def plot_topo(self, picks=None, baseline=None, mode='mean', tmin=None,
12581258
plt_show(show)
12591259
return fig
12601260

1261+
def plot_topomap(self, tmin=None, tmax=None, fmin=None, fmax=None,
1262+
ch_type=None, baseline=None, mode='mean',
1263+
layout=None, vmin=None, vmax=None, cmap=None,
1264+
sensors=True, colorbar=True, unit=None, res=64, size=2,
1265+
cbar_fmt='%1.1e', show_names=False, title=None,
1266+
axes=None, show=True, outlines='head', head_pos=None):
1267+
"""Plot topographic maps of time-frequency intervals of TFR data
1268+
1269+
Parameters
1270+
----------
1271+
tmin : None | float
1272+
The first time instant to display. If None the first time point
1273+
available is used.
1274+
tmax : None | float
1275+
The last time instant to display. If None the last time point
1276+
available is used.
1277+
fmin : None | float
1278+
The first frequency to display. If None the first frequency
1279+
available is used.
1280+
fmax : None | float
1281+
The last frequency to display. If None the last frequency
1282+
available is used.
1283+
ch_type : 'mag' | 'grad' | 'planar1' | 'planar2' | 'eeg' | None
1284+
The channel type to plot. For 'grad', the gradiometers are
1285+
collected in pairs and the RMS for each pair is plotted.
1286+
If None, then first available channel type from order given
1287+
above is used. Defaults to None.
1288+
baseline : tuple or list of length 2
1289+
The time interval to apply rescaling / baseline correction.
1290+
If None do not apply it. If baseline is (a, b)
1291+
the interval is between "a (s)" and "b (s)".
1292+
If a is None the beginning of the data is used
1293+
and if b is None then b is set to the end of the interval.
1294+
If baseline is equal to (None, None) all the time
1295+
interval is used.
1296+
mode : None | 'ratio' | 'zscore' | 'mean' | 'percent' | 'logratio' | 'zlogratio'
1297+
Do baseline correction with ratio (power is divided by mean
1298+
power during baseline) or zscore (power is divided by standard
1299+
deviation of power during baseline after subtracting the mean,
1300+
power = [power - mean(power_baseline)] / std(power_baseline)),
1301+
mean simply subtracts the mean power, percent is the same as
1302+
applying ratio then mean, logratio is the same as mean but then
1303+
rendered in log-scale, zlogratio is the same as zscore but data
1304+
is rendered in log-scale first.
1305+
If None no baseline correction is applied.
1306+
layout : None | Layout
1307+
Layout instance specifying sensor positions (does not need to
1308+
be specified for Neuromag data). If possible, the correct layout
1309+
file is inferred from the data; if no appropriate layout file was
1310+
found, the layout is automatically generated from the sensor
1311+
locations.
1312+
vmin : float | callable | None
1313+
The value specifying the lower bound of the color range. If None,
1314+
and vmax is None, -vmax is used. Else np.min(data) or in case
1315+
data contains only positive values 0. If callable, the output
1316+
equals vmin(data). Defaults to None.
1317+
vmax : float | callable | None
1318+
The value specifying the upper bound of the color range. If None,
1319+
the maximum value is used. If callable, the output equals
1320+
vmax(data). Defaults to None.
1321+
cmap : matplotlib colormap | (colormap, bool) | 'interactive' | None
1322+
Colormap to use. If tuple, the first value indicates the colormap
1323+
to use and the second value is a boolean defining interactivity. In
1324+
interactive mode the colors are adjustable by clicking and dragging
1325+
the colorbar with left and right mouse button. Left mouse button
1326+
moves the scale up and down and right mouse button adjusts the
1327+
range. Hitting space bar resets the range. Up and down arrows can
1328+
be used to change the colormap. If None (default), 'Reds' is used
1329+
for all positive data, otherwise defaults to 'RdBu_r'. If
1330+
'interactive', translates to (None, True).
1331+
sensors : bool | str
1332+
Add markers for sensor locations to the plot. Accepts matplotlib
1333+
plot format string (e.g., 'r+' for red plusses). If True, a circle
1334+
will be used (via .add_artist). Defaults to True.
1335+
colorbar : bool
1336+
Plot a colorbar.
1337+
unit : dict | str | None
1338+
The unit of the channel type used for colorbar label. If
1339+
scale is None the unit is automatically determined.
1340+
res : int
1341+
The resolution of the topomap image (n pixels along each side).
1342+
size : float
1343+
Side length per topomap in inches.
1344+
cbar_fmt : str
1345+
String format for colorbar values.
1346+
show_names : bool | callable
1347+
If True, show channel names on top of the map. If a callable is
1348+
passed, channel names will be formatted using the callable; e.g.,
1349+
to delete the prefix 'MEG ' from all channel names, pass the
1350+
function lambda x: x.replace('MEG ', ''). If `mask` is not None,
1351+
only significant sensors will be shown.
1352+
title : str | None
1353+
Title. If None (default), no title is displayed.
1354+
axes : instance of Axes | None
1355+
The axes to plot to. If None the axes is defined automatically.
1356+
show : bool
1357+
Call pyplot.show() at the end.
1358+
outlines : 'head' | 'skirt' | dict | None
1359+
The outlines to be drawn. If 'head', the default head scheme will
1360+
be drawn. If 'skirt' the head scheme will be drawn, but sensors are
1361+
allowed to be plotted outside of the head circle. If dict, each key
1362+
refers to a tuple of x and y positions, the values in 'mask_pos'
1363+
will serve as image mask, and the 'autoshrink' (bool) field will
1364+
trigger automated shrinking of the positions due to points outside
1365+
the outline. Alternatively, a matplotlib patch object can be passed
1366+
for advanced masking options, either directly or as a function that
1367+
returns patches (required for multi-axis plots). If None, nothing
1368+
will be drawn. Defaults to 'head'.
1369+
head_pos : dict | None
1370+
If None (default), the sensors are positioned such that they span
1371+
the head circle. If dict, can have entries 'center' (tuple) and
1372+
'scale' (tuple) for what the center and scale of the head should be
1373+
relative to the electrode locations.
1374+
1375+
Returns
1376+
-------
1377+
fig : matplotlib.figure.Figure
1378+
The figure containing the topography.
1379+
""" # noqa
1380+
from ..viz import plot_tfr_topomap
1381+
return plot_tfr_topomap(self, tmin=tmin, tmax=tmax, fmin=fmin,
1382+
fmax=fmax, ch_type=ch_type, baseline=baseline,
1383+
mode=mode, layout=layout, vmin=vmin, vmax=vmax,
1384+
cmap=cmap, sensors=sensors, colorbar=colorbar,
1385+
unit=unit, res=res, size=size,
1386+
cbar_fmt=cbar_fmt, show_names=show_names,
1387+
title=title, axes=axes, show=show,
1388+
outlines=outlines, head_pos=head_pos)
1389+
12611390
def _check_compat(self, tfr):
12621391
"""checks that self and tfr have the same time-frequency ranges"""
12631392
assert np.all(tfr.times == self.times)

0 commit comments

Comments
 (0)