mne_connectivity.viz.plot_circle_connectivity#

mne_connectivity.viz.plot_circle_connectivity(con, *, info=None, picks=None, selection='both', exclude='bads', node_aliases=None, n_lines=None, node_angles=None, node_width=None, node_height=1.0, node_colors=None, facecolor='black', textcolor='white', node_edgecolor='black', linewidth=1.5, colormap=None, vmin=None, vmax=None, colorbar=True, title=None, colorbar_size=0.2, colorbar_pos=(-0.3, 0.1), fontsize_title=12, fontsize_names=8, fontsize_colorbar=8, padding=6.0, ax=None, interactive=True, node_linewidth=2.0, show=True)[source]#

Visualize connectivity as a circular graph.

Parameters:
conConnectivity

The connectivity data to plot. Multivariate connectivity is not supported.

Changed in version 1.0: Arrays are no longer supported, so the indices parameter was removed.

infomne.Info | None

The mne.Info object with information about the sensors and methods of measurement. Used to identify bad channels. If None (default), all channels are assumed to be good 'misc' channels.

Added in version 1.0.

picksstr | 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 in info['bads'] will be included if their names or indices are explicitly provided.

Added in version 1.0.

selection'seeds' | 'targets' | 'both'

What the picks parameter will be applied to. If 'seeds', only connections within the seed channels matchinng picks will be included. If 'targets', only connections within the target channels matching picks will be included. If 'both', connections will be included if either the seed or target channels match picks. Ignored if picks is None.

Added in version 1.0.

excludelist of str | 'bads'

Channel names to exclude from plotting. All connections involving these channels will be excluded. If 'bads' (default), channels in info['bads'] are excluded.

Added in version 1.0.

node_aliasesdict | 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. If None and plotting results for bivariate connectivity, node names will be taken from con.names. If None and plotting results for multivariate connectivity, node names will be generated as 'node {idx}', where idx is the order of the node in the unique set of indices, as determined by np.unique([*con.indices[0], *con.indices[1]]).

Added in version 1.0: Replaces the node_names parameter.

n_linesint | None

If not None, only the n_lines strongest connections (strength=abs(con)) are drawn.

node_anglesarray, shape (n_nodes,) | None

Array with node positions in degrees, in the order of con.names. If None, the nodes are equally spaced on the circle. See mne.viz.circular_layout().

node_widthfloat | None

Width of each node in degrees. If None, the minimum angle between any two nodes is used as the width.

node_heightfloat

The relative height of the colored bar labeling each node. Default 1.0 is the standard height.

node_colorslist of tuple | list of str

List with the color to use for each node. If fewer colors than nodes are provided, the colors will be repeated. Any color supported by matplotlib can be used, e.g., RGBA tuples, named colors.

facecolorstr

Color to use for background. See matplotlib.colors.

textcolorstr

Color to use for text. See matplotlib.colors.

node_edgecolorstr

Color to use for lines around nodes. See matplotlib.colors.

linewidthfloat

Line width to use for connections.

colormapstr | instance of matplotlib.colors.Colormap | None

Colormap to use for coloring the connections. If None (default), a diverging colormap is used when the drawn connections have both positive and negative values, or when vmin and vmax span zero: "berlin" on a dark facecolor ("RdBu_r" with matplotlib < 3.10) and "RdBu_r" on a light one. Otherwise, "hot" is used.

Changed in version 1.0: The default changed from "hot" to None.

vminfloat | None

Minimum value for colormap. If None, it is determined automatically.

vmaxfloat | None

Maximum value for colormap. If None, it is determined automatically. If both vmin and vmax are None and the drawn connections have both positive and negative values, the limits are symmetric around zero.

Changed in version 1.0: Automatic limits for data with both signs are symmetric around zero.

colorbarbool

Display a colorbar or not.

titlestr

The figure title.

colorbar_sizefloat

Size of the colorbar.

colorbar_postuple, shape (2,)

Position of the colorbar.

fontsize_titleint

Font size to use for title.

fontsize_namesint

Font size to use for node names.

fontsize_colorbarint

Font size to use for colorbar.

paddingfloat

Space to add around figure to accommodate long labels.

axinstance of matplotlib.projections.polar.PolarAxes | None

The axes to use to plot the connectivity circle.

interactivebool

When enabled, left-click on a node to show only connections to that node. Right-click shows all connections.

node_linewidthfloat

Line width for nodes.

showbool

Show figure if True.

Returns:
figinstance of matplotlib.figure.Figure

The figure handle.

axinstance of matplotlib.projections.polar.PolarAxes

The subplot handle.

Notes

This code is based on a circle graph example by Nicolas P. Rougier.

By default, matplotlib.pyplot.savefig() does not take facecolor into account when saving, even if set when a figure is generated. This can be addressed via, e.g.:

>>> fig.savefig(fname_fig, facecolor='black')

If facecolor is not set via matplotlib.pyplot.savefig(), the figure labels, title, and legend may be cut off in the output figure.

Changed in version 1.0: Renamed from plot_connectivity_circle.