Devices
Scripts define which devices will be used in the experiment. Each device that will be used has to be registered with the Task. Registration requires three parameters:

The name must be unique (no two devices can share the same name) and should be descriptive. The device class name is the piece of information that Java uses to build the class for a device at each client location. Example:

displayHandle = task.addDevice("Display", "nemo.pdi.GraphicalDisplay", fromDisplay)

The Task returns a handle to the device that can be used to send commands to the device. In the example above displayHandle is the device handle. The device handle has access to the commands listed in the Script Interface section for each device below.

Descriptions of the NEMO devices follow:



GraphicalDisplay
Fully qualified class name: nemo.pdi.GraphicalDisplay

This device handles output to a video component, typically a screen (monitor or projector). The display is composed of a background color and any number of Graphics drawn over the background. A Graphic is a basic building block for drawing on the display (see the list of available Graphics below). Each Graphic is drawn in the order in which it was added to the display.

Creating Graphics
NEMO provides a means of creating Graphics through the GraphicFactory. This class takes as an argument the id for a Graphic type and returns the Graphic object. Here is an example using the GraphicFactory:

aRectangle = GraphicFactory.createGraphic(GraphicFactory.FILL_RECTANGLE)

The type ID that is passed in tells the factory which type of Graphic to create. The available type IDs are:

A special type of Graphic called a GraphicGroup cannot not be created using the GraphicFactory. A GraphicGroup is a composition of other Graphics. It is created with a statement like this:

aGraphicGroup = GraphicGroup()

See more information about GraphicGroups below.

Once the Graphic object has been created, certain values must be set before it can be diplayed. Each Graphic requires a name and description as well as various values for location, size, and color. The specific requirements for each type of Graphic are listed here: A note about positioning and sizing: The origin of the display (x="0", y="0") is located at top left corner of the display, with x values increasing to the right and y values increasing down. Position values are (by default) expressed as a percentage of the display's area (a position of x="50", y="50" will put the top left corner of the Graphic in the center of the display). Alternatively, you can express the value in absolute coordinates by appending an "a" to the end of the value (for example, x="50a", y="50" will place the top left corner 50 pixels from the left edge of the display and half way down from the top of the display). Percentage coordinates are recommended, because the size of the display is not known and may differ across clients. Using absolute coordinates may lead to Graphics that hang off the egde of the display.

Sizing works the same way as positioning. Widths and heights are expressed as percentages of the display area unless an "a" is appended to the value.

Script Interface
The script can send commands to the display of each client using the following functions:

The GraphicalDisplay responds to commands from the script by sending a DisplayEvent to the script. Each DisplayEvent contains information about the type of event that happened, the time it occurred, and any Graphics that were in the drawing list at the time. This event is sent to the handler method that was used in the device registration. A DisplayEvent has the following functions available:



ButtonBox
Fully qualified class name: nemo.pdi.ButtonBox

This device handles input from a device used by subjects to make decisions. An example of a common ButtonBox is a standard keyboard. As a user presses keys, NEMO sends data to the script for processing, and depending on the content of the input, the script can take alternate paths.

Some primitive ButtonBoxes may have limited input options (such as only providing 4 buttons with the values "1", "2", "3", and "4"). If your script expects input to be in the set ["A", "B", "C", "D"], then the primitive ButtonBox will never work with the script. To get around this type of problem, NEMO provides a method to map input values to new values. For example:

1 # Register the device with NEMO.
2 aButtonBox = task.addDevice("MyButtonBox", "nemo.pdi.ButtonBox", fromButtonBox)
3  
4 # The following lines of code tell NEMO to ask each client to provide a mapping to the given values.
5 task.addDeviceProperty("MyButtonBox", ButtonBox.PROP_OUT_VAL_BASE + String.valueOf("0"), "A")
6 task.addDeviceProperty("MyButtonBox", ButtonBox.PROP_OUT_VAL_BASE + String.valueOf("1"), "B")
7 task.addDeviceProperty("MyButtonBox", ButtonBox.PROP_OUT_VAL_BASE + String.valueOf("2"), "C")

In the above example, a ButtonBox is registered with the name "MyButtonBox" (line 1). The following lines (5-7) tell NEMO that input values should be mapped to "A", "B", and "C". This means that the client will need to pick valid values from their ButtonBox and map them to the requested values. If the box has values "1", "2", and "3" then the client could just map "1" to "A", "2" to "B", and "3" to "C". Now whenever the ButtonBox recieves a "1" from the subject, it will be mapped to an "A" and sent to the script. This mapping scheme allows the script to act as if all ButtonBoxes can provide the same input.

Script Interface
Scripts do not send commands to ButtonBoxes, since they exists only to take input from subjects.

However, when a subject sends input through the ButtonBox, data is sent to the script for processing. The data arrives as a standard Event. Each Event stores information about the type of the event, the time it occurred, and the button pressed. This event is sent to the handler method that was used in the device registration. A standard Event has the following functions available:



Scanner
Fully qualified class name: nemo.pdi.Scanner

The Scanner device controls communication between the NEMO client and an MRI scanner. This device is used to start and stop the scanner and to retrieve images from the scanner. This device will require special setup on the scanner to work properly.

Script Interface
The script can send commands to the Scanner of each client using the following functions:

When the Scanner responds to a command from the script, it sends an Event. Each Event stores information about the type of the event and the time it occurred. This Event is sent to the handler method that was used in the device registration. A standard Event has the following functions available:



SyringePump
Fully qualified class name: nemo.pdi.SyringePump

The SyringePump device squirts liquid. It can be used to squirt soda in subject's mouths, as in the study linked here, or it can be used to squirt water and juice as in the study linked here. The SyringePump allows you to control which syringe (the pump may have more than one), the rate of the squirt, and the duration of the squirt.

Script Interface
The script can send commands to the SyringePump of each client using the following functions:

When the SyringePump recieves a command from the script, it responds with an Event. Each Event stores information about the type of the event, the time it occurred, and the syringe that was pumped. This Event is sent to the handler method that was used in the device registration. A standard Event has the following functions available:



Movie
Fully qualified class name: nemo.pdi.Movie

The Movie device plays a movie clip in the center of the display. This device requires the installation of the Java Media Framework (which may be packaged with NEMO, but is also available here from Sun).

Script Interface
The script can send commands to the Movie device of each client using the following functions:

When the Movie acts on a command from the script or as a result of a movie clip event, it sends an Event to the script. Each Event stores information about the type of the event, the time it occurred, and a string describing the event and the name of the clip. This Event is sent to the handler method that was used in the device registration. A standard Event has the following functions available:



All documentation ©2005 Human Neuroimaging Laboratory