mne_connectivity.viz.plot_spectral_connectivity#
- mne_connectivity.viz.plot_spectral_connectivity(con, *, info=None, picks=None, selection='both', exclude='bads', combine=None, ci='sd', fmin=None, fmax=None, node_aliases=None, colors='auto', cmap='turbo', highlight=None, interactive=True, show=True)[source]#
Plot spectral connectivity as line plots, with circle plot overviews.
- Parameters:
- con
SpectralConnectivity The spectral 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.- combine
'mean'|callable()|None How to aggregate across connections.
'mean'usesnumpy.mean(). Ifcallable(), it must operate on an array of shape(n_connections, n_freqs)and return an array of shape(n_freqs,). IfNone, plot each connection individually. Defaults toNone.- ci
float|'sd'|'range'|None Type of confidence band drawn around the aggregated data when
combineis notNone. If'sd'(default) the band spans ±1 the standard deviation across connections. If'range'the band spans the range across connections at each bin. If a float, it indicates the (bootstrapped) confidence interval to display, and must satisfy0 < ci <= 100. IfNone, no band is drawn.- fmin, fmax
float|None First and last frequencies to plot, in Hz. If
Nonetake the first/last frequency in the data, respectively. Default isNone.- 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]]).- colors
'auto'|'global'|'relative' How to color the connections. If
'global', the same colormap is used across all connections. This is recommended if the connectivity indices do not correspond to a full or symmetric matrix. If'relative', the connections for each channel span the full colormap. This is recommended if the connectivity indices correspond to a full or symmetric matrix. If'auto'(default), the coloring is set to'relative'if the connectivity indices correspond to a lower-triangular matrix andinteractiveisTrue, or'global'otherwise.- cmap
str|matplotlib.colors.Colormap Colormap to use for coloring the connections. If a str, must be a recognised Matplotlib colormap name. Default is
'turbo'.- highlightarray_like of
float, shape (2,) | array_like offloat, shape (n, 2) |None Segments of the data to highlight by means of a light-yellow background color. The data periods to highlight must be specified as array-like objects in the form of
(start, end)in the units of the data. Multiple periods can be specified by passing an array-like object of individual periods (e.g., for 3 periods, the shape of the passed object would be(3, 2). IfNone(default), no highlighting is applied.- interactivebool
Whether to make the plot interactive. This enables functionality like clicking on a connection to show its name. Defaults to
True.- 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
The circle plot acts as an overview of the channels and their connections in the line plot. If
interactiveisTrue, left-clicking on a channel in the circle plot will show the connections only for that channel (the exact behaviour is determined byselection). Right-click to return to the original view. The circle plot is not shown if the plotted connections correspond to only a single node in the figure.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)', ....