Millisecond Forums

Positioning of random images & Using a conditional expression in /trialduration... & more.

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

By aya - 10/16/2011

Hello, I am doing an experiment that involves presenting 4 images on each trial. I would like to present the images in a 2 x 2 square, but have the images randomized to a position every time the experiment is run.


For example, if I had images 1, 2, 3, and 4: 


Participant 1, Trial 1 sees this:


1 3


4 2


Participant 2, Trial 1 sees this:


2 4


1 3


I hope that makes sense. 


 I understand that you can randomize the images in trials, but that's only if you want to present them in a row or a column. Is that correct?


Also, in the /trialduration property of <trial>, I would like to set a number of milliseconds only if a certain constraint is satisfied, i.e. /trialduration = [if (values.timer==1) 90000 else 99999999]. I thought this would work as the if statement would return an integer. I really wish this worked...


Lastly, I would like to redirect my participants to a survey website after the experiment, but pass along their subject ID to the URL. Kinda like what was going on here. But how do I access that subject number? Is it unique for every participant?


Any help would be greatly appreciated.



 Thanks!

By Dave - 10/16/2011

I would like to present the images in a 2 x 2 square, but have the images randomized to a position every time the experiment is run


See e.g. https://www.millisecond.com/forums/Topic5501.aspx for hints.


Also, in the /trialduration property of <trial>, I would like to set a number of milliseconds only if a certain constraint is satisfied, i.e. /trialduration = [if (values.timer==1) 90000 else 99999999]. I thought this would work as the if statement would return an integer. I really wish this worked...


It does work. Correct syntax is


<trial mytrial>
[...]
/ trialduration = if (values.timer==1) 900 else 9999
</trial>


Lastly, I would like to redirect my participants to a survey website after the experiment, but pass along their subject ID to the URL. Kinda like what was going on here. But how do I access that subject number? Is it unique for every participant?


You can't access the subject id. The method is to *always* start with the survey application (even if you're only showing some kind of introductory page), use the survey app's unique subject identifier, have the survey forward this id to Inquisit as URL parameter, etc. This is covered extensively in the "How to Interoperate Inquisit Web Edition with Online
Survey Packages" topic in the Inquisit documentation.


Regards,


~Dave

By aya - 10/17/2011

Thank you! 


I will read more about how to configure web experiments .


For randomizing the image positions, I decided to make the positions static and the images the ones that would be randomized. Unfortunately, it didn't work. I messed around with the code from the topic you linked to, trying it out with text stimuli. 


I would define a stimuli like so: (there are 4 of them in my code, just showing one) 


<text type2c>


/ items = (counter.picz.selectedvalue)


/ vposition = 60%


/ hposition = 30%


</text>


and the counter like so. In the real experiment I would use image names (it would be fine, right?)




<counter picz>


/ items = ("blorg", "blagh", "bloo", "fjekl")


/ select = noreplace


</counter>


Now when I run the code, nothing shows up. I'm assuming it has to do with counter.picz.selectedvalue. I also tried currentitem, item. But nothing works :/ 

The reason why I'm keeping the positions static is because I need to vary the positions based on the x and y coordinates, which will be trickier to handle...

By Dave - 10/17/2011

The correct syntax to use counters for item selection is


<text type2c>
/ items = (...)
/ vposition = 60%
/ hposition = 30%
/ select = picz
</text>


See the documentation for the /select attribute and the <counter> element for details.


Regards,


~Dave

By aya - 10/18/2011

OK, I updated that piece of code like so: 



<text type1>


/ txcolor = (red)


/ select = picz


/ vposition = 25%


/ hposition = 75%


</text>



and 


the counter like so:



<counter picz>


/ select = sequence(5, 4, 3, 2, 1)


</counter>




type1 object still doesn't show up. :(

By Dave - 10/18/2011

Since your <text> element does not have any items (i.e. no /items attribute), there's nothing it could possibly display.


Regards,


~Dave

By aya - 10/18/2011

But what I want to be randomized is in the counter. (e.g. the numbers 5, 4, 3, 2, 1) If I put something in /items, wouldn't that disregard the numbers in the counter? 


I want to do something like what you did in the other topic:



<counter type2pos>


/ items = (5%,25%,25%,35%,50%,65%,80%,95%)


/ not = (type1pos)


/ select = noreplace


/ selectionrate = always


</counter>


Where the different percentages are being put into the hposition property in <text>. Does /select in <text> not have access to the /items in <counter>? 


Aya

By Dave - 10/18/2011

A <counter> referenced in a stimulus element's (<text>, <picture>, etc.) /select attribute has the purpose of delivering an item's index number, not the actual item. Thus


<text mytext>
/ items = ("a","b","c")
/ select = mycounter
</text>

<counter mycounter>
/ select = sequence(1,2,3)
</counter>


Regards,


~Dave

By aya - 10/18/2011

Ahh that makes a lot more sense now! Thank you very much. 


This would mean I would have to specify the list of images in /item for each <picture>, then, and have to use multiple <counter>s to make sure that each image presented is unique? 

By Dave - 10/18/2011

This would mean I would have to specify the list of images in /item for each <picture>, then, and have to use multiple <counter>s to make sure that each image presented is unique? 


The answer to both is "Not necessarily":


<text left>
/ items = myitems
/ position = (25%,50%)
/ select = mycounter
</text>

<text center>
/ items = myitems
/ position = (50%,50%)
/ select = mycounter
</text>

<text right>
/ items = myitems
/ position = (75%,50%)
/ select = mycounter
</text>

<item myitems>
/ 1 = "A"
/ 2 = "B"
/ 3 = "C"
</item>

<counter mycounter>
/ select = noreplace(1-3)
/ selectionrate = always
</counter>

<trial mytrial>
/ stimulusframes = [1=left, center, right]
/ validresponse = (anyresponse)
</trial>

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


The optimal approach depends on what you ultimately want to do, so plan wisely.


Regards,


~Dave

By aya - 10/18/2011

How do you get your code so nice and formatted? I don't wanna post my entire code and have it be double-spaced and annoying to read. I uploaded my code, if you could please look at it.


Thank you for the advice, I managed to get the randomization of images working! Except now, the script crashes after I make a choice. It doesn't crash when I let it idle and let trialduration go to the next trial. And if I DO let it idle for more than the trials I've specified (I only have 2 trials up right now for a particular block), it will pick another trial from the list, even though I specified noreplacenorepeat. I thought the experiment would have finished. Or will it not finish until a selection has been made? I can view the individual trials in Object Browser, but the selection problem occurs for each one. 



In addition, other blocks are never "chosen"... so far, every time I've run the code, it only gives me the first block.



Thank you very much.


Aya

By Dave - 10/18/2011

How do you get your code so nice and formatted?


See https://www.millisecond.com/forums/Topic4400.aspx#4400.


Except now, the script crashes after I make a choice.


No, it does not crash after making a choice. In the "timer" conditions, you've set each trial to last 90 seconds via /trialduration. So, if you make a choice at, say, 5 seconds into the trial, the script will wait for 85 seconds before starting the next trial. You've told it to do so. Note that trialduration != timeout, see the documentation for those attributes for details. Also see the "How to Control Trial Duration and Inter-Trial
Intervals" topic in the Inquisit documentation.


And if I DO let it idle for more than the trials I've specified (I only have 2 trials up right now for a particular block), it will pick another trial from the list, even though I specified noreplacenorepeat


You are mistaken about how sequence() as in


<block visual>
/ trials = [1-2=sequence(yogurt_01, yogurt_02)]
</block>


works. See https://www.millisecond.com/community/forums/p/1306/4092.aspx#4092. 'noreplacenorepeat' has nothing to do with it.


In addition, other blocks are never "chosen"... so far, every time I've run the code, it only gives me the first block.


Well, again that's how you've set up the script:


<expt>
/ preinstructions = (visualintro, education, timer)
/ postinstructions = (generaloutro)
/ onexptbegin = [values.vis="on"; values.timer="on"; values.edu="on"]
/ blocks = [1=sequence(visual)]
/ subjects = (1 of 8)
</expt>


obviously only runs a single block. The script can't chose another one if you don't tell it to. Additionally see the documentation for the /subjects attribute for details on between-subjects condition assignment based on the numerical subject id. I generally recommend you re-visit the various tutorials contained in the Inquisit helpfile to refresh some basics.


Regards,


~Dave



By aya - 10/18/2011

Thank you, I really appreciate your replies. I will take more time to read up on how these properties work before asking again. It's just that I can't exit after making the choice (with ALT+F4) so I found that weird. And oops, I didn't mean blocks -- I meant conditions (<expt>). I only get the first <expt> which goes through those instruction pages (not all of the <expt> elements go through all of them, or go through different ones). 

By Dave - 10/18/2011

I will take more time to read up on how these properties work before asking again


I'm not trying to scare you from asking further questions. Rather, I'm suggesting that getting to grips with some of Inquisit's basic constructs first will save you a lot of time and effort. The tutorials should provide you with a solid foundation in that regard.


And oops, I didn't mean blocks -- I meant conditions (<expt>). I only get the first <expt> which goes through those instruction pages (not all of the <expt> elements go through all of them, or go through different ones). 


The different <expt> elements are run based on the numerical subject id. See the documentation for the /subjects attribute; see https://www.millisecond.com/forums/Topic4150.aspx#4150 for a more technical description. Case in point: You need to enter different subject numbers if you want to run different <expt>s.


Regards,


~Dave

By aya - 10/19/2011

THANK YOU! I have one more question about my code (which is updated). I also used the timer that you made, I hope that is okay. 


When the participant is in the 60 second condition, I want to make values.60timer "on" and I specify this in the particular <expt> element.  However, it seems that values.30timer also gets switched to "on" as well in this condition, and so the /timeout property automatically goes to values.trial_limit30 (30 sec). The value.timers are all default "off". I don't see where it is being changed to "on" in my code unless the other conditions are getting looked at. 

By Dave - 10/19/2011

/ timeout = (if(values.timer30="on") values.trial_limit30 else (if(values.timer60="on") values.trial_limit60))


is invalid syntax. Inquisit does not have an else if control structure. You need to solve this differently. (Hint: There is no need for separate values entries for the 30 and 60 second timeouts; use a single one and just set it to either 30 or 60 seconds.)


Regards,


~Dave