Adding response registration
To record a key press, we first define what keys we want to use. Let’s use the ‘X’-key and the ‘M’ which sit at a convenient location on the keyboard to work with the index finger of each hand:
KEY ResKeys
X M ; Define a Key Set consisting of’ ‘X and ‘M’
This defines a key definition consisting of the X and M key. All other keys will be not active.
Having defined the keys, we must extend the trial definition to activate the response registration. This is done with the RK trial command (Register Keys). This command must be inserted before the event you want the time recording to start:
TRIAL ShowWord
CS 2000 ; Clear Screen and wait for 2000 ms
RK ResKeys ; Activate Response Registration for next command
SP ? Center 1 500 ; Show a variable Picture for 500 ms
This new trial definition will turn on response registration together with the Show Picture (SP) command which is displaying the word ‘left’ or ‘right’
To give the subject some time to submit the response, we change the trial definition again and add a maximum reaction time to the RK command, at the same time changing the SP command to wait until a response has been submitted. This is done by setting the presentation time to 0 and adding a cancel flag (1) to link the presentation time to the submission of a response:
TRIAL ShowWord
CS 2000 ; Clear Screen and wait for 2000 ms
RK ResKeys 3000 ; Activate Response Registration with MaxRt = 3000
SP ? Center 1 0 1 ; Show a variable Picture until response is done or end of MaxRt
The word presentation will be aborted when the subject presses a response key or the time interval defined by MaxRt has been passed.
Update your script and run the script. You will see that the stimulus now disappears the moment you press ‘X’ or ‘M’
PICTURE Left N
PICTURE Right N
POSITION Center P
0,0
KEY ResKeys
X M ; Define a Key Set consisting of’ ‘X and ‘M’
TRIAL ShowWord
CS 2000 ; Clear Screen and wait for 1000 ms
RK ResKeys 3000 ; Activate Response Registration with MaxRt = 3000
SP ? Center 1 0 1 ; Show a variable Picture until response is done or end of MaxRt
BLOCK ChoiceRT 2
1 ShowWord Left ; Run Trial ‘ShowWord’ and set ‘Left’ as the Picture name
1 ShowWord Right ; Run Trial ‘ShowWord’ and set ‘Right’ as the Picture name
SesSION My First Experiment
RUNBLOCK ChoiceRT 10 ; Execute block ‘ChoiceRT’ with 10 trials in random order
Copyright 2021 - BeriSoft Inc.
All rights reserved