Millisecond Forums

Skipping an item per trial when previous trial last value & next trial first value are equal (during a Letter Memory Task)

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

By WarrenL - 6/23/2014

Hi again,

I've got an issue with a Letter memory task (whereby random letters are presented individually on screen and a participant has to repeat the letters aurally). The letters are selected from a pool without replacement and without repeating per trial. However, the problem I have is that the last letter presented in from any previous trial (e.g. Trial x) cannot be the first letter presented in the following trial (trial y). 


I've been trying to write a few expressions that will check for whether the previous-consecutive letter is the same but cannot figure out how to indicate to either ignore the corresponding letter during a trial completely, or to select another letter in the item set as the first letter of that trial (either would be fine). I've tried using expressions such as 

e.g [if(list.letters.nextvalue==list.letters.currentvalue)]0

but cannot think of a way for the script to do either of the above - I tried list.itemlist.removeitem but that it appeared to interference with the random/no replace setting


The script is below; I've made the stimulustimes, timeout and posttrialpause as 1ms so it is easier for testing. Any help would be great - thanking you in advance again.

<defaults>
/ screencolor = white
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 0)
/ txcolor = black
/ inputdevice = keyboard
</defaults>


<data>
/file = "LM_testing.iqdat"
/separatefiles = true
/ columns = [date time subject stimulus trialcode trialnum blockcode blocknum values.nextitemindex values.itemnumber values.itemremove]
</data>


<values>
/nextitemindex = 0
/itemnumber = 0
/itemremove = 0
</values>


<text digit1>
/items = letters
/select = list.itemlist.nextvalue
/ txcolor = black
</text>

<text digit2>   
/items = letters
/select = list.itemlist.nextvalue
/ txcolor = black
</text>

<text digit3>
/items = letters
/select = list.itemlist.nextvalue
/ txcolor = black
</text>

<text digit4>
/items = letters
/select = list.itemlist.nextvalue
/ txcolor = black
</text>

<text digit5>
/items = letters
/select = list.itemlist.nextvalue
/ txcolor = black
</text>

<item letters>
/1 = "A"
/2 = "B"
/3 = "C"
/4 = "D"
/5 = "E"
/6 = "F"
/7 = "G"
/8 = "H"
</item>



<list itemlist>
/ items = (1,2,3,4,5,6,7,8)
/ selectionmode = random
/ replace = false
</list>

<trial letter1>
/ stimulustimes = [1=digit1; 2=digit2;3=digit3;4=digit4;5=digit5]
/ timeout = 1
/ ontrialend = [values.nextitemindex = (list.itemlist.nextindex); values.itemnumber = (list.itemlist.currentvalue);] 
/ posttrialpause = 1

</trial>

<block sequence5>
/ trials = [1-5=letter1] 
</block>

<expt>
/ blocks = [1-15=noreplace(sequence5)]
</expt>



By Dave - 6/23/2014

A little recursive expression would be in order here:

<defaults>
/ screencolor = white
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 0)
/ txcolor = black
/ inputdevice = keyboard
</defaults>

<data>
/file = "LM_testing.iqdat"
/separatefiles = true
/ columns = [date time subject stimulus trialcode trialnum blockcode blocknum]
</data>

<values>
/ d1itemnumber = 0
</values>

<text digit1>
/ items = letters
/ select = values.d1itemnumber
/ txcolor = black
</text>

<item letters>
/1 = "A"
/2 = "B"
/3 = "C"
/4 = "D"
/5 = "E"
/6 = "F"
/7 = "G"
/8 = "H"
</item>

<list itemlist>
/ items = (1,2,3,4,5,6,7,8)
/ selectionmode = random
/ replace = false
</list>

<expressions>
/ myexpression = if (list.itemlist.nextvalue==values.d1itemnumber) {list.itemlist.reset(); expressions.myexpression} else values.d1itemnumber=list.itemlist.nextvalue
</expressions>

<trial letter1>
/ ontrialbegin = [expressions.myexpression]
/ stimulustimes = [1=digit1]
/ timeout = 100
/ posttrialpause = 0
</trial>

<block sequence5>
/ onblockbegin = [list.itemlist.reset();]
/ trials = [1-5=letter1]
</block>

<expt>
/ blocks = [1-15=sequence5]
</expt>
By WarrenL - 6/24/2014

Thanks for your speedy reply once again Dave,

Unfortunately I ran the script and it appears to repeat letters between trial 5 of block 1 and trial 1 of block 2, and also within blocks on occasion (see attached, block 2). Is this possibly due to the recursive expression resetting the currentvalue? I put in a values.d1itemnumber column in the data and it appears as empty which leads me to think that if an identical letter is detected and the expression is rerun, then the d1itemnumber is then blank?

Again, thanks for all your assistance - its superb.


By Dave - 6/24/2014

Thanks for the report -- that was my stupid mistake, sorry about that. Does the (actually simpler)

<defaults>
/ screencolor = white
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 0)
/ txcolor = black
/ inputdevice = keyboard
</defaults>

<data>
/file = "LM_testing.iqdat"
/separatefiles = true
/ columns = [date time subject stimulus trialcode trialnum blockcode blocknum values.d1itemnumber]
</data>

<values>
/ d1itemnumber = 0
</values>

<text digit1>
/ items = letters
/ select = values.d1itemnumber
/ txcolor = black
</text>

<item letters>
/1 = "A"
/2 = "B"
/3 = "C"
/4 = "D"
/5 = "E"
/6 = "F"
/7 = "G"
/8 = "H"
</item>

<list itemlist>
/ items = (1,2,3,4,5,6,7,8)
/ selectionmode = random
/ replace = false
/ not = (values.d1itemnumber)
</list>

<trial letter1>
/ ontrialbegin = [values.d1itemnumber=list.itemlist.nextvalue]
/ stimulustimes = [1=digit1]
/ timeout = 100
/ posttrialpause = 0
</trial>

<block sequence5>
/ onblockbegin = [list.itemlist.reset();]
/ trials = [1-5=letter1]
</block>

<expt>
/ blocks = [1-15=sequence5]
</expt>

do the trick?
By WarrenL - 6/25/2014

Thanks Dave - it looks to do just the job, nice and neat too like you said! Thanks once more for your excellent troubleshooting

Cheers
Warren