Help on External Apps:

Examples of External Apps:
o Curvature, Curve Radius, Angular Velocity, ...
o Pullman Spiral Test

Dos Batch Script as External Apps for MovAlyzeR

Dos Batch unleashes the power of your PC telling the PC what to do over and over without having to click anywhere. A batch file can be a text file with a name ending with .BAT instead of .txt; it may also contain a series of commands to be executed at the command prompt in its simplest way.
Search the web for Dos Batch Script language. Here follow a few useful tips.

External Apps: MovAlyzeR can start an External App (Matlab Script or Dos Batch Script) at specific points before recording (in the Condition Properties) or processing of a recording (in Experiment Properties). A Dos Batch script can call any other scripts or executable. MovAlyzeR will wait till the script has finished and its window is closed.

How to Access:
External App in the Condition Properties: Right click your condition > Properties > Events and Sounds > External Processing.
External App in the Experiment Properties: Right click your experiment > Properties > Processing > External Apps.

Where they are: The scripts reside in the Folder Scripts\ in your Data Path (See File >Users >Properties). You can also define scripts in the folder EEE\Attachments. EEE=your experiment. This folder is viewable by right clicking Attachments under the experiment.

Add Variables: You can define new variables by the percent followed by a numeric value, beginning with one. For example: set variable1=%1.
You can refer to these variables by, for example: %variable1% or, if it has only one character: %v.
For help, type: Help set

Show Variable: You can show the value of a variable by, for example: echo The value of Variable 1 is %variable1%
There are some system-wide variables that you can show:
echo %date%
echo %time%
echo %random%
echo %cd%
echo %errorlevel%
For help, type: Help echo

Arguments: To run batch job b.bat with arguments arg1 and arg2 you type: b.bat arg1 arg2 and hit enter. By default %0 refers to the name of the batch script (e.g., b.bat). %1 to Argument 1, %2 to Argument 2, etc. When called in MovAlyzeR the following arguments are given:
set BatchJobName=%0
set DataPath=%1
set Experiment=%2
set Group=%3
set Subject=%4
set Condition=%5
set Trial=%6
set SamplingRate=%7
set Resolution=%8

Let the script wait for you: To let a script wait till you have read the screen, include: pause.
It is useful if an error occurred: if %errorlevel% neq 0 pause. Batch file also waits for the specified time period (in seconds) or until any key is pressed. For example, wait for 3 seconds, TIMEOUT /T 3
For Help, type: Help pause.

Start the programs or files from a batch file: You can run a program or open a file by using the START command. For example: START /MAX test. You can also specify the location of the file by: START /MAX C:\Windows\test.txt
Creating and deleting files (watch out, del will delete irreversibly):
Del test.txt
Create a file with a command echo. 2>test.txt

Compare Variables: You can compare variables by, for example:
if %variable1%==25 echo It is 25
if not %variable1%==25 echo It is not
if %variable1%==25 echo It is 25
else echo it is not 25
if "%date%"=="Thu 01/17/2013" echo Today is a special day

Test run: You can test run a batch job by opening the Dos Prompt command line window (Start >Run >Type: cmd). Then use cd (Change Directory) to navigate folders. Hit Tab (or Shift Tab) multiple times to autocomplete the options). Enclose names that contain spaces by " ".

To customize the Dos Prompt: Click on its icon in the banner >Properties. There you can set size, font, color, ... When closing, select: Modify shortcut that started this window.

How to synchronize between image acquisition and MovAlyzeR data acquisition in an fMRI study
Create an event-related design in which two stimulus conditions are presented in random order, along with an equal number of random intervals of rest. Stimulus condition is performed in MovAlyzeR environment.
Stimulus conditions:
A = one movement condition
B = another movement condition
C(i)= rest
Where A, B begin with the presentation of the ‘start target’ and ‘finish target’, end with that subject complete the movement from ‘start target’ to ‘finish target’. The time interval of each condition depends on how fast subjects plan and complete their movement.
A            B                      B        A          B        A     
       C1              C2              C3         C1       C3
C1=2s; C2=4s; C3=1s;
Time intervals of A, B are recorded

Synchronizing between image acquisition and behavioral data acquisition:
Step 1: Ask MovAlyzeR external app in condition properties waiting a trigger from fMRI scanner to get start with the experiment.

Step 2: After MovAlyzeR finishes recording one condition, external App in experiment creates a plain text to inform this stimulus condition is completed, and software application records this time point, at the same time deletes the plain text; after rest time, the next trial begins.
A batch file can accomplish above steps easily, such as using If command to check whether a trigger arrives:

IF EXIST trigger. (
del trigger.
) ELSE (
echo trigger. missing.

By creating a text file to inform the other software application that the current stimulus condition is completed
echo. 2>trial_end.txt