Random order of stimulus times


Author
Message
Jeff
Jeff
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 49, Visits: 123

Hello all.  I have a 4-choice multiple choice task.  The pictures for each of the quadrants are listed in 4 separate item elements (Pic1-Pic4).  I then have 4 picture elements that call the items from these lists, and using two counters, I randomly put each one into a quadrant on the screen using the HPosition and Vposition attributes of the picture elements.  This worked great when all 4 pictures were presented simultaneously.


Now I'm modifying the task so that each picture will be presented sequentially with an audio label, but I don't know how to randomly select the order in which the pictures and sounds will be presented.  Right now, it's coded that stimuli are always presented in the same order, like so:




/ stimulustimes = [1=diamond, line_LF, line_RT, line_Top, line_Bottom;


  500 = Pic_A_pic;


  800 = Label_A_snd;


2000 = Pic_B_pic;


2300 = Label_B_snd;


3500 = Pic_C_pic;


3800 = Label_C_snd;


5000 = Pic_D_pic;


5300 = Label_D_snd;


6500 = point_to_the_letter_snd;


7500 = prompt_snd]




I've tried using counters to use in place of the stimulus times and a counter to randomly select the picture items in the picture element, but neither strategy has worked.  Any suggestions?



Jeff


Attachments
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: 98K

The solution is to consider the various timepoints as generic slots and randomly assign items to those slots via conditional logic:


<values>
/ slot01 = ""
/ slot02 = ""
/ slot03 = ""
/ slot04 = ""
</values>

<block myblock>
/ trials = [1-2=mytrial]
</block>

<trial mytrial>
/ ontrialbegin = [values.slot01=counter.slotorder.selectedvalue;
    values.slot02=counter.slotorder.selectedvalue;
    values.slot03=counter.slotorder.selectedvalue;
    values.slot04=counter.slotorder.selectedvalue;]
/ ontrialbegin = [if(values.slot01=="a")text.slot01.item.1=getitem(item.a, counter.acounter.selectedvalue);
    if(values.slot01=="b")text.slot01.item.1=getitem(item.b, counter.bcounter.selectedvalue);
    if(values.slot01=="c")text.slot01.item.1=getitem(item.c, counter.ccounter.selectedvalue);
    if(values.slot01=="d")text.slot01.item.1=getitem(item.d, counter.dcounter.selectedvalue);]
/ ontrialbegin = [if(values.slot02=="a")text.slot02.item.1=getitem(item.a, counter.acounter.selectedvalue);
    if(values.slot02=="b")text.slot02.item.1=getitem(item.b, counter.bcounter.selectedvalue);
    if(values.slot02=="c")text.slot02.item.1=getitem(item.c, counter.ccounter.selectedvalue);
    if(values.slot02=="d")text.slot02.item.1=getitem(item.d, counter.dcounter.selectedvalue);]
/ ontrialbegin = [if(values.slot03=="a")text.slot03.item.1=getitem(item.a, counter.acounter.selectedvalue);
    if(values.slot03=="b")text.slot03.item.1=getitem(item.b, counter.bcounter.selectedvalue);
    if(values.slot03=="c")text.slot03.item.1=getitem(item.c, counter.ccounter.selectedvalue);
    if(values.slot03=="d")text.slot03.item.1=getitem(item.d, counter.dcounter.selectedvalue);]
/ ontrialbegin = [if(values.slot04=="a")text.slot04.item.1=getitem(item.a, counter.acounter.selectedvalue);
    if(values.slot04=="b")text.slot04.item.1=getitem(item.b, counter.bcounter.selectedvalue);
    if(values.slot04=="c")text.slot04.item.1=getitem(item.c, counter.ccounter.selectedvalue);
    if(values.slot04=="d")text.slot04.item.1=getitem(item.d, counter.dcounter.selectedvalue);]
/ stimulustimes = [0=slot01; 500=slot02; 1000=slot03; 1500=slot04]
/ validresponse = (57)
</trial>

<counter slotorder>
/ items = ("a", "b", "c", "d")
/ select = noreplace
/ selectionrate = always
</counter>

<text slot01>
/ items = (" ")
</text>

<text slot02>
/ items = (" ")
</text>

<text slot03>
/ items = (" ")
</text>

<text slot04>
/ items = (" ")
</text>

<counter acounter>
/ select = noreplace(1-2)
</counter>

<counter bcounter>
/ select = noreplace(1-2)
</counter>

<counter ccounter>
/ select = noreplace(1-2)
</counter>

<counter dcounter>
/ select = noreplace(1-2)
</counter>

<item a>
/ 1 = "A1"
/ 2 = "A2"
</item>

<item b>
/ 1 = "B1"
/ 2 = "B2"
</item>

<item c>
/ 1 = "C1"
/ 2 = "C2"
</item>

<item d>
/ 1 = "D1"
/ 2 = "D2"
</item>


Regards,


~Dave


Jeff
Jeff
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 49, Visits: 123

Thanks, Dave.  This is working half-perfectly.  I am using pictures and sounds, and this code is working perfectly for the pictures, but something is going wrong with the sounds.  I initially set the picture elements to "blank.jpg" and the sound elements to "silence.wav".  In the trial element, I follow your strategy and randomly select a set of stimuli for each quadrant from the counter "Position".  I then assign the picture and sound based on the random position.  It's strange...the sounds that plays is always the initial sound set at the beginning (i.e., silence or a test sound), but my debug code shows the current sound item to be the correctly assigned filename.  Is there something different with the way that sounds are processed that I am not aware of?



Create dummy picture and sound elements for each quadrant (Upper Left shown here)


<picture Pic_UL_pic>


/ items = ("BLANK.JPG")


/ position = (25, 25)


/ size = (20%, 20%)


</picture>


 <sound Label_UL_snd>


/ items = ("silence.wav")


</sound>


 Assign random positions



   / ontrialbegin = [values.UL = counter.position.selectedvalue;


                    values.UR = counter.position.selectedvalue;


                    values.LL = counter.position.selectedvalue;


                    values.LR = counter.position.selectedvalue]


Assign picture for Upper Left quadrant


   / ontrialbegin = [if(values.UL=="A") values.correct_pic=="Pic_UL_pic"; 


                        if(values.UL=="A") picture.Pic_UL_pic.item.1=getitem(item.Pic_A, values.Item_index);


                        if(values.UL=="B") picture.Pic_UL_pic.item.1=getitem(item.Pic_B, values.Item_index);


                        if(values.UL=="C") picture.Pic_UL_pic.item.1=getitem(item.Pic_C, values.Item_index);


                      if(values.UL=="D") picture.Pic_UL_pic.item.1=getitem(item.Pic_D, values.Item_index)]


Assign sound for Upper Left quadrant


/ ontrialbegin = [if(values.UL=="A") Sound.Label_UL_snd.item.1=getitem(item.Label_A, values.Item_index);


                        if(values.UL=="B") Sound.Label_UL_snd.item.1=getitem(item.Label_B, values.Item_index);


                        if(values.UL=="C") Sound.Label_UL_snd.item.1=getitem(item.Label_C, values.Item_index);


                      if(values.UL=="D") Sound.Label_UL_snd.item.1=getitem(item.Label_D, values.Item_index)]



The full code is attached.  


Thanks,

Jeff



Attachments
EBLMC Random stimulus times demo.exp (915 views, 37.00 KB)
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: 98K

See the attached file for a working example outlining how to work around the limitations with the <sound> element.


Hope this helps,


~Dave


Attachments
Example.zip (602 views, 83.00 KB)
Jeff
Jeff
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 49, Visits: 123

I'm afraid it doesn't.  The program crashes now. I'm guessing that it's because the sound element isn't being updated, and since I've cleared it, there is no longer any sound file to play when it is called in the stimulustimes property.


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: 98K

Note that the example referenced earlier uses the <video> element, not <sound>. If you can run the example script (which works for me without any crashing), you can apply the same logic / modifications to your existing script.


Jeff
Jeff
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 49, Visits: 123

My bad.  I thought you wanted me to adapt the code for sound elements, not the other way around.  Anyway, it works fine with the video element.  Thanks! There is one thing that I discovered, though, that I don't understand.  My assignment statements for the picture elements use picture.picture_UL_pic.item.1, but the video element only works when I use video.video_UL_snd.item (without .1).  What does the ".1" tell Inquisit, and why are they different between the two element types?



Finally, now that it works, I need to be able to refer to which picture is correct in the correctresponse attribute.  I've tried using a value to keep track of the correct element (the correct response is always in the "A" list): 



   / ontrialbegin = [if(values.UL=="A") values.correct_pic="Pic_UL_pic"; 


                            if(values.UR=="A") values.correct_pic="Pic_UR_pic"; 


                            if(values.LL=="A") values.correct_pic="Pic_LL_pic"; 


                            if(values.LR=="A") values.correct_pic="Pic_LR_pic"]



But when I try to refer to the value in the correctresponse attribute, it doesn't like it, presumably because it needs an element name:


/ correctresponse = (values.correct_pic)


/ correctresponse = (<%values.correct_pic%>)



Thanks,

Jeff



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: 98K

What does the ".1" tell Inquisit, and why are they different between the two element types?


They're not different between the two elements (or any other elements), they apply to any of them. The difference is this:


'text.mytext.item.1=...' tells Inquisit to set the first item in the given element to the given value. This only works if there actually *is* an item.1 at the point of the re-assignment. Otherwise, i.g., if the element is empty / doesn't contain any items (due to e.g. clear()), it will fail.


'text.mytext.item=...' tells Inquisit to add an item to the given element. If the element is empty (as after invoking clear()), the item's index will be 1.


But when I try to refer to the value in the correctresponse attribute, it doesn't like it, presumably because it needs an element name:


/correctresponse is the wrong attribute to use in this case. You'll have to define /iscorrectresponse instead, which handles dynamically defined responses:


/ iscorrectresponse = [trial.mytrial.response == ...]


Regards,


~Dave



Jeff
Jeff
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 49, Visits: 123

Darn it...I knew that answer!




Thanks for the clarification about the .1.  Makes sense.


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search