Automatic command-line execution

Top  Previous  Next

MonkeyCantab v2.4 and above supports command-line execution.

 

To execute commands from the command-line, you will need to run a Command Prompt. Windows has one under Start / Programs / Accessories / Command Prompt. Alternatively, you can click Start / Run and type cmd into the "Run" box. You will see a prompt such as

 

Microsoft Windows 2000 [Version 5.00.2195]

(C) Copyright 1985-2000 Microsoft Corp.

 

C:\Documents and Settings\Rudolf>

 

I'll show things from the computer in blue, and things that you type in red. Suppose you have installed MonkeyCantab into C:\Program Files\MonkeyCantab, as is common. You could then type

 

"c:\program files\monkeycantab\monkeycantab" -?

 

for syntax help. (The quotes are necessary because "program files" has a space in it.) This would produce something like the following:

 

MonkeyCantab v2.4 - DEBUG build compiled on Feb 16 2006 at 12:57:24

Usage:

 monkeycantab [-?] [-help] [-autoexecute] [-server SERVER] [-port PORT] [-box BOX] [-debugdisplay] [-config CONFIG] [-enableshape]

 

Options:

                 When run with no options, starts MonkeyCantab in GUI mode

 -?              Prints this syntax message

 -help           Prints this syntax message

 -autoexecute    Starts MonkeyCantab in auto-execution mode.

                 This requires you to specify a configuration file.

 -server SERVER  Specifies a Whisker server to use (default "localhost").

 -port PORT      Specifies an IP port to use (default 3233).

 -box BOX        Specifies a box (operant chamber) to use (default 0).

 -debugdisplay   Creates a debugging display (default is not to do this).

 -config CONFIG  Specifies a configuration file to load.

 -enableshape    Enables the shaping digital input.

 

Example:

 monkeycantab -autoexecute -box 1 -config "d:\my configs\subject1_DMTS.xml"

 

So, if you wanted to run a MonkeyCantab session from a pre-saved configuration file, (1) ensure that WhiskerServer is running, and (2) type a command such as

 

"c:\program files\monkeycantab\monkeycantab" -autoexecute -box 1 -config "d:\my configs\subject1_DMTS.xml"

 

Note the use of quotes to surround all filenames with spaces in them. This will run MonkeyCantab, connect to the default Whisker server ("loopback", or the same computer that MonkeyCantab is running on) with the default IP port (3233), and then try to claim box 1 and run a session based on the configuration file named "d:\my configs\subject1_DMTS.xml".

 

Log files for the session will be stored in the current working directory.

 

To run multiple consecutive sessions for the same subject, using different configuration files (e.g. for different reward parameters), you could create a batch file. Suppose you use your favourite text editor to create a batch file called Subject7SWM_IDEDRun.BAT that contains the following text:

 

@echo off

REM the "echo off" command is optional, but has the effect of preventing remarks and commands from being shown on the screen

REM The initial "@" suppresses output from the first "echo off" command

REM "echo" allows you to print things to the screen

REM As you may have noticed, all lines starting with "REM(ark)" are ignored!

 

echo About to run subject 7 in box 0, first session (spatial working memory task)...

REM we want the output files to go somewhere sensible, so we change directory to that place first

cd "d:\my output files"

REM OK, now we run MonkeyCantab

"c:\program files\monkeycantab\monkeycantab" -autoexecute -box 0 -config "d:\my configs\subject7_SWM.xml"

 

echo About to run subject 7 in box 0, second session (ID/ED task)...

"c:\program files\monkeycantab\monkeycantab" -autoexecute -box 0 -config "d:\my configs\subject7_IDED.xml"

 

echo Finished.

 

As long as WhiskerServer is running, you could then type

 

Subject7SWM_IDEDRun

 

from your command prompt and the batch file would execute, running two MonkeyCantab sessions in sequence. The command-line window would show:

 

About to run subject 7 in box 0, first session (spatial working memory task)...

(pause while MonkeyCantab runs in a separate window)

About to run subject 7 in box 0, second session (ID/ED task)...

(pause while MonkeyCantab runs in a separate window, again)

Finished.

 

If need be, you can press CTRL-C or CTRL-BREAK to interrupt batch files.

 

Technical note: To allow this to work on as many operating systems as possible, this facility is implemented with a small program called MonkeyCantab.COM, which provides syntax help, checks syntax, and passes on the message to MonkeyCantab.EXE, which it expects to be in the same directory as itself. The .EXE file is the main graphical user interface (GUI) program and behavioural task suite. This is necessary because the GUI program may not have a command line to provide syntax help to. When you type monkeycantab at the command line, Windows prefers to execute the .COM version, rather than the .EXE.