visbrain.objects.VectorObj

class visbrain.objects.VectorObj(name, arrows, data=None, inferred_data=False, select=None, color='black', dynamic=None, line_width=5.0, arrow_size=10.0, arrow_type='stealth', arrow_coef=1.0, arrow_norm=(5.0, 20.0), antialias=False, cmap='viridis', clim=None, vmin=None, under='gray', vmax=None, over='red', transform=None, parent=None, verbose=None, _z=-10.0, **kw)[source][source]

Create a vector object.

Parameters:
name : string

Name of the vector object.

arrows : array_like, tuple, list

The position of arrows. Use either :

  • A list (or tuple) of two arrays with identical shapes (N, 3). The first array specify the (x, y, z) position where arrows start and the second the (x, y, z) position of the end of each arrow.
  • Alternatively to the point above, an array of type [(‘start’, float, 3), (‘end’, float, 3)] can also be used.
  • An array of type [(‘vertices’, float, 3), (‘normals’, float, 3)]. This method use the normals to vertices to inferred the arrow locations. In addition, if data is not None, data is used to inferred the arrow length.
data : array_like | None

Attach some data to each vector. This data can be used to inferred the color.

inferred_data : bool | False

If the arrows input use the (start, end) method and if inferred_data is set to True, the magnitude of each vector is used as data.

select : array_like | None

An array of boolean values to select some specifics arrows.

color : array_like/tuple/string | ‘black’

If no data are provided, use this parameter to set a unique color for all vectors.

dynamic : tuple | None

Use a dynamic transparency method. The dynamic input must be a tuple of two float between [0, 1]. Vectors with stronger associated data are going to be set more opaque.

line_width : float | 5.

Line width of each vector.

arrow_size : float | 10.

Size of the arrow-head.

arrow_type : string | ‘stealth’

The arrow-head type. Use either ‘stealth’, ‘curved’, ‘angle_30’, ‘angle_60’, ‘angle_90’, ‘triangle_30’, ‘triangle_60’, ‘triangle_90’ or ‘inhibitor_round’.

arrow_coef : float | 1.

Use this coefficient to define longer arrows. Must be a float superior to 1.

arrow_norm : tuple | (5., 20.)

Control arrow length for arrows defined using vertices and normals.

antialias : bool | False

Use smoothed lines.

cmap : string | ‘viridis’

The colormap to use (if data is not None).

clim : tuple | None

Colorbar limits. If None, the (max, min) of data is used (if data is not None).

vmin : float | None

Minimum threshold (if data is not None).

under : string | ‘gray’

Color for values under vmin (if data is not None).

vmax : float | None

Maximum threshold (if data is not None).

over : string | ‘red’

Color for values over vmax (if data is not None).

transform : VisPy.visuals.transforms | None

VisPy transformation to set to the parent node.

parent : VisPy.parent | None

Markers object parent.

verbose : string

Verbosity level.

_z : float | 10.

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

kw : dict | {}

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 VectorObj
>>> n_vector = 10
>>> arrows = [np.random.rand(n_vector, 3), np.random.rand(n_vector, 3)]
>>> data = np.random.uniform(-10, 10, (n_vector))
>>> v = VectorObj('Vector', arrows, data=data, antialias=True)
>>> v.preview(axis=True)

Methods

__init__(name, arrows[, data, …]) Init.
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_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.
arrow_size

Get the arrow_size value.

arrow_type

Get the arrow_type value.

cmap

Get the cmap value.

line_width

Get the line_width 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.

transform

Get the transform value.

visible_obj

Get the visible_obj value.

Examples using visbrain.objects.VectorObj