visbrain.objects.ConnectObj

class visbrain.objects.ConnectObj(name, nodes, edges, select=None, line_width=3.0, color_by='strength', custom_colors=None, alpha=1.0, antialias=False, dynamic=None, dynamic_order=1, dynamic_orientation='ascending', cmap='viridis', clim=None, vmin=None, vmax=None, under='gray', over='red', transform=None, parent=None, verbose=None, _z=-10.0, **kw)[source][source]

Create a connectivity object.

Parameters:
namestring

The name of the connectivity object.

nodesarray_like

Array of nodes coordinates of shape (n_nodes, 3).

edgesarray_like | None

Array of ponderations for edges of shape (n_nodes, n_nodes).

selectarray_like | None

Array to select edges to display. This should be an array of boolean values of shape (n_nodes, n_nodes).

line_widthfloat | 3.

Connectivity line width.

color_by{‘strength’, ‘count’, ‘causal’}

Coloring method:

  • ‘strength’ : color edges according to their connection strength define by the edges input. Only the upper triangle of the connectivity array is considered.

  • ‘count’ : color edges according to the number of connections per node. Only the upper triangle of the connectivity array is considered.

  • ‘causal’ : color edges according to the connectivity strength but this time, the upper and lower triangles of the connectivity array in edges are considered.

custom_colorsdict | None

Use a dictionary to colorize edges. For example, {1.2: ‘red’, 2.8: ‘green’, None: ‘black’} turn connections that have a 1.2 and 2.8 strength into red and green. All others connections are set to black.

alphafloat | 1.

Transparency level (if dynamic is None).

antialiasbool | False

Use smoothed lines.

dynamictuple | None

Control the dynamic opacity. For example, if dynamic=(0, 1), strong connections will be more opaque than weaker connections.

dynamic_orderint | 1

If 1, the dynamic transparency is linearly modulated by the connectivity. If 2, the transparency follow a x**2 curve etc.

dynamic_orientationstr | ‘ascending’

Define the transparency behavior :

  • ‘ascending’ : from translucent to opaque

  • ‘center’ : from opaque to translucent and finish by opaque

  • ‘descending’ ; from opaque to translucent

cmapstring | ‘viridis’

Colormap to use if custom_colors is None.

vminfloat | None

Lower threshold of the colormap if custom_colors is None.

understring | None

Color to use for values under vmin if custom_colors is None.

vminfloat | None

Higher threshold of the colormap if custom_colors is None.

overstring | None

Color to use for values over vmax if custom_colors is None.

transformVisPy.visuals.transforms | None

VisPy transformation to set to the parent node.

parentVisPy.parent | None

Line object parent.

verbosestring

Verbosity level.

_zfloat | 10.

In case of (n_sources, 2) use _z to specify the elevation.

kwdict | {}

Optional arguments are used to control the colorbar (See ColorbarObj).

Notes

List of supported shortcuts :

  • s : save the figure

  • <delete> : reset camera

Examples

>>> import numpy as np
>>> from visbrain.objects import ConnectObj
>>> n_nodes = 100
>>> nodes = np.random.rand(n_nodes, 3)
>>> edges = np.random.uniform(low=-10., high=10., size=(n_nodes, n_nodes))
>>> select = np.logical_and(edges >= 0, edges <= 1.)
>>> c = ConnectObj('Connect', nodes, edges, select=select, cmap='inferno',
>>>                antialias=True)
>>> c.preview(axis=True)

Methods

__init__(name, nodes, edges[, select, ...])

Init.

analyse_connections([roi_obj, group_by, ...])

Analyse connections.

animate([step, interval, iterations])

Animate the object.

copy()

Get a copy of the object.

describe_tree()

Tree description.

get_nb_connections_per_node([sort, order])

Get the number of connections per node.

preview([bgcolor, axis, xyz, show, obj, ...])

Previsualize the result.

record_animation(name[, n_pic, bgcolor])

Record an animated object and save as a *.gif file.

render()

Render the canvas.

screenshot(saveas[, print_size, dpi, unit, ...])

Take a screeshot of the scene.

set_shortcuts_to_canvas(canvas)

Set shortcuts to a VisbrainCanvas.

to_dict()

Return a dictionary of all colorbar args.

to_kwargs([addisminmax])

Return a dictionary for input arguments.

update()

Update the line.

update_from_dict(kwargs)

Update attributes from a dictionary.

Examples using visbrain.objects.ConnectObj

Animate objects in the scene

Animate objects in the scene

Combine multiple objects

Combine multiple objects

Connectivity object (ConnectObj) : complete tutorial

Connectivity object (ConnectObj) : complete tutorial

Connect deep sources

Connect deep sources

Add multiple objects to the scene

Add multiple objects to the scene