Help getting nback script to work--can't get past first screen.


Author
Message
tbauerle
tbauerle
New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)
Group: Forum Members
Posts: 1, Visits: 5
Hello,

We're trying to see what's wrong in getting our Inquisit 5 nback script to work for a touchscreen windows laptop. Worked flawlessly for XID input not too long ago. Tried switching all the inputs to mouse but now we can't click/tap/advance past the first screen. Any input would be greatly appreciated. Thank you in advance.

Version 5.0.14.0 (64 bit)

<usermanual>
                        
                        SINGLE N-BACK TASK NON-ADAPTIVE (1-KEY VERSION)- LETTERS
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software LLC
Date: March, 2012
last updated: 01-20-2016 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Copyright © 01-20-2016 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
The current script is based on the SingleTaskNBack.exp script which implements the single-task version of the N-Back procedure as
described in the following publication:

Jaeggi, Susanne M.; Studer-Luethi, Barbara; Buschkuehl, Martin; Su, Yi-Fen; Jonides, John; Perrig, Walter J. (2010). The
relationship between n-back performance and matrix reasoning - implications for training and transfer. Intelligence, 38, 625-635.

The current script is adapted to implement the procedure of the Single N-back task using letters as described in:
Ragland, J.D., Turetsky, B.I., Gur, R.C, Gunning-Dixon, F., Turner, T, Schroeder, L., Chan, R., & Gur, R.E. (2002).Working Memory
for Complex Figures: An fMRI Comparison of Letter and Fractal n-Back Tasks. Neuropsychology, 16, 370-379.

This Inquisit script provides trials and instructions for single n-back tasks with 20 upper case consonants for 4 levels of N
(N = 0, N = 1, N = 2, N = 3). Other levels of N can be implemented with minimal change.

                                             *Task*
In the 1-key single n-back task, participants are shown a sequence of stimuli (here: a sequence of white letters
on a black background) and are asked to indicate whether the currently presented stimulus fulfills the following criteria:

for N=0 trials*:
- is the letter the same as the first letter presented in the sequence? If so (it's a target), and press "A". If not, don't respond.

for N=1 trials:
- is the letter the same as the one that preceded it? If so (it's a target), and press "A". If not, don't respond.

for N=2 trials:
- is the letter the same as the one presented two trials before? If so (it's a target), and press "A". If not, don't respond.

for N=3 trials:
- is the letter the same as the one presented three trials before? If so (it's a target), and press "A". If not, don't respond.

*Note: The implementation for 0-nback tasks in this script differs from the procedure used by Jaeggi and collegues in her research.
Jaeggi and collegues used a pre-defined shape. In this script, the target shape is defined at runtime for each participant during the first trial.
Participants are instructed to pay close attention to this first presentation and are warned that presentation time is short.
Furthermore in this script, the experimenter can set how long the target letter should be presented to participants in 0 nback trials, as well
as how much time before starting the actual task (after the target has disappeared)


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'SingleTaskNBack_letters_raw.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
blockcode:                        the name of the current block
values.TotalBlocks:                the total number of experimental blocks run
trialcode:                        the name of the current trial
starttrialcounter:                keeps track of how many start trials have been run
stimulusitem:                    the letter presented
stimulusnumber:                 the item number of the presented letter
values.currenttarget:            the item number of the current target
response:                        the response of the participant
correct:                        the correctness of the response
latency:                        how fast a participant responded within the given timeframe, if at all (in ms)
values.trial_Hit:                whether the response was a Hit (=1)
values.trial_FA:                whether the response was a False Alarm (=1)
values.trial_Miss:                whether the response was Miss (=1)
values.trial_CR:                whether the response was a Correct Rejection ( = 1)
values.Hits:                    the sum of Hits in a block
values.FalseA:                    the sum of False Alarms in a block
values. Misses:                    the sum of Misses in a block
values.CorrReject:                the sum of Correct Rejections in a block
values.TotalHits:                the sum of total hits across all experimental blocks
values.TotalFA:                    the number of total false alarms across all experimental blocks
values.DV:                        the proportion of (TotalHits - TotalFA)/number of experimental blocks

(2) Summary data file: 'SingleTaskNBack_letters_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
values.TotalHits:                the sum of total hits across all experimental blocks
values.TotalFA:                    the number of total false alarms across all experimental blocks
values.DV:                        the proportion of (TotalHits - TotalFA)/number of experimental blocks


EXPERIMENTAL SET-UP:
- After instructions, participants receive 9 trials of practice per level N tested (here: N = 0 to N = 3) ,
(-> can be changed to eliminate N = 3 as was done by Ragland et al (2002))
- once practice is done, participants get the option to repeat practice
- After practice, participants receive 3 blocks per level of N tested. Which particular level a participant works on is
pseudo-randomly determined (see Ragland et al, 2002).
- the instructions are self-paced as a default, to change them to a timed format (default = 9s, see Ragland et al, 2002),
    follow instructions under parameters.instruction_duration

Block Information:
- Each single n-task block consists of 15+ trials (Ragland et al, 2002) using 20 different consonants.
=> + trials are the N trials that cannot display target shapes yet (=start trials). Their numbers vary depending on N.
        The data collected during these start trials are NOT included in performance counts for Correct Rejections/False Alarms.
=> Of the actual 15 experimental trials, 5 present a target and 10 do not (1:2 ratio as in Ragland et al, 2002).
- The computer selects randomly
a) whether it is a target trial or not and
b) what letter to show if it is not a target trial

Trial Information:
- Each trial presents the letter for 500ms and waits another 2000ms before presenting the next letter in the sequence
(see Ragland et al. for InterstimulusInterval = 2500ms). The trialduration can be edited by experimenter.
- Participants have the entire 2500ms to respond by pressing "A" if they detect a target.


INFORMATION FOR CODE-CHANGES (e.g. ADDITIONAL/DIFFERENT LEVELS OF N)

Instructions for changing code for additional Ns are provided with this script. Please check the following sections for the relevant info:
1. Custom Values
2. Instructions: (a) Instruction Slides -> Editable Instructions (b) Instruction Blocks -> section Instructions (block.Nbackinstruct_start)
3. Trials
4. Blocks: (a) Practice (b) Experimental


EDITABLE CODE:
check below for (relatively) easily editable parameters, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The parameters you can change are:

trialduration:                            Interstimulusinterval (in ms) for regular n-back trials, default = 2500ms,
posttrialpause_aftertarget0:            the posttrialpause (in ms) after the target in 0nback tasks disappears from sight and the actual 0 nback testing starts
                                                (default = 2000ms, to make it comparable to the remaining trials)
showtarget0:                            the amount of time the target for N = 0 trials should be presented; default = 3000
instruction_duration:                    the time the instructions for each experimental block are shown (in ms), default = 9000ms
                                        only applies if instructions for experimental blocks are NOT self-paced
                                                (see INSTRUCTIONS -> INSTRUCTION TRIALS -> trial.expinstructiontrial for further info)
                                        NOTE: the default for this script are self-paced instructions
debugmode = 0                            debugmode = 1: targetalerts are shown on screen,
                                        debugmode = 0, no targetalerts are shown (default)
/stimulusPresentationtime:        the presentation time (in ms) of the stimuli (default: 500ms)

(in general: if levels of N are changed, adjustments need to be made to instructions and list.Nlevel)

</usermanual>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE PARAMETERS: change editable parameters here
**************************************************************************************************************
**************************************************************************************************************

<parameters>
/ trialduration = 2500
/ posttrialpause_aftertarget0 = 2000
/ instruction_duration = 9000
/ showtarget0 = 3000
/ debugmode = 0
/ stimulusPresentationtime = 500
</parameters>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

* 20 consonants
<item letters>
/ 1 = "B"
/ 2 = "C"
/ 3 = "D"
/ 4 = "F"
/ 5 = "G"
/ 6 = "H"
/ 7 = "J"
/ 8 = "K"
/ 9 = "L"
/ 10 = "M"
/ 11 = "N"
/ 12 = "P"
/ 13 = "Q"
/ 14 = "R"
/ 15 = "S"
/ 16 = "T"
/ 17 = "V"
/ 18 = "W"
/ 19 = "X"
/ 20 = "Z"
</item>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************

***********INSTRUCTION SLIDES*****************************
Note: these instruction slides are adapted from the original instructions kindly provided to Millisecond Software by Jaeggi et al .
Thank you!

*********************************************************
NOTE:
If you only run N = 0 to N = 2, remove/exchange the instructionslides that reference N = 3
**********************************************************
<item Nback_startinstructions>
/ 1 = "SingleNbackInstructions_letters_start.gif"
/ 2 = "SingleNbackInstructions_letters_N2.gif"
</item>
*********************************************************
Alternative if only N=0 - N=2 is run
-> "SingleNbackInstructions_letters_practice012.gif"
*********************************************************


<item practiceend>
/ 1 = "SingleNbackInstructions_letters_practiceend0123.gif"
</item>
*********************************************************
Alternative if only N=0 - N=2 is run
-> "SingleNbackInstructions_letters_practiceend012.gif"
*********************************************************

*slides to start experimental trials/end experiment
<item startendslides>
/ 1 = "StartExpt.gif"
/ 2 = "ThankYouSlide.gif"
</item>

*Instructions for individual practice N-levels (not original)
<item expinstructions>
/ 1 = "SingleNbackInstructionsN0_letters_exp.gif"
/ 2 = "SingleNbackInstructionsN1_letters_exp.gif"
/ 3 = "SingleNbackInstructionsN2_letters_exp.gif"
/ 4 = "SingleNbackInstructionsN3_letters_exp.gif"
</item>

Note: presents the instructions for the test blocks


Used in htmlpage 'ExpInstructions'
<expressions>
/ expInstructions = if (values.N > 0){
        "<p>Press 'A' if the current letter is the same as the letter <span class='red'><b><%values.N%></b></span> trial(s) before.
        Otherwise don't do anything.</p><br><br>";
    } else {
        "<p>Once you start the test, pay <span class='red'>close attention</span> to the first letter. This shape will be your target
        for the remaining trials.
        <p>Press 'A' if the current letter is the same one as the one in the very first trial otherwise don't do anything.</p><br><br>"        
    };
</expressions>




*******CODE CHANGES:
If you would like to run different levels of N in practice/experimental trials, change/add the necessary instruction slides
under the appropriate item categories above, as well as pay attention to the changes necessary under "Instruction Blocks"
block.Nbackinstruct_start

***********************************************************
these instructions will be run if the script is
run on a touchscreen
***********************************************************

<text touchscreenInstruct1>
/ items = ("This is a touchscreen device. Tapping anywhere on the screen to respond during the exercise.")
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 1)
/ position = (50%, 20%)
/ txbgcolor = black
/ txcolor = white
/ size = (80%, 20%)
/ vjustify = center
</text>

<text touchscreenInstruct2>
/ items = ("Tap anywhere on the screen to continue.")



/ fontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txbgcolor = black
/ txcolor = white
/ size = (70%, 30%)
/ vjustify = center
</text>

*********************************
Summary
*********************************
*A feedback page that is presented at the end of each practice block

<instruct>
/ fontstyle = ("Arial", 2.67%, false, false, false, false, 5, 0)
/ txcolor = white
/ screencolor = black
</instruct>

<page BlockSummary>
^^               FEEDBACK
^^
^^CORRECT: <% ((values.Hits + values.CorrReject) /20) * 100 %>% of the times
</page>

<page BlockSummary_practice>
^^               FEEDBACK
^^
^^CORRECT: <% ((values.Hits + values.CorrReject) /10) * 100 %>% of the times
</page>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

Note: list controls the level of N run during practice. By default, practice runs level 2, 3, 4 once and
in sequence
<list nextN_practice>
/ items = (0, 1, 2, 3)
/ selectionmode = sequence
/ selectionrate = block
/ resetinterval = 0
</list>

*list.Nlevel pseudorandomly selects the next N level (the experiment runs as many blocks as there are
items in this list)
! if you do NOT run level N = 3, remove all 3s from the item list of this list
! if you want to run a level more or fewer times adjust the number of the digits in the item list accordingly
! if you want to run the levels in sequence, replace /replace=false with /selectionmode = sequence

IN GENERAL: if you run different levels of N or change the number of repetitions, you need to adjust the item list of
list.nlevel
<list Nlevel>
/ items = (2)
/ replace = false
/ resetinterval = 0
</list>
**************************************************************************************************************
                                !!!REMAINING CODE: Customize after careful consideration only!!!
**************************************************************************************************************


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.5.0 or higher

<defaults>
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ canvasaspectratio = (4,3)
/ minimumversion = "5.0.5.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = white
/ txcolor = (0, 0, 0)
/ screencolor = black
</defaults>


**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

*********************
raw data
*********************
<data>
/ columns = (build, computer.platform, date, time, subject, group, values.N, blockcode, values.TotalBlocks, trialcode, trialnum,
                values.starttrialcounter, stimulusitem, stimulusnumber,
                values.currenttarget, response, correct, latency,
                values.trial_Hit, values.trial_FA, values.trial_Miss, values.trial_CR,                    
                values.Hits, values.FalseA, values.Misses, values.CorrReject,
                values.TotalHits, values.TotalFA, values.DV)
/ separatefiles = true
</data>

*********************
summary data
*********************

<summarydata>
/ columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.TotalHits, values.TotalFA, values.DV)
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                        0 = script was not completed (script was prematurely aborted); 1 = script was completed (all conditions run)

minus1:                            contains the stimulusitemnumber of the stimulus in the trial preceding the current one
minus2:                            contains the stimulusitemnumber of the stimulus shown 2 trials before the current one
minus3:                            contains the stimulusitemnumber of the stimulus shown 3 trials before the current one
minus4:                            contains the stimulusitemnumber of the stimulus shown 4 trials before the current one
stim:                                contains the current stimulusitem
stimnumber:                        contains the current stimulusitemnumber
N:                                    the lag between a target and the stimulus it repeats
currenttarget:                    contains the stimulusnumber of the current target
                                    (a target in N = 0 trials is a stimulus with the same stimulus number as stored in target0)
Hits:                                codes the number of correctly identifiying a target
FalseA:                            codes the number of times a participant identifies a non-target as a target
Misses:                            codes the number of times a participant misses to identify a target
CorrReject:                        codes the number of times a participant correctly identifies a non-target (and does nothing)
values.TotalHits:                the number of total hits across all experimental blocks
values.TotalFA:                    the number of total false alarms across all experimental blocks
values.TotalBlocks:                the total number of experimental blocks run
values.DV:                        dependent variable (DV) in Jaeggi et al (2010): the proportion of (TotalHits - TotalFA)/number of total blocks
starttrialcounter:                keeps track of how many start trials have been run
trialduration_starttrial:        the trialduration time for the starttrials, depends on level of N (starttrial for N = 0 trials differs)
starttrialposttrialpause:        the posttrialpause of starttrials (can be set for N = 0 trials, for all others it's 0)
/lastIndex:                    helper variable to manage the last N presented shape list

<values>
/ completed = 0
/ minus1 = 0
/ minus2 = 0
/ minus3 = 0
/ minus4 = 0
/ N = 0
/ currenttarget = 0
/ Hits = 0
/ FalseA = 0
/ Misses = 0
/ CorrReject = 0
/ TotalHits = 0
/ TotalFA = 0
/ DV = 0
/ TotalBlocks = 0
/ starttrialcounter = 0
/ trialduration_starttrial = 0
/ starttrialposttrialpause = 0
/ trial_Hit = 0
/ trial_Miss = 0
/ trial_CR = 0
/ trial_FA = 0
/ lastIndex = 0
</values>

**************************ADDITIONAL N-LEVELS*************************************
* if additional N-levels are needed, create and add further "minusN" values and set them to 0,
Example: N = 5
/minus5 = 0

**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************
expressions.selectinstruct helps to select the adequate instructions for adaptive n-back testing

<expressions>
/ selectinstruct = values.N + 1
</expressions>

/fillitemlist:            recursive function that fills list.items with N items at the beginning of each new block
<expressions>
/ fillitemlist = {
    if (values.lastIndex < values.N){
        list.items.insertitem(0, 1);
        values.lastIndex += 1;
        expressions.fillitemlist;
    } else {
        list.items.insertitem(0, 1);
    };
}
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************

***********INSTRUCTION IMAGE SELECTION******************************************
<picture SingleNbackinstructions_start>
/ items = Nback_startinstructions
/ select = sequence
/ size = (100%, 100%)
</picture>

<picture Practice_end>
/ items = practiceend
/ select = 1
/ size = (100%, 100%)
</picture>

<picture StartExp_slide>
/ items = startendslides
/ select = 1
/ size = (100%, 100%)
</picture>

<picture EndExp_slide>
/ items = startendslides
/ select = 2
/ size = (100%, 100%)
</picture>

*instructions for individual experimental trials are selected depending on level of N
<picture expinstructionslide>
/ items = expinstructions
/ select = expressions.selectinstruct
/ size = (100%, 100%)
</picture>

<picture repeatpractice_page>
/ items = ("SingleNbackInstructions_practicerepeat.gif")
/ size = (100%, 100%)
</picture>

***********INSTRUCTION TRIALS*******************************************

****************************************************************************************
Note:
* instructions for each level of N are self-paced.
* If they should be shown for a predetermined time (e.g. 9s, see Ragland et al, 2002)
use the following code instead in trial.expinstructiontrial:
/ stimulusframes = [1 = expinstructionslide, eraserrec, wait]
/ validresponse = (noresponse)
/ timeout = (parameters.instruction_duration)
****************************************************************************************

<trial touchscreenInstruct>
/ skip = [
    !computer.touch || computer.haskeyboard;
]
/ stimulusframes = [1 = touchscreenInstruct1, touchscreenInstruct2]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.touchscreenInstruct.response == 80
]
/ recorddata = false
</trial>

<trial expinstructiontrial>
/ stimulusframes = [1 = expinstructionslide]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.expinstructiontrial.response == 80
]
/ recorddata = false
</trial>

<trial Nbackinstruct_starttrial>
/ stimulusframes = [1 = SingleNbackinstructions_start]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.Nbackinstruct_starttrial.response == 80
]
/ recorddata = false
</trial>

<trial Practice_endtrial>
/ stimulusframes = [1 = Practice_end]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.Practice_endtrial.response == 80
]
/ recorddata = false
</trial>

<trial StartExp_trial>
/ stimulusframes = [1 = StartExp_slide]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.StartExp_trial.response == 80
]
/ recorddata = false
</trial>

<trial repeatpractice>
/ stimulusframes = [1 = repeatpractice_page]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.repeatpractice.response == 80
]
/ recorddata = false
</trial>

<trial EndExp_trial>
/ stimulusframes = [1 = EndExp_slide]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.EndExp_trial.response == 80
]
/ recorddata = false
</trial>

**************************************************************************************************************
**************************************************************************************************************
    STIMULI
**************************************************************************************************************
**************************************************************************************************************

***randomly selects one of the letters
<text startletter>
/ items = letters
/ select = replace
/ position = (50%, 50%)
/ txcolor = white
/ txbgcolor = black
/ fontstyle = ("Arial", 50%, false, false, false, false, 5, 0)
</text>

***selects any letter that cannot be a target
<text nontargetletter>
/ items = letters
/ select = list.notargetvalue.nextvalue
/ position = (50%, 50%)
/ txcolor = white
/ txbgcolor = black
/ fontstyle = ("Arial", 50%, false, false, false, false, 5, 0)
</text>

***selects the item with the same item number as the established target
<text targetletter>
/ items = letters
/ select = values.currenttarget
/ position = (50%, 50%)
/ txcolor = white
/ txbgcolor = black
/ fontstyle = ("Arial", 50%, false, false, false, false, 5, 0)
</text>


FEEDBACK MESSAGES FOR PRACTICE TRIALS ONLY (default: they are NOT used)
<text ErrorFeedback>
/ items = ("ERROR")
/ fontstyle = ("Arial", 5.00%, true, false, false, false, 5, 0)
/ txcolor = red
/ txbgcolor = black
/ position = (50%, 70%)
</text>

<text CorrectFeedback>
/ items = ("CORRECT")
/ fontstyle = ("Arial", 5.00%, true, false, false, false, 5, 0)
/ txcolor = green
/ txbgcolor = black
/ position = (50%, 70%)
</text>

ASSISTANT STIMULI:

*****reminder that the letter participants see during the first trial in N = 0 nback trials is the target
<text targetreminder>
/ items = ("this is the target")
/ position = (50%, 25%)
/ txbgcolor = black
/ txcolor = black
/ fontstyle = ("Arial", 3.00%, false, false, false, false, 5, 0)
</text>

*****For timed instructions, this shape covers up the original instructions (on slides)
that instruct participants to use the Spacebar to continue
<shape eraserrec>
/ shape = rectangle
/ color = black
/ position = (50%, 95%)
/ size = (100%, 8%)
</shape>

*****For timed instructions this text alerts participants that the task starts in the
predetermined amount of time (default: 9s)
<text wait>
/ items = ("the task will start automatically in <%parameters.instruction_duration/1000%> s")
/ position = (50%, 95%)
/ txbgcolor = black
/ txcolor = white
/ fontstyle = ("Arial", 2.08%, false, false, false, false, 5, 0)
</text>

*****Debug Code:
<text targetalert>
/ items = ("target")
/ position = (50%, 80%)
/ txcolor = black
/ txbgcolor = black
/ fontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
</text>

**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

****list Variables to select notargetvalue

*list.notargetvalue selects any of the 8 numbers but the one selected for targetvalue
<list notargetvalue>
/ items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
/ not = (values.currenttarget)
/ replace = true
</list>

Note: list contains the itemnumbers of the presented shapes in reversed order (dynamic list)
(item 1 is always the last one presented)
<list items>
</list>

**************************************************************************************************************
**************************************************************************************************************
    TRIALS     
**************************************************************************************************************
**************************************************************************************************************

*there are 3 types of trials
    1. start:                 presented at beginning of block when number of trials too small for Target trials; they can present
                                any of the stimuli (N = 0, start trial presents the target shape)
    2. nontarget:            trials that present stimuli that do not repeat the stimulus of n-trials before
    3. target:                trials that present Target stimuli



**********************************
Starttrial
**********************************
NOTE:
for N = 0 trials:
- the first trial shows the target for a set amount of time (editable), together with a text stimulus that
reminds participants that this letter is the target.
- There is a pause (length is editable) before the next trial starts

*start trial runs N-times (unless N = 0, then it runs N = 1 time)
<trial start>
/ ontrialbegin = [
    if (values.N == 0) {
        text.targetreminder.textcolor = red;
        values.trialduration_starttrial = parameters.showtarget0;
        values.starttrialposttrialpause = parameters.posttrialpause_aftertarget0;
    } else {
        trial.start.insertstimulustime(clearscreen, parameters.stimulusPresentationtime);
        values.trialduration_starttrial = parameters.trialduration;
        values.starttrialposttrialpause = 0;
    };
    values.starttrialcounter += 1;
    values.trial_Hit = 0;
    values.trial_Miss = 0;
    values.trial_CR = 0;
    values.trial_FA = 0;
]
/ stimulustimes = [0 = startletter, targetreminder]
/ inputdevice = mouse
/ isvalidresponse = [
    trial.start.response == 80 || trial.nontarget.response == 0
]
/ validresponse = (anyresponse)
/ iscorrectresponse = [
    trial.nontarget.response == 0
]
/ ontrialend = [
    trial.start.resetstimulusframes();
    if (values.N == 0) {
        values.currenttarget = text.startletter.currentitemnumber;
    }
    list.items.insertitem(text.startletter.currentitemnumber, 1);
    text.targetreminder.textcolor = black;
]
/ beginresponsetime = 0
/ trialduration = values.trialduration_starttrial
/ posttrialpause = (values.starttrialposttrialpause)
/ branch = [
    if (values.starttrialcounter < values.N)
        trial.start
]
</trial>

**********************************
Nontarget Trials
**********************************
<trial nontarget>
/ stimulustimes = [0 = nontargetletter]
/ inputdevice = mouse
/ isvalidresponse = [
    trial.nontarget.response == 80 || trial.nontarget.response == 0
]
/ validresponse = (anyresponse)
/ iscorrectresponse = [
    trial.nontarget.response == 0
]
/ ontrialbegin = [
    trial.nontarget.insertstimulustime(clearscreen, parameters.stimulusPresentationtime);
    if (values.N > 0) {
        values.currenttarget = list.items.item(values.N);
    };
    values.trial_Hit = 0;
    values.trial_Miss = 0;
    values.trial_CR = 0;
    values.trial_FA = 0;
]
/ ontrialend = [
    trial.nontarget.resetstimulusframes();
    list.items.insertitem(text.nontargetletter.currentitemnumber, 1);
    values.CorrReject = values.CorrReject + trial.nontarget.correct;
    values.trial_CR = trial.nontarget.correct;
    values.FalseA = values.FalseA + trial.nontarget.error;
    values.trial_FA = trial.nontarget.error;
    values.TotalFA = values.TotalFA + trial.nontarget.error;
    values.DV = (values.TotalHits - values.TotalFA)/values.TotalBlocks;
]
/ beginresponsetime = 0
/ trialduration = parameters.trialduration
</trial>

**********************************
Target Trials
**********************************
**if target, press the letter "A" (code: 30)
<trial target>
/ stimulustimes = [0 = targetletter, targetalert]
/ inputdevice = mouse
/ isvalidresponse = [
    trial.target.response == 80 || trial.target.response == 0
]
/ validresponse = (anyresponse)
/ iscorrectresponse = [
    trial.target.response == 80
]
/ ontrialbegin = [
    trial.target.insertstimulustime(clearscreen, parameters.stimulusPresentationtime);
    if (values.N > 0) {
        values.currenttarget = list.items.item(values.N);
    };
    values.trial_Hit = 0;
    values.trial_Miss = 0;
    values.trial_CR = 0;
    values.trial_FA = 0;
]

/ ontrialend = [
    trial.target.resetstimulusframes();
    list.items.insertitem(text.targetletter.currentitemnumber, 1);
    values.Hits = values.Hits+ trial.target.correct;
    values.trial_Hit = trial.target.correct;
    values.Misses = values.Misses + trial.target.error;
    values.trial_Miss = trial.target.error;
    values.TotalHits = values.TotalHits + trial.target.correct;
    values.DV = (values.TotalHits - values.TotalFA)/values.TotalBlocks;
]
/ beginresponsetime = 0
/ trialduration = parameters.trialduration
</trial>
                    
**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

ATTENTION: PRACTICE BLOCKS
(1) This block sets the beginning N value for practice trials to the lowest level of N run in the experiment
(2) runs instructions 1-6, for N=0-3, if more/fewer than four N levels are run adjust /trials = [1-X.....]
Example: N=0 to N = 2: / trials = [1-5 = Nbackinstruct_starttrial]

<block Nbackinstruct_start>
/ trials = [1 = touchscreenInstruct; 2-3 = Nbackinstruct_starttrial]
/ recorddata = false
</block>

<block RepeatPractice>
/ trials = [1 = repeatpractice]
/ recorddata = false
/ branch = [
    if (trial.repeatpractice.response == 21) {
        block.practice_s_ntask
    } else
        block.Practiceblock_end;
]
/ screencolor = black
</block>

<block Practiceblock_end>
/ trials = [1 = Practice_endtrial]
/ recorddata = false
</block>

**********************************************
PRACTICE
**********************************************

* Practice Blocks give feedback and do NOT record data
* Block starts with
(a) Instructiontrial
(b) N start-trials that cannot present Targets yet (no data collected) , if N = 0, the first trial presents the target letter
(c) 9 practice trials: ratio targets : nontargets = 1 : 2
* stops after lever N = highestN (set by experimenter)
(d) runs from the lowest N to the highest N

<block practice_s_ntask>
/ onblockbegin = [
    values.N = list.nextN_practice.nextvalue;
    values.currenttarget = 0;
    values.currenttarget = 0;
    list.items.reset();
    values.TotalBlocks += 1;
    values.starttrialcounter = 0;
    values.Hits = 0;
    values.FalseA = 0;
    values.Misses = 0;
    values.CorrReject = 0;
]
/ trials = [1 = expinstructiontrial; 2 = start; 3 - 11 = noreplace(nontarget, nontarget, target)]
/ onblockend = [
    values.TotalHits = 0;
    values.TotalFA = 0;
    values.DV = 0
]
/ screencolor = (0, 0, 0)
/ recorddata = false
/ postinstructions = (BlockSummary_practice)
/ branch = [
    if (values.TotalBlocks < list.nextN_practice.itemcount) {
        values.TotalBlocks = 0;
        block.RepeatPractice;
    } else {
        block.practice_s_ntask;
    };
]    
</block>

if trial feedback is desired:
/ errormessage = true(ErrorFeedback, 500)
/ correctmessage = true(CorrectFeedback, 500)

**********************************************
EXPERIMENTAL-BLOCKS NONADAPTIVE
**********************************************

<block StartExp>
/ trials = [1 = StartExp_trial]
/ recorddata = false
/ onblockbegin = [
    values.TotalHits = 0;
    values.TotalFA = 0;
    values.TotalBlocks = 0;
    values.DV = 0;
]
</block>

* Block starts with
(a) Instructiontrial
(b) N start-trials that cannot present Targets yet
(c) 15 Experimental trials
* Experimental trials: ratio targets : nontargets = 1 : 2
* N level is pseudo-randomly selected by list.Nlevel
* Block runs as many times as there are items in list.Nlevel

<block s_ntask>
/ onblockbegin = [
    values.N = list.Nlevel.nextvalue;
    values.currenttarget = 0;
    list.items.reset();
    values.lastIndex = 1;
    expressions.fillitemlist;
    values.Hits = 0;
    values.FalseA = 0;
    values.Misses = 0;
    values.CorrReject = 0;
    values.TotalBlocks += 1;
    values.starttrialcounter = 0;
]
/ trials = [1 = start; 2 - 72 = noreplace(nontarget, nontarget, target)]
/ screencolor = (0, 0, 0)
/ branch = [
    if (values.TotalBlocks < list.Nlevel.itemcount) {
        block.s_ntask;
    } else {
        block.EndExp;
    };
]
</block>

<block EndExp>
/ trials = [1 = EndExp_trial]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

*After running the initial instructions, participants work through practice blocks for N = lowestN to N = highestN
* After practice, participants work through 3 blocks for each of the level of N (levels are pseudorandomly determined)

<expt>
/ onexptbegin = [
    if (parameters.debugmode == 1)
        text.targetalert.textcolor = red
]
/ blocks = [
    1 = Nbackinstruct_start;
    2 = StartExp;
    3 = s_ntask;
]
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
                                                End of File
**************************************************************************************************************
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 83K
tbauerle - 6/22/2022
Hello,

We're trying to see what's wrong in getting our Inquisit 5 nback script to work for a touchscreen windows laptop. Worked flawlessly for XID input not too long ago. Tried switching all the inputs to mouse but now we can't click/tap/advance past the first screen. Any input would be greatly appreciated. Thank you in advance.

Version 5.0.14.0 (64 bit)

<usermanual>
                        
                        SINGLE N-BACK TASK NON-ADAPTIVE (1-KEY VERSION)- LETTERS
SCRIPT INFO

Script Author: Katja Borchert, Ph.D. (katjab@millisecond.com) for Millisecond Software LLC
Date: March, 2012
last updated: 01-20-2016 by K.Borchert (katjab@millisecond.com) for Millisecond Software LLC

Copyright © 01-20-2016 Millisecond Software


BACKGROUND INFO

                                            *Purpose*
The current script is based on the SingleTaskNBack.exp script which implements the single-task version of the N-Back procedure as
described in the following publication:

Jaeggi, Susanne M.; Studer-Luethi, Barbara; Buschkuehl, Martin; Su, Yi-Fen; Jonides, John; Perrig, Walter J. (2010). The
relationship between n-back performance and matrix reasoning - implications for training and transfer. Intelligence, 38, 625-635.

The current script is adapted to implement the procedure of the Single N-back task using letters as described in:
Ragland, J.D., Turetsky, B.I., Gur, R.C, Gunning-Dixon, F., Turner, T, Schroeder, L., Chan, R., & Gur, R.E. (2002).Working Memory
for Complex Figures: An fMRI Comparison of Letter and Fractal n-Back Tasks. Neuropsychology, 16, 370-379.

This Inquisit script provides trials and instructions for single n-back tasks with 20 upper case consonants for 4 levels of N
(N = 0, N = 1, N = 2, N = 3). Other levels of N can be implemented with minimal change.

                                             *Task*
In the 1-key single n-back task, participants are shown a sequence of stimuli (here: a sequence of white letters
on a black background) and are asked to indicate whether the currently presented stimulus fulfills the following criteria:

for N=0 trials*:
- is the letter the same as the first letter presented in the sequence? If so (it's a target), and press "A". If not, don't respond.

for N=1 trials:
- is the letter the same as the one that preceded it? If so (it's a target), and press "A". If not, don't respond.

for N=2 trials:
- is the letter the same as the one presented two trials before? If so (it's a target), and press "A". If not, don't respond.

for N=3 trials:
- is the letter the same as the one presented three trials before? If so (it's a target), and press "A". If not, don't respond.

*Note: The implementation for 0-nback tasks in this script differs from the procedure used by Jaeggi and collegues in her research.
Jaeggi and collegues used a pre-defined shape. In this script, the target shape is defined at runtime for each participant during the first trial.
Participants are instructed to pay close attention to this first presentation and are warned that presentation time is short.
Furthermore in this script, the experimenter can set how long the target letter should be presented to participants in 0 nback trials, as well
as how much time before starting the actual task (after the target has disappeared)


DATA FILE INFORMATION:
The default data stored in the data files are:

(1) Raw data file: 'SingleTaskNBack_letters_raw.iqdat' (a separate file for each participant)

build:                            Inquisit build
computer.platform:                the platform the script was run on
date, time, subject, group:        date and time script was run with the current subject/groupnumber
blockcode:                        the name of the current block
values.TotalBlocks:                the total number of experimental blocks run
trialcode:                        the name of the current trial
starttrialcounter:                keeps track of how many start trials have been run
stimulusitem:                    the letter presented
stimulusnumber:                 the item number of the presented letter
values.currenttarget:            the item number of the current target
response:                        the response of the participant
correct:                        the correctness of the response
latency:                        how fast a participant responded within the given timeframe, if at all (in ms)
values.trial_Hit:                whether the response was a Hit (=1)
values.trial_FA:                whether the response was a False Alarm (=1)
values.trial_Miss:                whether the response was Miss (=1)
values.trial_CR:                whether the response was a Correct Rejection ( = 1)
values.Hits:                    the sum of Hits in a block
values.FalseA:                    the sum of False Alarms in a block
values. Misses:                    the sum of Misses in a block
values.CorrReject:                the sum of Correct Rejections in a block
values.TotalHits:                the sum of total hits across all experimental blocks
values.TotalFA:                    the number of total false alarms across all experimental blocks
values.DV:                        the proportion of (TotalHits - TotalFA)/number of experimental blocks

(2) Summary data file: 'SingleTaskNBack_letters_summary*.iqdat' (a separate file for each participant)

script.startdate:                date script was run
script.starttime:                time script was started
script.subjectid:                subject id number
script.groupid:                    group id number
script.elapsedtime:                time it took to run script (in ms)
computer.platform:                the platform the script was run on
/completed:                        0 = script was not completed (prematurely aborted); 1 = script was completed (all conditions run)
values.TotalHits:                the sum of total hits across all experimental blocks
values.TotalFA:                    the number of total false alarms across all experimental blocks
values.DV:                        the proportion of (TotalHits - TotalFA)/number of experimental blocks


EXPERIMENTAL SET-UP:
- After instructions, participants receive 9 trials of practice per level N tested (here: N = 0 to N = 3) ,
(-> can be changed to eliminate N = 3 as was done by Ragland et al (2002))
- once practice is done, participants get the option to repeat practice
- After practice, participants receive 3 blocks per level of N tested. Which particular level a participant works on is
pseudo-randomly determined (see Ragland et al, 2002).
- the instructions are self-paced as a default, to change them to a timed format (default = 9s, see Ragland et al, 2002),
    follow instructions under parameters.instruction_duration

Block Information:
- Each single n-task block consists of 15+ trials (Ragland et al, 2002) using 20 different consonants.
=> + trials are the N trials that cannot display target shapes yet (=start trials). Their numbers vary depending on N.
        The data collected during these start trials are NOT included in performance counts for Correct Rejections/False Alarms.
=> Of the actual 15 experimental trials, 5 present a target and 10 do not (1:2 ratio as in Ragland et al, 2002).
- The computer selects randomly
a) whether it is a target trial or not and
b) what letter to show if it is not a target trial

Trial Information:
- Each trial presents the letter for 500ms and waits another 2000ms before presenting the next letter in the sequence
(see Ragland et al. for InterstimulusInterval = 2500ms). The trialduration can be edited by experimenter.
- Participants have the entire 2500ms to respond by pressing "A" if they detect a target.


INFORMATION FOR CODE-CHANGES (e.g. ADDITIONAL/DIFFERENT LEVELS OF N)

Instructions for changing code for additional Ns are provided with this script. Please check the following sections for the relevant info:
1. Custom Values
2. Instructions: (a) Instruction Slides -> Editable Instructions (b) Instruction Blocks -> section Instructions (block.Nbackinstruct_start)
3. Trials
4. Blocks: (a) Practice (b) Experimental


EDITABLE CODE:
check below for (relatively) easily editable parameters, stimuli, instructions etc.
Keep in mind that you can use this script as a template and therefore always "mess" with the entire code to further customize your experiment.

The parameters you can change are:

trialduration:                            Interstimulusinterval (in ms) for regular n-back trials, default = 2500ms,
posttrialpause_aftertarget0:            the posttrialpause (in ms) after the target in 0nback tasks disappears from sight and the actual 0 nback testing starts
                                                (default = 2000ms, to make it comparable to the remaining trials)
showtarget0:                            the amount of time the target for N = 0 trials should be presented; default = 3000
instruction_duration:                    the time the instructions for each experimental block are shown (in ms), default = 9000ms
                                        only applies if instructions for experimental blocks are NOT self-paced
                                                (see INSTRUCTIONS -> INSTRUCTION TRIALS -> trial.expinstructiontrial for further info)
                                        NOTE: the default for this script are self-paced instructions
debugmode = 0                            debugmode = 1: targetalerts are shown on screen,
                                        debugmode = 0, no targetalerts are shown (default)
/stimulusPresentationtime:        the presentation time (in ms) of the stimuli (default: 500ms)

(in general: if levels of N are changed, adjustments need to be made to instructions and list.Nlevel)

</usermanual>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE PARAMETERS: change editable parameters here
**************************************************************************************************************
**************************************************************************************************************

<parameters>
/ trialduration = 2500
/ posttrialpause_aftertarget0 = 2000
/ instruction_duration = 9000
/ showtarget0 = 3000
/ debugmode = 0
/ stimulusPresentationtime = 500
</parameters>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

* 20 consonants
<item letters>
/ 1 = "B"
/ 2 = "C"
/ 3 = "D"
/ 4 = "F"
/ 5 = "G"
/ 6 = "H"
/ 7 = "J"
/ 8 = "K"
/ 9 = "L"
/ 10 = "M"
/ 11 = "N"
/ 12 = "P"
/ 13 = "Q"
/ 14 = "R"
/ 15 = "S"
/ 16 = "T"
/ 17 = "V"
/ 18 = "W"
/ 19 = "X"
/ 20 = "Z"
</item>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************

***********INSTRUCTION SLIDES*****************************
Note: these instruction slides are adapted from the original instructions kindly provided to Millisecond Software by Jaeggi et al .
Thank you!

*********************************************************
NOTE:
If you only run N = 0 to N = 2, remove/exchange the instructionslides that reference N = 3
**********************************************************
<item Nback_startinstructions>
/ 1 = "SingleNbackInstructions_letters_start.gif"
/ 2 = "SingleNbackInstructions_letters_N2.gif"
</item>
*********************************************************
Alternative if only N=0 - N=2 is run
-> "SingleNbackInstructions_letters_practice012.gif"
*********************************************************


<item practiceend>
/ 1 = "SingleNbackInstructions_letters_practiceend0123.gif"
</item>
*********************************************************
Alternative if only N=0 - N=2 is run
-> "SingleNbackInstructions_letters_practiceend012.gif"
*********************************************************

*slides to start experimental trials/end experiment
<item startendslides>
/ 1 = "StartExpt.gif"
/ 2 = "ThankYouSlide.gif"
</item>

*Instructions for individual practice N-levels (not original)
<item expinstructions>
/ 1 = "SingleNbackInstructionsN0_letters_exp.gif"
/ 2 = "SingleNbackInstructionsN1_letters_exp.gif"
/ 3 = "SingleNbackInstructionsN2_letters_exp.gif"
/ 4 = "SingleNbackInstructionsN3_letters_exp.gif"
</item>

Note: presents the instructions for the test blocks


Used in htmlpage 'ExpInstructions'
<expressions>
/ expInstructions = if (values.N > 0){
        "<p>Press 'A' if the current letter is the same as the letter <span class='red'><b><%values.N%></b></span> trial(s) before.
        Otherwise don't do anything.</p><br><br>";
    } else {
        "<p>Once you start the test, pay <span class='red'>close attention</span> to the first letter. This shape will be your target
        for the remaining trials.
        <p>Press 'A' if the current letter is the same one as the one in the very first trial otherwise don't do anything.</p><br><br>"        
    };
</expressions>




*******CODE CHANGES:
If you would like to run different levels of N in practice/experimental trials, change/add the necessary instruction slides
under the appropriate item categories above, as well as pay attention to the changes necessary under "Instruction Blocks"
block.Nbackinstruct_start

***********************************************************
these instructions will be run if the script is
run on a touchscreen
***********************************************************

<text touchscreenInstruct1>
/ items = ("This is a touchscreen device. Tapping anywhere on the screen to respond during the exercise.")
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 1)
/ position = (50%, 20%)
/ txbgcolor = black
/ txcolor = white
/ size = (80%, 20%)
/ vjustify = center
</text>

<text touchscreenInstruct2>
/ items = ("Tap anywhere on the screen to continue.")



/ fontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
/ position = (50%, 50%)
/ txbgcolor = black
/ txcolor = white
/ size = (70%, 30%)
/ vjustify = center
</text>

*********************************
Summary
*********************************
*A feedback page that is presented at the end of each practice block

<instruct>
/ fontstyle = ("Arial", 2.67%, false, false, false, false, 5, 0)
/ txcolor = white
/ screencolor = black
</instruct>

<page BlockSummary>
^^               FEEDBACK
^^
^^CORRECT: <% ((values.Hits + values.CorrReject) /20) * 100 %>% of the times
</page>

<page BlockSummary_practice>
^^               FEEDBACK
^^
^^CORRECT: <% ((values.Hits + values.CorrReject) /10) * 100 %>% of the times
</page>


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE LISTS: change editable lists here
**************************************************************************************************************
**************************************************************************************************************

Note: list controls the level of N run during practice. By default, practice runs level 2, 3, 4 once and
in sequence
<list nextN_practice>
/ items = (0, 1, 2, 3)
/ selectionmode = sequence
/ selectionrate = block
/ resetinterval = 0
</list>

*list.Nlevel pseudorandomly selects the next N level (the experiment runs as many blocks as there are
items in this list)
! if you do NOT run level N = 3, remove all 3s from the item list of this list
! if you want to run a level more or fewer times adjust the number of the digits in the item list accordingly
! if you want to run the levels in sequence, replace /replace=false with /selectionmode = sequence

IN GENERAL: if you run different levels of N or change the number of repetitions, you need to adjust the item list of
list.nlevel
<list Nlevel>
/ items = (2)
/ replace = false
/ resetinterval = 0
</list>
**************************************************************************************************************
                                !!!REMAINING CODE: Customize after careful consideration only!!!
**************************************************************************************************************


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************
script requires Inquisit 5.0.5.0 or higher

<defaults>
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ canvasaspectratio = (4,3)
/ minimumversion = "5.0.5.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = white
/ txcolor = (0, 0, 0)
/ screencolor = black
</defaults>


**************************************************************************************************************
**************************************************************************************************************
    DATA
**************************************************************************************************************
**************************************************************************************************************

Note: data file explanations under User Manual Information at the top

*********************
raw data
*********************
<data>
/ columns = (build, computer.platform, date, time, subject, group, values.N, blockcode, values.TotalBlocks, trialcode, trialnum,
                values.starttrialcounter, stimulusitem, stimulusnumber,
                values.currenttarget, response, correct, latency,
                values.trial_Hit, values.trial_FA, values.trial_Miss, values.trial_CR,                    
                values.Hits, values.FalseA, values.Misses, values.CorrReject,
                values.TotalHits, values.TotalFA, values.DV)
/ separatefiles = true
</data>

*********************
summary data
*********************

<summarydata>
/ columns = (script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, computer.platform, values.completed,
values.TotalHits, values.TotalFA, values.DV)
/ separatefiles = true
</summarydata>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                        0 = script was not completed (script was prematurely aborted); 1 = script was completed (all conditions run)

minus1:                            contains the stimulusitemnumber of the stimulus in the trial preceding the current one
minus2:                            contains the stimulusitemnumber of the stimulus shown 2 trials before the current one
minus3:                            contains the stimulusitemnumber of the stimulus shown 3 trials before the current one
minus4:                            contains the stimulusitemnumber of the stimulus shown 4 trials before the current one
stim:                                contains the current stimulusitem
stimnumber:                        contains the current stimulusitemnumber
N:                                    the lag between a target and the stimulus it repeats
currenttarget:                    contains the stimulusnumber of the current target
                                    (a target in N = 0 trials is a stimulus with the same stimulus number as stored in target0)
Hits:                                codes the number of correctly identifiying a target
FalseA:                            codes the number of times a participant identifies a non-target as a target
Misses:                            codes the number of times a participant misses to identify a target
CorrReject:                        codes the number of times a participant correctly identifies a non-target (and does nothing)
values.TotalHits:                the number of total hits across all experimental blocks
values.TotalFA:                    the number of total false alarms across all experimental blocks
values.TotalBlocks:                the total number of experimental blocks run
values.DV:                        dependent variable (DV) in Jaeggi et al (2010): the proportion of (TotalHits - TotalFA)/number of total blocks
starttrialcounter:                keeps track of how many start trials have been run
trialduration_starttrial:        the trialduration time for the starttrials, depends on level of N (starttrial for N = 0 trials differs)
starttrialposttrialpause:        the posttrialpause of starttrials (can be set for N = 0 trials, for all others it's 0)
/lastIndex:                    helper variable to manage the last N presented shape list

<values>
/ completed = 0
/ minus1 = 0
/ minus2 = 0
/ minus3 = 0
/ minus4 = 0
/ N = 0
/ currenttarget = 0
/ Hits = 0
/ FalseA = 0
/ Misses = 0
/ CorrReject = 0
/ TotalHits = 0
/ TotalFA = 0
/ DV = 0
/ TotalBlocks = 0
/ starttrialcounter = 0
/ trialduration_starttrial = 0
/ starttrialposttrialpause = 0
/ trial_Hit = 0
/ trial_Miss = 0
/ trial_CR = 0
/ trial_FA = 0
/ lastIndex = 0
</values>

**************************ADDITIONAL N-LEVELS*************************************
* if additional N-levels are needed, create and add further "minusN" values and set them to 0,
Example: N = 5
/minus5 = 0

**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************
expressions.selectinstruct helps to select the adequate instructions for adaptive n-back testing

<expressions>
/ selectinstruct = values.N + 1
</expressions>

/fillitemlist:            recursive function that fills list.items with N items at the beginning of each new block
<expressions>
/ fillitemlist = {
    if (values.lastIndex < values.N){
        list.items.insertitem(0, 1);
        values.lastIndex += 1;
        expressions.fillitemlist;
    } else {
        list.items.insertitem(0, 1);
    };
}
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************

***********INSTRUCTION IMAGE SELECTION******************************************
<picture SingleNbackinstructions_start>
/ items = Nback_startinstructions
/ select = sequence
/ size = (100%, 100%)
</picture>

<picture Practice_end>
/ items = practiceend
/ select = 1
/ size = (100%, 100%)
</picture>

<picture StartExp_slide>
/ items = startendslides
/ select = 1
/ size = (100%, 100%)
</picture>

<picture EndExp_slide>
/ items = startendslides
/ select = 2
/ size = (100%, 100%)
</picture>

*instructions for individual experimental trials are selected depending on level of N
<picture expinstructionslide>
/ items = expinstructions
/ select = expressions.selectinstruct
/ size = (100%, 100%)
</picture>

<picture repeatpractice_page>
/ items = ("SingleNbackInstructions_practicerepeat.gif")
/ size = (100%, 100%)
</picture>

***********INSTRUCTION TRIALS*******************************************

****************************************************************************************
Note:
* instructions for each level of N are self-paced.
* If they should be shown for a predetermined time (e.g. 9s, see Ragland et al, 2002)
use the following code instead in trial.expinstructiontrial:
/ stimulusframes = [1 = expinstructionslide, eraserrec, wait]
/ validresponse = (noresponse)
/ timeout = (parameters.instruction_duration)
****************************************************************************************

<trial touchscreenInstruct>
/ skip = [
    !computer.touch || computer.haskeyboard;
]
/ stimulusframes = [1 = touchscreenInstruct1, touchscreenInstruct2]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.touchscreenInstruct.response == 80
]
/ recorddata = false
</trial>

<trial expinstructiontrial>
/ stimulusframes = [1 = expinstructionslide]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.expinstructiontrial.response == 80
]
/ recorddata = false
</trial>

<trial Nbackinstruct_starttrial>
/ stimulusframes = [1 = SingleNbackinstructions_start]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.Nbackinstruct_starttrial.response == 80
]
/ recorddata = false
</trial>

<trial Practice_endtrial>
/ stimulusframes = [1 = Practice_end]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.Practice_endtrial.response == 80
]
/ recorddata = false
</trial>

<trial StartExp_trial>
/ stimulusframes = [1 = StartExp_slide]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.StartExp_trial.response == 80
]
/ recorddata = false
</trial>

<trial repeatpractice>
/ stimulusframes = [1 = repeatpractice_page]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.repeatpractice.response == 80
]
/ recorddata = false
</trial>

<trial EndExp_trial>
/ stimulusframes = [1 = EndExp_slide]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
    trial.EndExp_trial.response == 80
]
/ recorddata = false
</trial>

**************************************************************************************************************
**************************************************************************************************************
    STIMULI
**************************************************************************************************************
**************************************************************************************************************

***randomly selects one of the letters
<text startletter>
/ items = letters
/ select = replace
/ position = (50%, 50%)
/ txcolor = white
/ txbgcolor = black
/ fontstyle = ("Arial", 50%, false, false, false, false, 5, 0)
</text>

***selects any letter that cannot be a target
<text nontargetletter>
/ items = letters
/ select = list.notargetvalue.nextvalue
/ position = (50%, 50%)
/ txcolor = white
/ txbgcolor = black
/ fontstyle = ("Arial", 50%, false, false, false, false, 5, 0)
</text>

***selects the item with the same item number as the established target
<text targetletter>
/ items = letters
/ select = values.currenttarget
/ position = (50%, 50%)
/ txcolor = white
/ txbgcolor = black
/ fontstyle = ("Arial", 50%, false, false, false, false, 5, 0)
</text>


FEEDBACK MESSAGES FOR PRACTICE TRIALS ONLY (default: they are NOT used)
<text ErrorFeedback>
/ items = ("ERROR")
/ fontstyle = ("Arial", 5.00%, true, false, false, false, 5, 0)
/ txcolor = red
/ txbgcolor = black
/ position = (50%, 70%)
</text>

<text CorrectFeedback>
/ items = ("CORRECT")
/ fontstyle = ("Arial", 5.00%, true, false, false, false, 5, 0)
/ txcolor = green
/ txbgcolor = black
/ position = (50%, 70%)
</text>

ASSISTANT STIMULI:

*****reminder that the letter participants see during the first trial in N = 0 nback trials is the target
<text targetreminder>
/ items = ("this is the target")
/ position = (50%, 25%)
/ txbgcolor = black
/ txcolor = black
/ fontstyle = ("Arial", 3.00%, false, false, false, false, 5, 0)
</text>

*****For timed instructions, this shape covers up the original instructions (on slides)
that instruct participants to use the Spacebar to continue
<shape eraserrec>
/ shape = rectangle
/ color = black
/ position = (50%, 95%)
/ size = (100%, 8%)
</shape>

*****For timed instructions this text alerts participants that the task starts in the
predetermined amount of time (default: 9s)
<text wait>
/ items = ("the task will start automatically in <%parameters.instruction_duration/1000%> s")
/ position = (50%, 95%)
/ txbgcolor = black
/ txcolor = white
/ fontstyle = ("Arial", 2.08%, false, false, false, false, 5, 0)
</text>

*****Debug Code:
<text targetalert>
/ items = ("target")
/ position = (50%, 80%)
/ txcolor = black
/ txbgcolor = black
/ fontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
</text>

**************************************************************************************************************
**************************************************************************************************************
    LISTS    
**************************************************************************************************************
**************************************************************************************************************

****list Variables to select notargetvalue

*list.notargetvalue selects any of the 8 numbers but the one selected for targetvalue
<list notargetvalue>
/ items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
/ not = (values.currenttarget)
/ replace = true
</list>

Note: list contains the itemnumbers of the presented shapes in reversed order (dynamic list)
(item 1 is always the last one presented)
<list items>
</list>

**************************************************************************************************************
**************************************************************************************************************
    TRIALS     
**************************************************************************************************************
**************************************************************************************************************

*there are 3 types of trials
    1. start:                 presented at beginning of block when number of trials too small for Target trials; they can present
                                any of the stimuli (N = 0, start trial presents the target shape)
    2. nontarget:            trials that present stimuli that do not repeat the stimulus of n-trials before
    3. target:                trials that present Target stimuli



**********************************
Starttrial
**********************************
NOTE:
for N = 0 trials:
- the first trial shows the target for a set amount of time (editable), together with a text stimulus that
reminds participants that this letter is the target.
- There is a pause (length is editable) before the next trial starts

*start trial runs N-times (unless N = 0, then it runs N = 1 time)
<trial start>
/ ontrialbegin = [
    if (values.N == 0) {
        text.targetreminder.textcolor = red;
        values.trialduration_starttrial = parameters.showtarget0;
        values.starttrialposttrialpause = parameters.posttrialpause_aftertarget0;
    } else {
        trial.start.insertstimulustime(clearscreen, parameters.stimulusPresentationtime);
        values.trialduration_starttrial = parameters.trialduration;
        values.starttrialposttrialpause = 0;
    };
    values.starttrialcounter += 1;
    values.trial_Hit = 0;
    values.trial_Miss = 0;
    values.trial_CR = 0;
    values.trial_FA = 0;
]
/ stimulustimes = [0 = startletter, targetreminder]
/ inputdevice = mouse
/ isvalidresponse = [
    trial.start.response == 80 || trial.nontarget.response == 0
]
/ validresponse = (anyresponse)
/ iscorrectresponse = [
    trial.nontarget.response == 0
]
/ ontrialend = [
    trial.start.resetstimulusframes();
    if (values.N == 0) {
        values.currenttarget = text.startletter.currentitemnumber;
    }
    list.items.insertitem(text.startletter.currentitemnumber, 1);
    text.targetreminder.textcolor = black;
]
/ beginresponsetime = 0
/ trialduration = values.trialduration_starttrial
/ posttrialpause = (values.starttrialposttrialpause)
/ branch = [
    if (values.starttrialcounter < values.N)
        trial.start
]
</trial>

**********************************
Nontarget Trials
**********************************
<trial nontarget>
/ stimulustimes = [0 = nontargetletter]
/ inputdevice = mouse
/ isvalidresponse = [
    trial.nontarget.response == 80 || trial.nontarget.response == 0
]
/ validresponse = (anyresponse)
/ iscorrectresponse = [
    trial.nontarget.response == 0
]
/ ontrialbegin = [
    trial.nontarget.insertstimulustime(clearscreen, parameters.stimulusPresentationtime);
    if (values.N > 0) {
        values.currenttarget = list.items.item(values.N);
    };
    values.trial_Hit = 0;
    values.trial_Miss = 0;
    values.trial_CR = 0;
    values.trial_FA = 0;
]
/ ontrialend = [
    trial.nontarget.resetstimulusframes();
    list.items.insertitem(text.nontargetletter.currentitemnumber, 1);
    values.CorrReject = values.CorrReject + trial.nontarget.correct;
    values.trial_CR = trial.nontarget.correct;
    values.FalseA = values.FalseA + trial.nontarget.error;
    values.trial_FA = trial.nontarget.error;
    values.TotalFA = values.TotalFA + trial.nontarget.error;
    values.DV = (values.TotalHits - values.TotalFA)/values.TotalBlocks;
]
/ beginresponsetime = 0
/ trialduration = parameters.trialduration
</trial>

**********************************
Target Trials
**********************************
**if target, press the letter "A" (code: 30)
<trial target>
/ stimulustimes = [0 = targetletter, targetalert]
/ inputdevice = mouse
/ isvalidresponse = [
    trial.target.response == 80 || trial.target.response == 0
]
/ validresponse = (anyresponse)
/ iscorrectresponse = [
    trial.target.response == 80
]
/ ontrialbegin = [
    trial.target.insertstimulustime(clearscreen, parameters.stimulusPresentationtime);
    if (values.N > 0) {
        values.currenttarget = list.items.item(values.N);
    };
    values.trial_Hit = 0;
    values.trial_Miss = 0;
    values.trial_CR = 0;
    values.trial_FA = 0;
]

/ ontrialend = [
    trial.target.resetstimulusframes();
    list.items.insertitem(text.targetletter.currentitemnumber, 1);
    values.Hits = values.Hits+ trial.target.correct;
    values.trial_Hit = trial.target.correct;
    values.Misses = values.Misses + trial.target.error;
    values.trial_Miss = trial.target.error;
    values.TotalHits = values.TotalHits + trial.target.correct;
    values.DV = (values.TotalHits - values.TotalFA)/values.TotalBlocks;
]
/ beginresponsetime = 0
/ trialduration = parameters.trialduration
</trial>
                    
**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

ATTENTION: PRACTICE BLOCKS
(1) This block sets the beginning N value for practice trials to the lowest level of N run in the experiment
(2) runs instructions 1-6, for N=0-3, if more/fewer than four N levels are run adjust /trials = [1-X.....]
Example: N=0 to N = 2: / trials = [1-5 = Nbackinstruct_starttrial]

<block Nbackinstruct_start>
/ trials = [1 = touchscreenInstruct; 2-3 = Nbackinstruct_starttrial]
/ recorddata = false
</block>

<block RepeatPractice>
/ trials = [1 = repeatpractice]
/ recorddata = false
/ branch = [
    if (trial.repeatpractice.response == 21) {
        block.practice_s_ntask
    } else
        block.Practiceblock_end;
]
/ screencolor = black
</block>

<block Practiceblock_end>
/ trials = [1 = Practice_endtrial]
/ recorddata = false
</block>

**********************************************
PRACTICE
**********************************************

* Practice Blocks give feedback and do NOT record data
* Block starts with
(a) Instructiontrial
(b) N start-trials that cannot present Targets yet (no data collected) , if N = 0, the first trial presents the target letter
(c) 9 practice trials: ratio targets : nontargets = 1 : 2
* stops after lever N = highestN (set by experimenter)
(d) runs from the lowest N to the highest N

<block practice_s_ntask>
/ onblockbegin = [
    values.N = list.nextN_practice.nextvalue;
    values.currenttarget = 0;
    values.currenttarget = 0;
    list.items.reset();
    values.TotalBlocks += 1;
    values.starttrialcounter = 0;
    values.Hits = 0;
    values.FalseA = 0;
    values.Misses = 0;
    values.CorrReject = 0;
]
/ trials = [1 = expinstructiontrial; 2 = start; 3 - 11 = noreplace(nontarget, nontarget, target)]
/ onblockend = [
    values.TotalHits = 0;
    values.TotalFA = 0;
    values.DV = 0
]
/ screencolor = (0, 0, 0)
/ recorddata = false
/ postinstructions = (BlockSummary_practice)
/ branch = [
    if (values.TotalBlocks < list.nextN_practice.itemcount) {
        values.TotalBlocks = 0;
        block.RepeatPractice;
    } else {
        block.practice_s_ntask;
    };
]    
</block>

if trial feedback is desired:
/ errormessage = true(ErrorFeedback, 500)
/ correctmessage = true(CorrectFeedback, 500)

**********************************************
EXPERIMENTAL-BLOCKS NONADAPTIVE
**********************************************

<block StartExp>
/ trials = [1 = StartExp_trial]
/ recorddata = false
/ onblockbegin = [
    values.TotalHits = 0;
    values.TotalFA = 0;
    values.TotalBlocks = 0;
    values.DV = 0;
]
</block>

* Block starts with
(a) Instructiontrial
(b) N start-trials that cannot present Targets yet
(c) 15 Experimental trials
* Experimental trials: ratio targets : nontargets = 1 : 2
* N level is pseudo-randomly selected by list.Nlevel
* Block runs as many times as there are items in list.Nlevel

<block s_ntask>
/ onblockbegin = [
    values.N = list.Nlevel.nextvalue;
    values.currenttarget = 0;
    list.items.reset();
    values.lastIndex = 1;
    expressions.fillitemlist;
    values.Hits = 0;
    values.FalseA = 0;
    values.Misses = 0;
    values.CorrReject = 0;
    values.TotalBlocks += 1;
    values.starttrialcounter = 0;
]
/ trials = [1 = start; 2 - 72 = noreplace(nontarget, nontarget, target)]
/ screencolor = (0, 0, 0)
/ branch = [
    if (values.TotalBlocks < list.Nlevel.itemcount) {
        block.s_ntask;
    } else {
        block.EndExp;
    };
]
</block>

<block EndExp>
/ trials = [1 = EndExp_trial]
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************

*After running the initial instructions, participants work through practice blocks for N = lowestN to N = highestN
* After practice, participants work through 3 blocks for each of the level of N (levels are pseudorandomly determined)

<expt>
/ onexptbegin = [
    if (parameters.debugmode == 1)
        text.targetalert.textcolor = red
]
/ blocks = [
    1 = Nbackinstruct_start;
    2 = StartExp;
    3 = s_ntask;
]
/ onexptend = [values.completed = 1]
</expt>

**************************************************************************************************************
                                                End of File
**************************************************************************************************************

All your /isvalidresponse attributes are wrong for mouse or touch input, they invalidate any response you make with the mouse (or by tapping on the screen). Same for some of the /iscorectresponse attributes. "80" is not something a mouse click or tap results in.

<trial touchscreenInstruct>
/ skip = [
  !computer.touch || computer.haskeyboard;
]
/ stimulusframes = [1 = touchscreenInstruct1, touchscreenInstruct2]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
  trial.touchscreenInstruct.response == 80
]

/ recorddata = false
</trial>

<trial expinstructiontrial>
/ stimulusframes = [1 = expinstructionslide]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
  trial.expinstructiontrial.response == 80
]

/ recorddata = false
</trial>

<trial Nbackinstruct_starttrial>
/ stimulusframes = [1 = SingleNbackinstructions_start]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
  trial.Nbackinstruct_starttrial.response == 80
]

/ recorddata = false
</trial>

<trial Practice_endtrial>
/ stimulusframes = [1 = Practice_end]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
  trial.Practice_endtrial.response == 80
]

/ recorddata = false
</trial>

<trial StartExp_trial>
/ stimulusframes = [1 = StartExp_slide]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
  trial.StartExp_trial.response == 80
]

/ recorddata = false
</trial>

<trial repeatpractice>
/ stimulusframes = [1 = repeatpractice_page]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
  trial.repeatpractice.response == 80
]

/ recorddata = false
</trial>

<trial EndExp_trial>
/ stimulusframes = [1 = EndExp_slide]
/ inputdevice = mouse
/ validresponse = (anyresponse)
/ isvalidresponse = [
  trial.EndExp_trial.response == 80
]

/ recorddata = false
</trial>

etc.
Edited Last Month by Dave
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search