Example scripts for BrainVoyager QX 2.1 and higher
Contents of this page (latest update: 22-11-11)
Example processing scripts for BrainVoyager
Example non-GUI scripts:
Example GUI scripts:
Print to Log when clicking button
Demonstration of use of most important graphical components (widgets)
Conditional enabling of widgets
Returning and passing parameters to functions
Using tabs and shortcut names for widgets using findChild()
Introduction
In BrainVoyager QX 2.1, the JavaScript language is used. This is almost similar to the scripting language that was used before, until BrainVoyager QX 2.0, called Qt Script for Applications (QSA). The scripts now have a *.js extension instead of *.qs for a script of *.qsa for a script project. The scripting guide (*.pdf) for BrainVoyager QX 2.1 can be downloaded from the Automation and Development page. Information can also be found on the GUI Scripts page in the BrainVoyager User's Guide. Also online, there is a JavaScript language reference from w3schools (external link).
Example processing scripts for BrainVoyager QX
Example creation of BrainVoyager projects (FMR/DMR/VMR), preprocessing and creation of VTC/VDW files scripts: ExampleScriptsBVQX21_030210.zip
Please note that the FMR preprocessing script has been updated (03-02-'10), which contained an obsolete function; also the cubic spline interpolation parameter for slice scan time correction has been added in the comments. And here is a proper createprotocol script.
Example non-GUI scripts
getPath.js: Script to extract the path from a filename using JavaScript string functions "lastIndexOf()" and "substring()".
classes.js: Sometimes it can be useful to create custom-made objects, for example when creating an FMR project many times. The parameters for the project creation can then be concisely stored in one object, so that one doesn't need to pass a lot of parameters to a function, but only one instance of a class.
preprocess_fmrs.js: Simple script to show how to use a loop and an array in preprocessing multiple runs, using slice scan time correction as example.
read_projectinfo.js: A script to read a text file with filenames/directorynames and some number (of runs, for example) into a two-dimensional array so that the filenames do not need to be added to a (preprocessing) script, but are external to the script. The expected text file structure is:
RadioButton: toggled
CheckBox: stateChanged
TextEdit: textChanged (emit signal after each character)
CheckBox: checked
DoubleSpinBox: value
TimeEdit: time
Contents: This script bundle consists of printDlg.js (the script to load in BrainVoyager) and printDlg.ui (the user interface of the script), place both in /Documents/BVQXExtensions/Scripts/ folder.

extPrintDlg.js/ui
Contents: This script bundle consists of extPrintDlg.js (the script to load in BrainVoyager) and extPrintDlg.ui (the user interface of the script), place both in the /Documents/BVQXExtensions/Scripts/ folder.

conditionalEnabling.js/ui
Contents: This script bundle consists of conditionalEnabling.js (the script to load in BrainVoyager) and conditionalEnabling.ui (the user interface of the script), place both in the /Documents/BVQXExtensions/Scripts/ folder.

Returning and passing parameters: non-GUI version (*.js) GUI version (*.js/*.ui)
Purpose: show how to pass and return parameters between functions when creating BrainVoyager QX 2.1 scripts without and with a graphical user interface (GUI).

tabbedDlg.js/ui
Purpose: Addressing widgets using the findChild() function. In case many graphical components are used, like checkboxes on tabbed widgets, their names can become complicated and it can be hard to find how to address them. To solve this, the findChild() function has been provided. The current example listens to signals emitted from a radiobutton and checkbox located on a tabbed widget; the signals are connected to functions, which print something to the BrainVoyager QX Log tab.
| < Prev | Next > |
|---|


