Post by embhlab on Dec 17, 2020 14:38:32 GMT
Hello!
I am playing around with the coding for the original (2) n-back test and after including a fixation, the first two numbers show but afterwards it becomes just a black screen and no key would read. I want my task to look somewhat like the image attached. Another issue I'm running into is the output. I am trying to use 2 keys for responses: m for it is a 2-back match and n for when it is not a 2-back match. I've tried re-coding each section but no luck.
My code looks like:
#correct response
if $requiredresponse == 1 and STATUS != TIMEOUT
set $score 1 ## correctly pressed during number presentation.
set $match 1
show bitmap fix ## fixation cross
fi
#incorrect response
if $requiredresponse == 2 and STATUS != TIMEOUT
set $score 2 ## incorrect pressed key
set $nonmatch 1
show bitmap fix ## fixation cross
fi
#timed-out response
if $requiredresponse == 0 and STATUS == TIMEOUT
set $score 0 ## so far so good #changed from 1 to 2 and is timed out
#show bitmap fix ## fixation cross
fi
task twoback
keys m n
set &trialcount increase
set $currentnumber random 1 8 ## choose random number out of the 8 options
############################################################################
## is this condition a yes condition?
set $target random 1 &choosechance ## random number for choosing condition
set $nontarget random 2 &choosechance ## random number for choosing condition
## if a 2back trial
if $target == 1 and $nontarget != 2 and &trialcount > 2
set $currentletter &nback2
set $requiredresponse 1 ## the m key needs to be pressed later, m=stands for Memory
set $typeoftrial 1
fi
## if a NON n-back trial - added
if $target != 1 and $nontarget == 2 or &trialcount <= 2 ## chose a letter but not that of 3 trials ago
set $currentletter random 1 8
#while $currentletter == &nback2 ## choose anything but NOT that of 3 back
#set $currentletter random 1 8
# while-end
set $requiredresponse 2 ##
set $typeoftrial 2
fi
## if a timed out trial
if $target != 1 and $nontarget != 2 or &trialcount <= 2 ## chose a letter but not that of 3 trials ago
set $currentletter random 1 8
while $currentletter == &nback2 ## choose anything but NOT that of 3 back
set $currentletter random 1 8
while-end
set $requiredresponse 0 ## no key should be pressed
set $typeoftrial 0
fi
###########################################################################
#
draw off
show bitmap $currentletter ## stimulus 1
draw on
readkeys option &stimulus_display_time #add 2
set $extrawait expression &stimulus_display_time - RT ## how much time is left between max RT and now?
##############################################################
## determine whether error was made during number presentation
## people can only make mistake if pressing now when they should not
##############################################################
set $score 0 ## this is the default, assume error
part check_response
set $my_rt RT
###########
## now wait remaining time if needed
###########
delay $extrawait ## wait until number has been on screen total of 760 ms, note this only happens if people already pressed
clear 1 ## clear the number from screen
show bitmap fix #recently added
###########
## now show nothing but allow response during ITI
###########
if STATUS == TIMEOUT ## means people did not respond yet
readkeys option &iti
set $my_rt expression RT + &stimulus_display_time
fi
part check_response
## if you pressed, then some time will be left; during that time, no need to further check keys anymore
set $extrawait expression &iti - RT ## how much time is left between iti RT and now?
## now check if people missed
if $requiredresponse == 1 and $score == 0
set $miss 1
fi
delay $extrawait
### now save the number for next trial
set &nback2 &nback1
set &nback1 $currentnumber
### save the data
save BLOCKNUMBER &trialcount $typeoftrial $score $match $miss $nonmatch $my_rt $target $nontarget $currentnumber &nback1 &nback2
Any help would be greatly appreciated!
EMBH Lab
I am playing around with the coding for the original (2) n-back test and after including a fixation, the first two numbers show but afterwards it becomes just a black screen and no key would read. I want my task to look somewhat like the image attached. Another issue I'm running into is the output. I am trying to use 2 keys for responses: m for it is a 2-back match and n for when it is not a 2-back match. I've tried re-coding each section but no luck.
My code looks like:
#correct response
if $requiredresponse == 1 and STATUS != TIMEOUT
set $score 1 ## correctly pressed during number presentation.
set $match 1
show bitmap fix ## fixation cross
fi
#incorrect response
if $requiredresponse == 2 and STATUS != TIMEOUT
set $score 2 ## incorrect pressed key
set $nonmatch 1
show bitmap fix ## fixation cross
fi
#timed-out response
if $requiredresponse == 0 and STATUS == TIMEOUT
set $score 0 ## so far so good #changed from 1 to 2 and is timed out
#show bitmap fix ## fixation cross
fi
task twoback
keys m n
set &trialcount increase
set $currentnumber random 1 8 ## choose random number out of the 8 options
############################################################################
## is this condition a yes condition?
set $target random 1 &choosechance ## random number for choosing condition
set $nontarget random 2 &choosechance ## random number for choosing condition
## if a 2back trial
if $target == 1 and $nontarget != 2 and &trialcount > 2
set $currentletter &nback2
set $requiredresponse 1 ## the m key needs to be pressed later, m=stands for Memory
set $typeoftrial 1
fi
## if a NON n-back trial - added
if $target != 1 and $nontarget == 2 or &trialcount <= 2 ## chose a letter but not that of 3 trials ago
set $currentletter random 1 8
#while $currentletter == &nback2 ## choose anything but NOT that of 3 back
#set $currentletter random 1 8
# while-end
set $requiredresponse 2 ##
set $typeoftrial 2
fi
## if a timed out trial
if $target != 1 and $nontarget != 2 or &trialcount <= 2 ## chose a letter but not that of 3 trials ago
set $currentletter random 1 8
while $currentletter == &nback2 ## choose anything but NOT that of 3 back
set $currentletter random 1 8
while-end
set $requiredresponse 0 ## no key should be pressed
set $typeoftrial 0
fi
###########################################################################
#
draw off
show bitmap $currentletter ## stimulus 1
draw on
readkeys option &stimulus_display_time #add 2
set $extrawait expression &stimulus_display_time - RT ## how much time is left between max RT and now?
##############################################################
## determine whether error was made during number presentation
## people can only make mistake if pressing now when they should not
##############################################################
set $score 0 ## this is the default, assume error
part check_response
set $my_rt RT
###########
## now wait remaining time if needed
###########
delay $extrawait ## wait until number has been on screen total of 760 ms, note this only happens if people already pressed
clear 1 ## clear the number from screen
show bitmap fix #recently added
###########
## now show nothing but allow response during ITI
###########
if STATUS == TIMEOUT ## means people did not respond yet
readkeys option &iti
set $my_rt expression RT + &stimulus_display_time
fi
part check_response
## if you pressed, then some time will be left; during that time, no need to further check keys anymore
set $extrawait expression &iti - RT ## how much time is left between iti RT and now?
## now check if people missed
if $requiredresponse == 1 and $score == 0
set $miss 1
fi
delay $extrawait
### now save the number for next trial
set &nback2 &nback1
set &nback1 $currentnumber
### save the data
save BLOCKNUMBER &trialcount $typeoftrial $score $match $miss $nonmatch $my_rt $target $nontarget $currentnumber &nback1 &nback2
Any help would be greatly appreciated!
EMBH Lab