visbrain.objects.TopoObj

class visbrain.objects.TopoObj(name, data, xyz=None, channels=None, system='cartesian', levels=None, level_colors='white', unit='degree', line_color='black', line_width=3.0, chan_size=12.0, chan_offset=(0.0, 0.0, 0.0), chan_mark_color='white', chan_mark_symbol='disc', chan_txt_color='black', cmap='viridis', clim=None, vmin=None, under='gray', vmax=None, over='red', margin=0.05, transform=None, parent=None, verbose=None, **kw)[source][source]

Create a topoplot object.

Parameters:
name : string

The name of the connectivity object.

data : array_like

Array of data of shape (n_channels)

xyz : array_like | None

Array of source’s coordinates.

channels : list | None

List of channel names.

system : {‘cartesian’, ‘spherical’}

Coordinate system.

levels : array_like/int | None

The levels at which the isocurve is constructed.

level_colors : string/array_like | ‘white’

The color to use when drawing the line. If a list is given, it must be of shape (Nlev), if an array is given, it must be of shape (Nlev, …). and provide one color per level (rgba, colorname). By default, all levels are whites.

unit : {‘degree’, ‘rad’}

If system is ‘spherical’, specify if angles are in degrees or radians.

line_color : array_like/string | ‘black’

Color of lines for the head, nose and eras.

line_width : float | 4.

Line width for the head, nose and eras.

chan_size : float | 12.

Size of channel names text.

chan_mark_color : array_like/string | ‘white’

Color of channel markers.

chan_mark_symbol : string | ‘disc’

Symbol to use for markers. Use disc, arrow, ring, clobber, square, diamond, vbar, hbar, cross, tailed_arrow, x, triangle_up, triangle_down, and star.

chan_txt_color : array_like/string | ‘black’

Color of channel names.

cmap : string | None

Matplotlib colormap (like ‘viridis’, ‘inferno’…).

clim : tuple/list | None

Colorbar limit. Every values under / over clim will clip.

vmin : float | None

Every values under vmin will have the color defined using the under parameter.

vmax : float | None

Every values over vmin will have the color defined using the over parameter.

under : tuple/string | None

Matplotlib color under vmin.

over : tuple/string | None

Matplotlib color over vmax.

transform : VisPy.visuals.transforms | None

VisPy transformation to set to the parent node.

parent : VisPy.parent | None

Line object parent.

verbose : string

Verbosity level.

kw : dict | {}

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

Notes

List of supported shortcuts :

  • s : save the figure
  • <delete> : reset camera

Methods

__init__(name, data[, xyz, channels, …]) Init.
connect(connect, **kwargs) Draw connectivity lines between channels.
copy() Get a copy of the object.
describe_tree() Tree description.
preview([bgcolor, axis, xyz, show, obj, size]) Previsualize the result.
screenshot(saveas[, print_size, dpi, unit, …]) Take a screeshot of the scene.
set_data(data[, levels, level_colors, cmap, …]) Set data to the topoplot.
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() Fonction to run when an update is needed.
update_from_dict(kwargs) Update attributes from a dictionary.
cmap

Get the cmap value.

connect(connect, **kwargs)[source][source]

Draw connectivity lines between channels.

Parameters:
connect : array_like

A 2D array of connectivity links of shape (n_channels, n_channels).

kwargs : dict | {}

Optional arguments are passed to the visbrain.objects.ConnectObj object.

copy()[source]

Get a copy of the object.

data_folder

Get the data_folder value.

name

Get the name value.

parent

Get the parent value.

preview(bgcolor='black', axis=False, xyz=False, show=True, obj=None, size=(1200, 800), **kwargs)[source]

Previsualize the result.

Parameters:
bgcolor : array_like/string/tuple | ‘black’

Background color for the preview.

axis : bool | False

Add x and y axis with ticks.

xyz : bool | False

Add an (x, y, z) axis to the scene.

obj : VisbrainObj | None

Pass a Visbrain object if you want to use the camera of an other object.

size : tuple | (1200, 800)

Default size of the window.

kwargs : dict | {}

Optional arguments are passed to the VisbrainCanvas class.

screenshot(saveas, print_size=None, dpi=300.0, unit='centimeter', factor=None, region=None, autocrop=False, bgcolor=None, transparent=False, obj=None, line_width=1.0, **kwargs)[source]

Take a screeshot of the scene.

By default, the rendered canvas will have the size of your screen. The screenshot() method provides two ways to increase to exported image resolution :

  • Using print_size, unit and dpi inputs : specify the size of the image at a specific dpi level. For example, you might want to have an (10cm, 15cm) image at 300 dpi.
  • Using the factor input : multiply the default image size by this factor. For example, if you have a (1920, 1080) monitor and if factor is 2, the exported image should have a shape of (3840, 2160) pixels.
Parameters:
saveas : str

The name of the file to be saved. This file must contains a extension like .png, .tiff, .jpg…

print_size : tuple | None

The desired print size. This argument should be used in association with the dpi and unit inputs. print_size describe should be a tuple of two floats describing (width, height) of the exported image for a specific dpi level. The final image might not have the exact desired size but will try instead to find a compromize regarding to the proportion of width/height of the original image.

dpi : float | 300.

Dots per inch for printing the image.

unit : {‘centimeter’, ‘millimeter’, ‘pixel’, ‘inch’}

Unit of the printed size.

factor : float | None

If you don’t want to use the print_size input, factor simply multiply the resolution of your screen.

region : tuple | None

Select a specific region. Must be a tuple of four integers each one describing (x_start, y_start, width, height).

autocrop : bool | False

Automaticaly crop the figure in order to have the smallest space between the brain and the border of the picture.

bgcolor : array_like/string | None

The background color of the image.

transparent : bool | False

Specify if the exported figure have to contains a transparent background.

obj : VisbrainObj | None

Pass a Visbrain object if you want to use the camera of an other object for the sceen rendering.

kwargs : dict | {}

Optional arguments are passed to the VisbrainCanvas class.

set_data(data, levels=None, level_colors='white', cmap='viridis', clim=None, vmin=None, under='gray', vmax=None, over='red')[source][source]

Set data to the topoplot.

Parameters:
data : array_like

Array of data of shape (n_channels)

levels : array_like/int | None

The levels at which the isocurve is constructed.

level_colors : string/array_like | ‘white’

The color to use when drawing the line. If a list is given, it must be of shape (Nlev), if an array is given, it must be of shape (Nlev, …). and provide one color per level (rgba, colorname). By default, all levels are whites.

cmap : string | None

Matplotlib colormap (like ‘viridis’, ‘inferno’…).

clim : tuple/list | None

Colorbar limit. Every values under / over clim will clip.

vmin : float | None

Every values under vmin will have the color defined using the under parameter.

vmax : float | None

Every values over vmin will have the color defined using the over parameter.

under : tuple/string | None

Matplotlib color under vmin.

over : tuple/string | None

Matplotlib color over vmax.

transform

Get the transform value.

visible_obj

Get the visible_obj value.

Examples using visbrain.objects.TopoObj