Scripting Reference Manual For
Total Page:16
File Type:pdf, Size:1020Kb
Scripting Reference Manual for BrainVoyager QX 2.1 - 2.4 Hester Breman and Rainer Goebel copyright 2012 c Brain Innovation B.V. Contents 1 Introduction 4 1.1 Location of script files.......................................4 1.2 Switching from scripting in BrainVoyager QX 2.0 to 2.1 or higher..............4 1.3 History................................................5 1.3.1 Scripting in BrainVoyager.................................5 1.3.2 Documentation history..................................6 2 The BrainVoyager Script Editor7 2.1 General properties of the BrainVoyager Script Editor......................7 2.1.1 The user interface......................................7 2.2 Creating scripts...........................................7 2.3 Running scripts...........................................8 2.4 Using the interpreter........................................9 2.5 Debugging.............................................. 11 3 BrainVoyager Scripting Commands (API) 12 3.1 Introduction............................................. 12 3.1.1 Invoking BrainVoyager scripting functions from other programs.......... 12 3.1.2 Example script....................................... 13 3.2 List of all methods......................................... 14 3.3 BrainVoyager QX-specific classes................................. 16 3.4 Functions of the BrainVoyagerQX object............................. 16 3.4.1 List of methods....................................... 16 3.4.2 Detailed description of methods............................. 17 3.5 Create projects............................................ 18 3.5.1 List of Methods....................................... 18 3.5.2 Create FMR project..................................... 18 3.5.3 Create DMR projects.................................... 20 3.5.4 Create VMR projects.................................... 21 3.5.5 Create AMR projects.................................... 22 3.5.6 For all projects....................................... 23 3.5.7 Example scripts....................................... 24 3.6 BVQX Project functions: Preprocessing of functional data (FMR)............... 25 3.6.1 List of methods....................................... 25 3.6.2 Detailed description of methods............................. 26 3.6.3 Example script....................................... 29 3.7 BVQX Project functions: Preprocessing of functional data (VTC)............... 31 3.7.1 List of methods....................................... 31 3.7.2 Detailed description of methods............................. 32 3.7.3 Example script....................................... 33 3.8 BVQX Project functions: Transformations and Normalization................. 34 3.8.1 List of methods....................................... 34 3.8.2 Detailed description of methods............................. 35 3.8.3 Example script to create VTC files............................ 39 3.8.4 Creating diffusion weighted (VDW) files........................ 40 3.8.5 Example script to create VDW files............................ 41 3.9 BVQX Project functions: Experimental design.......................... 42 1 3.9.1 List of Methods for stimulation protocols........................ 42 3.9.2 List of Properties for stimulation protocols....................... 42 3.9.3 Detailed description of methods............................. 43 3.9.4 Example script....................................... 45 3.9.5 List of Methods for design matrices........................... 45 3.9.6 List of Properties for design matrices.......................... 45 3.9.7 Detailed description of methods............................. 47 3.9.8 Example scripts....................................... 49 3.10 BVQX Project functions: Statistics................................. 50 3.10.1 List of Methods....................................... 50 3.10.2 List of Properties...................................... 50 3.10.3 Detailed description of methods............................. 51 3.10.4 Example script....................................... 53 3.11 BVQX Project functions: Surface functions............................ 54 3.11.1 List of Methods....................................... 54 3.11.2 List of Properties...................................... 54 3.11.3 Detailed description of methods............................. 55 3.11.4 Example script: visualization............................... 56 3.11.5 Example script: create MTC................................ 58 4 File input and output (I/O) 59 4.1 Introduction............................................. 59 4.2 Class QDir.............................................. 59 4.3 Class QFile.............................................. 59 4.3.1 List of (some) methods................................... 59 4.3.2 Detailed description of methods............................. 59 4.4 Class QIODevice.......................................... 60 4.4.1 List of methods....................................... 60 4.5 Class QTextStream......................................... 60 4.5.1 List of (some) methods................................... 60 4.5.2 Detailed description of methods............................. 60 4.6 Example script: write a file I.................................... 61 4.7 Example script: write a file II................................... 62 4.8 Example script: read a file..................................... 63 4.9 Example: delete a file........................................ 64 5 Creating scripts with dialogs 65 5.1 Introduction............................................. 65 5.2 Writing GUI scripts......................................... 65 5.2.1 Capturing emitted signals................................. 65 5.2.2 Collecting information in the dialog........................... 65 5.2.3 An example script with different widgets........................ 67 5.2.4 The JavaScript........................................ 68 5.2.5 The user interface...................................... 69 5.3 Procedure to create a GUI script.................................. 72 5.3.1 The user interface (*.ui).................................. 74 5.3.2 Running a script with user interface........................... 75 5.3.3 Catching errors....................................... 76 6 JavaScript language reference 77 6.1 Introduction............................................. 77 6.2 Keywords.............................................. 77 6.2.1 Operators.......................................... 77 6.2.2 Data types.......................................... 79 6.2.3 Creating objects....................................... 86 6.2.4 Declarations......................................... 88 6.2.5 Control statements..................................... 88 6.2.6 Error handling....................................... 88 6.2.7 Comments.......................................... 88 2 6.2.8 Date and time........................................ 89 6.3 Using Qt Objects.......................................... 90 A Switching from BrainVoyager QX 2.0 to 2.1 scripting 91 A.1 The Scripting Language...................................... 91 A.1.1 Classes vs. Objects and Properties............................ 91 A.1.2 Constructors......................................... 92 A.1.3 Member Functions and Prototypes............................ 93 A.1.4 Inheritance.......................................... 94 A.1.5 Static Members....................................... 94 A.2 The Built-in Functions and Library................................ 95 3 Chapter 1 Introduction Welcome to the BrainVoyager Scripting Reference Manual!1 This reference manual can be used for scripting in BrainVoyager QX 2.3 and 2.4, but most commands can also be used in BrainVoyager QX 2.2, and some in BrainVoyager QX 2.1. This manual contains the BrainVoyager functions (Application Programmer’s Interface (API), see Chapter3), some introduction to the JavaScript language (Chapter 6) and a short section on writing scripts in BrainVoyager with a user interface (see Chapter5). A very nice new feature is the Script Debugger, which will be discussed in section 2.5. When starting with scripting, in BrainVoyager or in general, please also check out our Getting Started with Scripting in BrainVoyager Guide. This can be found in the “GettingStartedGuides” folder of the BrainVoyager directory or online at the BrainVoyager support site. Latest update: 08-02-2012 1.1 Location of script files Scripts (*.js) for BrainVoyager QX 2.1 and higher can be stored in the folder (My) Documents/BVQXExtensions/Scripts/ An option to specify a custom scripts folder has been added in v2.4.1. Users can switch between stan- dard and custom folder in ”Settings” dialog. 1.2 Switching from scripting in BrainVoyager QX 2.0 to 2.1 or higher How to use Qt Script and what are the differences with respect to QSA? - To start, call the scripting dialog clicking on “Scripts” ! “Scripting...” menu. - Files are stored as “.js” (JavaScript) text files allowing to use also external editors (by simple double- clicking). - Instead of “Application.BrainVoyagerQX”, you only need “BrainVoyagerQX” global symbol to get access to the BVQX API, please have a look at the example scripts. - There (at present) no support for “projects”, i.e. only one file is evaluated (this might change). - The script editor has syntax highlighting. Furthermore the QScript debugger is integrated, which allows for easy hunting of bugs. - On Windows, COM support is available from version 2.2. - QScript is much faster than QSA, so some “plugin” processing will be possible without requiring C++ code. - Scripts with a graphical