Millisecond Forums

Script Error

https://forums.millisecond.com/Topic17890.aspx

By Tannie Davis - 12/3/2015

Hello,

I am currently using Inquisit to design a n-back task. I used a pre-written script to save some time, but I made some edits to the script. However, now when I try to run the script, I keep getting an error and I cannot figure out what I am doing wrong. It may have to do with the changes I tried to make: basically, I tried to remove a trial, but I think there is some place in the code where I did not remove a section that I should have...I will paste the written code below and also the error code so you can see what I am talking about. I don't have much experience with coding, and I am trying my best to learn, so please make your advice as simplistic as possible. Thank you so much in advance!
Error Code: Unable to initialize <picture expinstructionslide> item number 4. Verify the item exists and is correctly defined.
Script: 


Single n-back tasks:
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.


Specific Procedural Information
(1) Single n-back letter EXPERIMENT information:
- 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 values.instruction_duration

(2) Single n-back 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

(3) Single n-back 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.

*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)
************************************************************************************************************************************************************************

************************************************************************************************************************************************************************
INFORMATION FOR CODE-CHANGES (e.g. Adding/Removing levels of N)

Instructions for changing code for different levels of Ns are provided with this script. Please check the following sections for the relevant info:
1. Values
2. Lists
3. Instructions: (a) Instruction Slides (b) Instruction Blocks
4. Trials
5. Blocks
************************************************************************************************************************************************************************

************************************************************************************************************************************************************************
DEFAULTS

requires Inquisit 4.0.0.0 or greater

<defaults>
/minimumversion = "4.0.0.0"

/ screencolor = black
</defaults>
/canvasaspectratio = (4,3)

************************************************************************************************************************************************************************

************************************************************************************************************************************************************************
CUSTOM VALUES

******************
editable by experimenter: (changes need to be made under values below)
******************
trialduration:Interstimulusinterval for regular n-back trials, default = 2500ms,
posttrialpause_aftertarget0:the posttrialpause 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, default = 9000ms
only applies if instructions for experimental blocks are NOT self-paced
(see INSTRUCTIONS -> INSTRUCTION TRIALS -> trial.expinstructiontrial for further info)
the default for this script are self-paced instructions
highestN:default N = 3
lowestN:default N = 0
debugmode = 0debugmode = 1: targetalerts are shown on screen,
debugmode = 0, no targetalerts are shown (default)


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

<values >
/trialduration = 2500
/posttrialpause_aftertarget0 = 2000
/instruction_duration = 9000
/highestN = 3
/lowestN = 0
/showtarget0 = 3000
/debugmode = 0
</values>



******************
updated automatically during runtime:
******************
/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)


<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
</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>
************************************************************************************************************************************************************************

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


*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, set /select = 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 = (0,0,0,1,1,1,2,2,2)
/ replace = false
</list>


****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>
************************************************************************************************************************************************************************

************************************************************************************************************************************************************************
DATA COLLECTION

this implementation suggests to collect the following information:
date:Date of Experiment
time:Time of Day
subject:Subjectnumber
values.N:the type of N-back trial
blockcode:the name of the current block
values.TotalBlocks:the total number of experimental blocks run
trialcode:the name of the current trial
stimulusitem:the file of the stimulus shown during a trial
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
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


*********************
raw data
*********************
<data>
/file = "SingleTaskNBack_letters_rawdata.iqdat"
/columns = [date, time, subject, values.N, blockcode, values.TotalBlocks, trialcode, trialnum, stimulusitem,
values.currenttarget, response, correct, latency,
values.Hits, values.FalseA, values.Misses, values.CorrReject,
values.TotalHits, values.TotalFA, values.DV]
/ separatefiles = true
</data>

*********************
summary data
*********************
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)
/completed:0 = script was not completed (script was 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


<summarydata >
/file = "SingleTaskNBack_letters_summary.iqdat"
/columns = [script.startdate, script.starttime, script.subjectid, script.groupid, script.elapsedtime, values.completed,
values.TotalHits, values.TotalFA, values.DV]
</summarydata>

************************************************************************************************************************************************************************

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

***********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 = "Slide1.gif"
/2 = "Slide2.gif"
/3 = "Slide3.gif"
/4 = "Slide4.gif"
/5 = "Slide5.gif"
/6 = "Slide6.gif"
/7 = "Slide7.gif"
</item>
*********************************************************
Alternative if only N=0 - N=2 is run
-> "SingleNbackInstructions_letters_practice012.gif"
*********************************************************


<item practiceend>
/1 = "Slide8.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 experimental N-levels (not original)
<item expinstructions>
/1 = "Slide9.gif"
/2 = "Slide10.gif"
/3 = "Slide11.gif"
</item>

*******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"


***********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 = values.N+1
/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 = (values.instruction_duration)
****************************************************************************************
<trial expinstructiontrial>
/ stimulusframes = [1 = expinstructionslide]
/ validresponse = (57)

/ recorddata = false
</trial>

<trial Nbackinstruct_starttrial>
/ stimulusframes = [1 = SingleNbackinstructions_start]
/ validresponse = (57)
/ recorddata = false
</trial>

<trial Practice_endtrial>
/ stimulusframes = [1 = Practice_end]
/ validresponse = (57)
/ recorddata = false
</trial>

<trial StartExp_trial>
/ stimulusframes = [1 = StartExp_slide]
/ validresponse = (57)
/ recorddata = false
</trial>

<trial repeatpractice>
/ stimulusframes = [1 = repeatpractice_page]
/ validresponse = (49, 21)
/ recorddata = false
</trial>

<trial EndExp_trial>
/ stimulusframes = [1 = EndExp_slide]
/ validresponse = (57)
/ recorddata = false
</trial>

*************INSTRUCTION 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-5 = Nbackinstruct_starttrial]
/ recorddata = false
/ onblockbegin = [values.N = values.lowestN]
</block>

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

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

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


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


************************************************************************************************************************************************************************

************************************************************************************************************************************************************************
SUMMARY PAGES

*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 = (255, 255, 255)
/ screencolor = (0, 0, 0)
/ windowsize = (70%, 60%)
</instruct>


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

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

************************************************************************************************************************************************************************
LETTER ITEMS

* 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>

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

***selects any letter that cannot be a target
<text nontargetletter>
/ items = letters
/select = notargetvalue
/ position = (50%, 50%)
/ txcolor = (white)
/ txbgcolor = (black)
/ fontstyle = ("Arial", 20%, 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", 20%, 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 = (255, 0, 0)
/ txbgcolor = (0, 0, 0)
/ position = (50%, 70%)
</text>

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

************************************************************************************************************************************************************************

************************************************************************************************************************************************************************
ASSISTANT STIMULI

*****acts as an eraser after showing the key stimuli for 500ms, staying on for the remainder of the trial
<shape eraser>
/ shape = rectangle
/ size = (100%, 100%)
/ color = (0, 0, 0)
</shape>

*****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 <%values.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>
************************************************************************************************************************************************************************

************************************************************************************************************************************************************************
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;
shape.eraser.color = transparent;
values.trialduration_starttrial = values.showtarget0;
values.starttrialposttrialpause = values.posttrialpause_aftertarget0}
else
{values.trialduration_starttrial = values.trialduration;
values.starttrialposttrialpause = 0}]

/ stimulustimes = [0 = startletter, targetreminder; 500 = eraser]
/ validresponse = (noresponse, 30)
/ correctresponse = (noresponse)
/ responsetime = 0
/ ontrialbegin = [
{if (values.N == 1) values.currenttarget = values.minus1};
{if (values.N == 2) values.currenttarget = values.minus2};
{if (values.N == 3) values.currenttarget = values.minus3};
values.starttrialcounter += 1;
]
/ ontrialend = [
{if (values.N == 0) values.currenttarget = text.startletter.currentitemnumber};
values.minus4 = values.minus3;
values.minus3 = values.minus2;
values.minus2 = values.minus1;
values.minus1 = text.startletter.currentitemnumber
]

/ ontrialend = [text.targetreminder.textcolor = black; shape.eraser.color = black]
/trialduration = values.trialduration_starttrial
/ posttrialpause = (values.starttrialposttrialpause)
/branch = [if (values.starttrialcounter < values.N) trial.start]
</trial>

**********************************
Nontarget Trials
**********************************
<trial nontarget>
/ stimulustimes = [0 = nontargetletter; 500 = eraser]
/validresponse = (noresponse, 30)
/ correctresponse = (noresponse)
/ ontrialbegin = [
{if (values.N == 1) values.currenttarget = values.minus1};
{if (values.N == 2) values.currenttarget = values.minus2};
{if (values.N == 3) values.currenttarget = values.minus3};

]

/ ontrialend = [
values.minus4 = values.minus3;
values.minus3 = values.minus2;
values.minus2 = values.minus1;
values.minus1 = text.nontargetletter.currentitemnumber;
values.CorrReject = values.CorrReject + trial.nontarget.correct;
values.FalseA = values.FalseA + trial.nontarget.error;
values.TotalFA = values.TotalFA + trial.nontarget.error;
values.DV = (values.TotalHits - values.TotalFA)/values.TotalBlocks;

]
/ responsetime = 0
/ trialduration = values.trialduration
</trial>

**********************************
Target Trials
**********************************
**if target, press the letter "A" (code: 57)
<trial target>
/ stimulustimes = [0 = targetletter, targetalert; 500 = eraser]
/validresponse = (noresponse, 57)
/ correctresponse = (57)
/ ontrialbegin = [
{if (values.N == 1) values.currenttarget = values.minus1};
{if (values.N == 2) values.currenttarget = values.minus2};
{if (values.N == 3) values.currenttarget = values.minus3};
  ]

/ ontrialend = [
values.minus4 = values.minus3;
values.minus3 = values.minus2;
values.minus2 = values.minus1;
values.minus1 = text.targetletter.currentitemnumber;
values.Hits = values.Hits+ trial.target.correct;
values.Misses = values.Misses + trial.target.error;
values.TotalHits = values.TotalHits + trial.target.correct;
values.DV = (values.TotalHits - values.TotalFA)/values.TotalBlocks;
]
/ responsetime = 0
/ trialduration = values.trialduration
</trial>

********************************ADDITIONAL N-LEVELS*****************************************************

For each trial type:
(1) add {if (values.N == X) values.currenttarget = values.minusX};, e.g. N = 5
/ ontrialbegin = [
.....
{if (values.N == 1) values.currenttarget = values.minus1};
{if (values.N == 2) values.currenttarget = values.minus2};
{if (values.N == 3) values.currenttarget = values.minus3};
{if (values.N == 4) values.currenttarget = values.minus4};
=>{if (values.N == 5) values.currenttarget = values.minus5};
]
(2) add values.minusX = values.minus(X-1) e.g. N = 5 - largest N goes on top of the list
/ ontrialend = [
=>values.minus5 = values.minus4;
values.minus4 = values.minus3;
values.minus3 = values.minus2;
values.minus2 = values.minus1;
values.minus1 = picture.targetshape.currentitemnumber;
....
]

************************************************************************************************************************************************************************

************************************************************************************************************************************************************************
PRACTICE-BLOCKS

* 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.currenttarget = 0; values.minus1 = 0; values.minus2 = 0; values.minus3 = 0;
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.N < values.highestN) { values.N += 1; block.practice_s_ntask}
else {values.TotalBlocks = 0; block.RepeatPractice}]
</block>

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

************************************************************************************************************************************************************************

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


* 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]
/ onblockbegin = [
values.currenttarget = 0; values.minus1 = 0; values.minus2 = 0; values.minus3 = 0; values.minus4 = 0;
values.Hits = 0; values.FalseA = 0; values.Misses = 0; values.CorrReject = 0;
values.TotalBlocks += 1;
values.starttrialcounter = 0;
]
/ trials = [1 = expinstructiontrial; 2 = start; 3 - 17 = noreplace(nontarget, nontarget, target)]
/ screencolor = (0, 0, 0)

/ branch = [if (values.TotalBlocks < list.Nlevel.itemcount) block.s_ntask
else block.EndExp]
</block>
***********************************************ADDITIONAL N-LEVELS********************************************************
(1) add values.minusX = 0 to
/ onblockbegin = [
values.currenttarget = 0; values.minus1 = 0; values.minus2 = 0; values.minus3 = 0; values.minus4 = 0;
.....
]

Example: N = 5
/ onblockbegin = [
values.currenttarget = 0; values.minus1 = 0; values.minus2 = 0; values.minus3 = 0; values.minus4 = 0;
values.minus5 = 0;
.....
]

************************************************************************************************************************************************************************

************************************************************************************************************************************************************************
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 (values.debugmode == 1) text.targetalert.textcolor = (red)]
/ blocks = [
1 = Nbackinstruct_start;
2 = practice_s_ntask;
3 = StartExp;
4 = s_ntask
]
/onexptend = [values.completed = 1]
</expt>
************************************************************************************************************************************************************************
End of Script
************************************************************************************************************************************************************************




 
By Dave - 12/3/2015

> I made some edits to the script.

In the future, please take the time to actually describe the edits you made and why. When you just post some code without any explanation, it can be difficult or even impossible to determine why a given edit was made, whether it was deliberate / what it was intended to achieve, etc. And if possible, please do not paste entire scripts into a post's body. Instead use the forum's file attachment facilities to attach the actual script file as well as all the other files your script requires to run. Put them all in a ZIP archive an click on +Insert -> Add File to attach the ZIP to a post.

> Error Code: Unable to initialize <picture expinstructionslide> item number 4. Verify the item exists and is correctly defined.

The error tells you is that your script expects to find a 4th item in <picture expinstructionslide>, for which there are only 3 items specified.

<item expinstructions>
/1 = "Slide9.gif"
/2 = "Slide10.gif"
/3 = "Slide11.gif"
</item>

Items in that element are selected according to values.N

<picture expinstructionslide>
/items = expinstructions
/select = values.N+1
/size = (100%, 100%)
</picture>

i.e., if the N-level is 0, the 1st item is selected. If the N-level is 1, the 2nd item is selected and so forth.

From that you can determine that the problem is that at some point values.N is set to 3 and the <picture> element tries to select a non-existing 4th item. Here's where that happens:

* 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 level N = highestN (set by experimenter)
(d) runs from the lowest N to the highest N

<block practice_s_ntask>
...
/ branch = [if (values.N < values.highestN) { values.N += 1; block.practice_s_ntask}
else {values.TotalBlocks = 0; block.RepeatPractice}]
</block>

Now, if you look at what you specified values.highestN to be, you'll find that it's set to 3, which is not what you want:

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

<values >
/trialduration = 2500
/posttrialpause_aftertarget0 = 2000
/instruction_duration = 9000
/highestN = 3
/lowestN = 0
/showtarget0 = 3000
/debugmode = 0
</values>

You'll want to set that value to 2, which is the actual highest N-level you want to administer.
By Tannie Davis - 12/5/2015

Thank you very much, this worked like a charm.

And I will be sure to follow those formatting instructions in the future, thank you again!