Scripts for BrainVoyager (JavaScript)
- Details
- Category: Available Scripts
- Last Updated: 15 February 2024
- Published: 13 April 2018
- Hits: 5290
16-11-22: Please note that the JavaScript function LoadVOIFile() does not seem to work in BrainVoyager 22.2 and 22.4; this has been reported. The Python function load_vois() could be used temporarily instead.
Introduction
The following JavaScript-scripts (*.js) can be used from BrainVoyager QX 2.1 or 2.2; the example (non-GUI) scripts are now updated to BrainVoyager 20+, including the use of the new Getting Started Guide data (Sept 2019). They are an addition to the scripts that are available in the folder /(My) Documents/BVExtensions/Scripts/ after installation of BrainVoyager. The scripting guide (*.pdf) for BrainVoyager can be downloaded from the Scripting Reference page. Also online, there is a JavaScript language reference from w3schools (external link).
Contents of this page
BrainVoyager 23, added 13-02-24 (zipped): createMultipleFuncNIfTIBIDS.js, gui_tutorial_6.qml, CreateVMRAndIIHCAndAutoTALAndMNI_BV23.js, CreateVTCfiles_BV23.js, ExperimentalDesign_BV23.js, LinkPRTSaveVTC_BV23.js, CreateMDM_MultiGLMs_BV23.js
Example processing scripts for BrainVoyager 20+ (19-09-19) including CreateDocuments_BV21_NewGSGdata.js, CreateVMRAndAutoTAL_BV21.js, etc.
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()
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.
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:
matrix_functions.js: A simple script for calculating with 4x4 matrices. Just change the matrix in the script and then run in BrainVoyager to calculate the result. Available functions in the script: getIdentityMatrix(), getEmptyMatrix(), multiply4x4Matrices(mat1, mat2), getdeterminant(a), getinverse(mat), printMatrixToLog(matrix, name). This script can for example be used to check whether the orientation of an image was reversed during import from NIfTI (see example use of getdeterminant() in script).
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.