Responses can be collected via:
Specifics of each are described below.
tell application "PsyScript"
set response type to keyboard response
end tell
By default, all keys are noticed, with a mapping set to the name of the key.
this is equivalent to saying:
tell application "PsyScript"
set response type to keyboard response
set noticed of every key to true
end tell
Default mappings can be viewed by saying:
return
mapping
of key
"M"
--> "M"
Thus keyboard responses are simple: presses of any key will register, and
PsyScript will record the CAPITAL letter pressed as the subject
response. So if the subject presses the "h" key, subject
response will hold "H" (regardless of whether the shift key
was being held down or not).
set noticed of every key to false
If you ignore all keys, then you selectively reenable the keys PsyScript should notice, and you should also specify what PsyScript should record in subject response when a designated key is pressed. These two functions are performed by the noticed and mapping properties of the keys you want.
For example, to associate the "m" key with a "right" response,
you would do the following:
set
noticed
of key
"M" to
true
set
mapping
of key
"M" to
"right"
or, more compactly
tell key "M" to set {noticed, mapping} to {true, "right"}
Now, when the subject presses the "m" key, PsyScript will set subject
response to "right".
set response type to bbox response
CMU has developed the CMU
BBOX for collecting responses in psychology experiments. This box contains
3 buttons, a microphone input for voice trigger responses, and connectors for
interfacing to external devices.
These are expensive and largely superceeded by USB ActiveWire. For further information, see the "Psyscope Button Box" document on the
Note: the button boxes have undergone a number of hardware and software revisions; PsyScript will no longer work with older mode (before Mark 5 or so) bboxes; and the 68K version of PsyScript no longer supports bboxes at all. To check your bbox version, you can run the CMU BBoxTester program supplied with the PsyScript distribution (or available from the CMU web page). If the dialogue box you see says "Response" at the bottom, you're fine; if it says "Millisecond", you have a old mode bbox which will not work with PsyScript. Any bbox purchased 1996 or later should be fine, and some earlier ones may work as well. Older documentation from CMU stated that an extension called "SerialDMA" had to exist in your system folder for the bbox code to work on PPC's and some other macs. It seems to be the case, however, that System 7.5.3 and later has this extension incorporated into it automatically, so don't worry about it if you have the newest System version. If you're using an older version of the system, load the SerialDMA extension, which you can get from Apple's web page.
Using the bbox for input is similar to using the keyboard. the buttons are labeled
1 to 3 (the red, yellow, and green buttons respectively with the external lines
being addressed as keys 4-8
To use the bbox, connect it to a modem port (use the keyspan emulator on new macs), then turn it on.
Inside your script, initialized the box, set the response mode + noticed and mapping of keys, then it is business as usual:
tell application
"PsyScript"
activate
begin experiment
initialize bbox
set
response type
to bbox
response
set
noticed
of every
bbox key
to false
tell
bbox key
1
set
{noticed,
mapping}
to {true,
"left"}
end
tell
do trial
" 'press the red key on your bbox' "
set
theRT to
reaction time
do trial
"'that rt was ?t"
given {t:theRT}
end experiment
end tell
If you want to wait for a bbox line to go true, see wait on input. To control the bbox lights, see output control
set response type to mouse response
Mouse responses are handled like keyboard responses, except that the "keys" are click regions which you define on screen and associate with a mapping. The mapping is stored in subject resposne, rt is still in reaction time, and the location which is clicked is stored in mouse location
You can also use mouse up, and can record mouse moved moments.
In this example, I draw two boxes on screen, and record in which the subject clicks
tell application
"PsyScript"
activate
begin experiment
set
response type
to mouse
response
set
noticed
of every
click area
to false
--there are 50 click areas
--first i define two rectangles
which we will draw on screen
set
rect1 to
{50, 50,
100, 100}
--top left bottom right
set
rect2 to
{120, 50,
170, 100}
--top left bottom right
--let's notice two areas
corresponding to these rectangles
tell
click area
1
set
{noticed,
mapping,
bounds}
to {true,
"red", rect1}
end
tell
tell
click area
2
set
{noticed,
mapping,
bounds}
to {true,
"green", rect2}
end
tell
draw
rectangle in
rect1 corner
rounding {5,
5} using
{pen color:red}
with filling
draw
rectangle in
rect2 corner
rounding {5,
5} using
{pen color:green}
with filling
do trial
" ''(0) 'click in the red box with your mouse'
"
end
experiment
end tell
Now two click regions (the 2 rectangles) will be noticed, all other clicks will be ignored, and the clicks are mapped to english labels
Here is a complete mouse example with drawing of boxes and feedback
tell application
"PsyScript"
activate
begin experiment
set
response type
to mouse
response
set
noticed
of every
click area
to false
--there are 50 click areas
--first i define two rectangles
which we will draw on screen
set
rect1 to
{50, 50,
100, 100}
--top left bottom right
set
rect2 to
{120, 50,
170, 100}
--top left bottom right
--let's notice two areas
corresponding to these rectangles
tell
click area
1
set
{noticed,
mapping,
bounds}
to {true,
"red", rect1}
end
tell
tell
click area
2
set
{noticed,
mapping,
bounds}
to {true,
"green", rect2}
end
tell
set
tryagain
to true
repeat
while tryagain
is true
--now i
draw the 2 rects on screen
draw
rectangle in
rect1 corner
rounding {5,
5} using
{pen color:red}
with filling
draw
rectangle in
rect2 corner
rounding {5,
5} using
{pen color:green}
with filling
do trial
" ''(0) 'click in the red box with your mouse'
"
set
theRT to
reaction time
set
clickLoc
to mouse
location--this
is a point: {x,y}
set
resp to
subject response
--this contains the mapping of the clicked
region ("green" or "red")
if
resp is
not "red"
then
set
feedback
to "'i
said the red box'"
else
set
feedback
to "'good
choice'"
set
tryagain
to false
end
if
do trial
"!e !t(0)"
draw
rectangle in
rect1 corner
rounding {5,
5} using
{pen color:red}
with filling
draw
rectangle in
rect2 corner
rounding {5,
5} using
{pen color:green}
with filling
draw
oval in
(clickLoc
& {(item
1 of
clickLoc)
+ 3, (item
2 of
clickLoc)
+ 3}) using
{pen color:blue}
with filling
do trial
"!w(?2) ?3 . Your rt was ?1"
given {theRT,
{(item
1 of
clickLoc)
+ 100, (item
2 of
clickLoc)
+ 30}, feedback}
end
repeat
end experiment
end tell
set response type to reply box
This type of response shows a dialog box on the screen, and subjects can type in any text as a response. The reply box looks like this:

The subject's response will be stored in reply, and subject response will be undefined (this is so that if you use "combination" replies, subject response can hold the subject's keypress). You can set *prompt_id* to any string; this string will be shown when the dialog box comes up.
Here is an example of the reply box in action.
tell application
"PsyScript"
activate
begin experiment
set
response type
to reply
response
do trial
"'Please type
the color of the object just shown.'"
set
theRt to
reaction time
set
theReply to
subject reply
end experiment
return
{theRt,
theReply}
-->{5393.0,
"red"}
end tell
Use a voice trigger by hooking a microphone to your mac (any kind of soudn input
will do)
Calibrate the microphone by using the "Experiments->sound settings" menu. You can set the amount of speechstored before trigger, the threshold for triggering.
When a voice trigger response is made, subject response gets set to whatever you set the mapping element of soudn settings. It is basically irelevant as only one mapping is possible.
tell application
"PsyScript"
reset all
set
theData
to {}
set
fileHelper
to load
script file
("" & Psyscript
base folder & "libraries:file.lib")
activate
begin experiment
set
word size
to 32
display dialog
"have you set the voice key threshold?"
buttons
{"Yes", "No"}
if
button returned
of result
is "Yes"
then
--
else
display
dialog "set
the voice key threshold using the Experiment menu: sound settings item, then
run this expt again"
end
experiment
return
end
if
set
response type
to sound
response
set
recording
of current
sound to
true
set
theWordList
to {"hello",
"this", "is",
"voice", "key",
"stuff"}
repeat
with theStim
in theWordList
do trial
"!e + #250 !e #250 !t ?theStim "
given {theStim:theStim}
end
repeat
end experiment
end tell
set response type to combo response
Here, the subject presses a key (this works just like a keyboard response), then PsyScript shows a dialog box to get a further response (just like a reply box response). subject response contains the typed response, reaction time contains the key press onset time.
response type can take a list of types. All the types discussed above can be added add every type (except for mouse moved) will be scanned while PsyScript waits for a response.
response count
TBA
| MACCS | |
Documentation | Downloads | FAQ | Mailing List | Last change: echo date( "F d Y.", getlastmod() ); ?> |
| Advanced Search |