5a. Scripting FAQ and hints

Questions

 

1. My function does not appear in the list of functions. What could be wrong?

2. My function does not do what I want it to do.

3. The link from PRT to VTC does not seem to be saved (updated September 26, 2006)

4. How can I do non-tal VTC creation?

5. The script editor window with list of functions on the right is removed. How do I get it back?

6. Why does the QSA mathematical function anyMathematicalFunction() not work?

7. Is it possible to script BrainVoyager QX from Matlab?

8. The error window reports a 'parse error'. What is the problem?

9. How can I obtain a list of a certain file type in a directory?

10. Error 'Left-hand side is not writeable'

 

Answers

 

1. My function does not appear in the list of functions. What could be wrong?

Maybe is a parenthesis missing somewhere...? Try the parentheses matching function, by placing the cursor on the outer side of a "{". The function part that is covered by the method, gets a greenish color. In case a function "{" is missing, this becomes immediately clear because the function won't be totally green. For inner loops this works kind of the same.

 

This feature and other nifty features of the BrainVoyager QX scripting editor are described in chapter 2a.

 

2. My function does not do what I want it to do.

Is taken into account that BrainVoyager QX preprocessing functions return booleans?

In case of a script launched on the Mac where a FileDialog is launched, the FileDialog window might appear behind the Script Editor, so that it seems that nothing happens in the script, while in fact it is just waiting for input.

See also the hints (below) and following the debugging flowchart to exclude possible causes and thus isolate the problem.

 

3. The link from PRT to VTC does not seem to be saved

For previous BrainVoyager versions: on the forum of our website http://www.BrainVoyager.com/ a generous BrainVoyager user offers a Matlab script to save protocol names in *.vtc files and another user a Visual Basic script tool.

However, it is easily possible to save the name of a protocol file via plugins, by setting the header property of the VTC_Header structure. There is a plugin 'linkPRTtoVTC.dll/dylib/so' available on the new wiki http://wiki.brainvoyager.com/BVQX_scripts including preparation script and source code that makes it possible to link many protocol to many VTC files automatically.

 

4. How can I do non-tal VTC creation?

In BrainVoyager QX 1.3, the methods CreateVTCInVMRSpace()and CreateVTCInACPCSpace()can be used to create VTC files in non-Talairach space. See also topic 'Create VTCs' in chapter 1.

 

5. The script editor window with list of functions on the right is removed. How do I get it back?

Two dedicated BrainVoyager users offered a solution to this problem.

 

BrainVoyager user Jonas proposes the following for Mac OS X:

 

- Close BrainVoyager

- Locate the "/Library/Preferences/com.BrainVoyager QX.plist" file, which contains BV's global preferences.

- Open this file with Property List Editor (included in Mac Os X Developer tools).

- Find the key called "1%2E0.QSAEditor.WindowLayout".

- It seems to be empty, but editing it it reads something like

Tools,

[Tools,0,0,-1,-1,1]

Output,

[Output,0,0,-1,100,1]

Defined Functions,

[Defined Functions,0,0,150,-1,1]

The last nuber in each block determines whether a window is shown or not, 0 meaning no and 1 yes.

- Save this file and start BrainVoyager

 

And BrainVoyager user Marc mentions:

 

You can also right-click on a blank portion of the toolbar in the editor and re-check "output".

 

Thanks!

 

6. Why does the QSA mathematical function anyMathematicalFunction() not work?

To enable the mathematical module in QSA, use

with (Math) {

Math.<functionname>()

}

 

When typing this in the script editor, the available mathematical functions and properties will appear when using the Math module.

 

 

7. Is it possible to script BrainVoyager QX from Matlab?

In BrainVoyager 2000, it was possible to start and control BrainVoyager from Matlab via an implementation of the Component Object Model (COM). This will also be possible in one of the next releases of BrainVoyager QX. For static reading and writing of BrainVoyager files, the Matlab toolbox for BrainVoyager can be used, which is available on the wiki.

 

8. The error window reports a 'parse error'. What is the problem?

This is mostly a syntax error in the script, nothing to worry about. Maybe a semicolon (;) at the end of a scripting instruction has been forgotten, or a sign defining the scope of a block of instructions'( { } )' is missing or double, or a method or object name is typed wrongly.

 

Solution: go to the line number indicated in the error window, and search for the typo in a bottom-up manner.

 

9. How can I obtain a list of a certain file type in a directory?

A list of files can be created by first creating a directory object, then using the entryList() function while using a filter with the file type (for example "*.prt"). When no filter is used, all files in the directory are in the list. For an example, see the File list sample script.

 

10. Error 'Left-hand side is not writeable'

 

When trying to modify a property of an object, for example the interslice time of an FMR document, which can be performed via

 

var docFMR = BrainVoyagerQX.OpenDocument("firstrun.fmr");

docFMR.InterSliceTime = 63;

docFMR.TimeResolutionVerified = true;

docFMR.Save();

 

and the messatge 'Left-hand side is not writeable appears, this means that the document is not valid. Something went wrong with opening the file, so the

docFMR does not exist.

 

 

Hints