Brain Innovation

support portal


Blockly is a software library developped by Google. The Blockly editor uses interlocking, graphical blocks to represent code concepts like variables, logical expressions, loops, and more. It allows users to apply programming principles without having to worry about syntax or the intimidation of a blinking cursor on the command line.

Basic usage of blocks can be learn throught the exercices proposed on Blockly

How to start

The toolbox

On the left of the visual editor, you will find the toolbox. Clicking on a section will open a menu where you can select the next block you are interested in.

toolbox menu

The first part of the toolbox contains standard scripting blocks with logical operations, loops, basic math and text. The middle part allows you to create variables, functions or lists which are a specific type of variable allowing to contain multiple values. The bottom part of the toolbox contains BrainVoyager specific functions.

Hovering with your mouse pointer over a block will show you some tips about the use of the function and the expected parameters.

block tips

For some blocks, you will find that these parameters are already filled by "shadow" blocks. They are there to help you to find the right value to feed to the block. When possible, they contain the default BrainVoyager values. You may change the values of these "shadow" blocks as you like. You may also replace them by new block by dropping the block in the parameter position. "Quotes" in the block indicate that this is a text block and that text input is needed, for example a file name. If the default parameters suit your need, you do not need to touch anything.

Blocks can be connected on the left, right, top and bottom.

left - right connections top - bottom connections

Left connections indicate that the block as an output. This could be a number, a text or a variable. Right connections indicate that the block needs parameters, like a file name. Leaving a parameter connection empty may work perfectly fine with some blocks but not with others, be careful. The visual editor will not issue any warning but your script will not run properly in BrainVoyager. The visual editor is still not fully "safe". Top and bottom connections are used by block without a direct output, for example when you execute a function on images or print to the log, there is no output for the program itself, only for the image or log.

Connections can also be internal.

internal connections

Internal connections are parameters for the block like the right connections. The fact that the connections are internal or right is purely based on the "design experience" of the developper. All FMR, VTC, VMR, MESH blocks will need as first paramenter a brainvoyager document of the corresponding type opened with either the "open" block or the appropriate "create" block.

Visual editor

The middle window is the visual editor. You can drag and drop blocks there and arrange them to write your script. The program will read the blocks from left to right and top to bottom.

blockly visual editor

Right clicking on a block will open a block menu.

figure of block submenu

The menu allows you to duplicate the block (and, eventually, the attached blocks), add a comment related to this block, for example "check second parameter", Collapse a block or group of blocks to reduce their size in the visual editor, delete the block or get help related to this block. The Help button is not implemented yet, and will only sent you to a general BrainVoyager webpage. For help, move your mouse cursor over the block and wait.

A collapsed group of block

Javascript/Python code window

The right window contains the automatic translation of the blocks into JavaScript or Python code.

javascript script editor

This code can be executed directly by BrainVoyager. You may either use the button or select and copy the code from the Javascript/Python window and copy it into BrainVoyager script/Python editor. For Javascript code, the script editor can be opened via the “Scripting...” menu option in BrainVoyager, "Edit and Run Scripts...". The Python editor can be accessed throuhg the "Python" menu option.

how to open BrainVoyager script editor

For more information on BrainVoyager script editor, see the BrainVoyager Scripting Reference manual, chapter 2.

Save and load script

When you are done with your script press the button on the top left of the page. You will be asked to save two files. Depending of your browser, the file interface and the order of the files may change but this has no influence on the resulting files. Some browsers may even ask you to allow to save multiple files, just press allow. Do not forget to change the default file name to reflect the script function.

Allow to save multiple files

The file ".xml" is an XML file which contains the block structure and can be used later to load the script back in the visual editor using the button next to "Load script". This button has different shape depending of your browser. The ".js" file is a JavaScript file which contains a BrainVoyager compatible version of your script. You may save this file in the in the default directory for scripts and script projects, which is /(My) Documents/BVExtensions/Scripts/. If you save your script there and there is no scripting error, you will see your script appearing in the "Scripting" menu the next time you open BrainVoyager. The ".py" file is a Python file and can be saved in /(My) Documents/BVExtensions/PythonScripts. The script will then appear in the Python editor the next time you start BrainVoyager.

You are here: HomeBrainVoyagerAvailable ToolsAvailable Plugins ≫ Visual Scripting Editor II