mne_connectivity.viz.plot_connectivity#
- mne_connectivity.viz.plot_connectivity(con, *, info=None, picks=None, selection='both', exclude='bads', node_aliases=None, vmin=None, vmax=None, cnorm=None, cmap=None, colorbar=True, node_labels='ticks', mask=None, mask_style=None, mask_cmap='Greys', mask_alpha=0.1, show=True)[source]#
Plot connectivity as a matrix.
- Parameters:
- con
Connectivity The connectivity object to plot.
- info
mne.Info|None The
mne.Infoobject with information about the sensors and methods of measurement. Used to split the figures by channel types and identify bad channels. IfNone(default), all channels are assumed to be good'misc'channels.- picks
str| array_like |slice|None Channels to include in the plot. Connections involving these channels will be included, based on
selection. 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 any good channels. Note that channels ininfo['bads']will be included if their names or indices are explicitly provided.- selection
'seeds'|'targets'|'both' What the
picksparameter will be applied to. If'seeds', only connections within the seed channels matchinngpickswill be included. If'targets', only connections within the target channels matchingpickswill be included. If'both', connections will be included if either the seed or target channels matchpicks. Ignored ifpicksisNone.- exclude
listofstr|'bads' Channel names to exclude from plotting. All connections involving these channels will be excluded. If
'bads'(default), channels ininfo['bads']are excluded.- node_aliases
dict|None Mapping of node indices to node names. Keys should be seed or target indices found in
con.indices, that is, integers for bivariate connectivity, and arrays of integers for multivariate connectivity. IfNoneand plotting results for bivariate connectivity, node names will be taken fromcon.names. IfNoneand plotting results for multivariate connectivity, node names will be generated as'node {idx}', whereidxis the order of the node in the unique set of indices, as determined bynp.unique([*con.indices[0], *con.indices[1]]).- vmin, vmax
float|None Lower and upper bounds of the colormap, respectively. If both entries are
Noneand there are both positive and negative values in the data, the bounds are set at ± the maximum absolute value of the data (yielding a colormap with midpoint at 0). If both entries areNoneand the data is all positive or all negative, the bounds are set at the min/max of the data, respectively. ProvidingNonefor just one entry will set the corresponding boundary at the min/max of the data. Defaults toNone.- cnorm
matplotlib.colors.Normalize|None How to normalize the colormap. If
None(default), standard linear normalization is performed. If notNone,vminandvmaxwill be ignored. See Matplotlib docs for more details on colormap normalization.- cmap
str|matplotlib.colors.Colormap|None The colormap to use for coloring the connectivity values. If a str, must be a valid Matplotlib colormap name.If
None(default),'RdBu_r'is used for data that has positive and negative values,Redsis used for data that is all positive, andBlues_ris used for data that is all negative.- colorbarbool
Whether to display a colorbar for each figure. Defaults to
True.- node_labels
'ticks'|'names'|None How to label the nodes in the matrix along the x- and y-axes. If
'ticks'(default), the indices of the nodes are shown at evenly spaced intervals. Note that for many nodes, not all may have labels. If'names', each node’s name is shown. Note that for many nodes, this can lead to overlapping labels. IfNone, no labels are shown.- mask
numpy.ndarray|None An array of boolean values, of the same shape as the data. Data that corresponds to
Falseentries in the mask are plotted differently, as determined bymask_style,mask_alpha, andmask_cmap. Useful for, e.g., highlighting areas of statistical significance. Default isNone, for no masking.- mask_style
None|'contour'|'mask'|'both' How to distinguish the masked/unmasked regions of the plot. If
'contour', a line is drawn around the areas wheremaskis True. If'mask', areas wheremaskisFalsewill be (partially) transparent, as determined bymask_alpha. If'both', both a contour and transparency are used. Default isNone, which is silently ignored ifmaskisNone, and is interpreted like'both'otherwise.- mask_cmap
matplotlib.colors.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 mask isNone. Default is'Greys'.- mask_alpha
float Relative opacity of the masked region versus the unmasked region, given as a float between 0 and 1 (0 means masked areas are not visible at all). Defaults to
0.1.- showbool
Whether to show the figure(s). Defaults to
True.
- con
- Returns:
- figinstance of
matplotlib.figure.Figure|listof instance ofmatplotlib.figure.Figure The figure(s) containing the connectivity plot(s). One figure is returned per channel types in the seeds and targets.
- figinstance of
Notes
Plotting for multivariate connectivity is handled by treating each component of the multivariate connections as a separate connection. The names of the nodes are differentiated by the addition of the component number to the node name, e.g.,
'node 0 (0)', 'node 0 (1)', ....