If statements within trial's /stimulusframes?


Author
Message
DCole9
DCole9
Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)
Group: Forum Members
Posts: 42, Visits: 220
Hi Inquisiters,
I'm running into a problem with a task-switching paradigm in which subjects have a choice between 2 colored patches.  The patches are randomly assigned a high demand and a low demand condition which effects the display color of a number.  The color of the number will effect whether they make an "even or odd" decision or a "> 5 or < 5" decision.

What I'm trying to do is setup my stimulus frames to display from the high demand number list when the certain criteria are true (random position variable = 1, they selected patch1, etc).

My question is:   Do I need to set up individual trials for each possibility?  (e.g. trialA for random position 1, select.patch1.  trialB for random position 2, select.patch1. etc. etc.)

Or is it possible to use something like
"/ontrialbegin = [if((values.XX == 1( && (values.YY == 2 )) values.stimframes = "displaytext, displaynum, patch1, patch2]
/stimulusframes = values.stimframes"


or "/stimulusframes = [if ((values.XX == 1) && (values.YY == 2)) 1 = displaytext, displaynum, patch1, patch2]"


Thank you for your help!
Attachments
DemandSelection.iqx (233 views, 25.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: 13K, Visits: 104K
Yes, it's possible. You need to use the <trial> element's insertstimulustime() etc. functions to do this. You cannot use <values> in the way you sketched.

See e.g. https://www.millisecond.com/forums/Topic10374.aspx#bm11148

For further details, see the language reference for the functions mentioned above.

DCole9
DCole9
Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)
Group: Forum Members
Posts: 42, Visits: 220
That's perfect Dave!

One other (I think simple) question: In my code do you know why I am receiving the 'Expression " is invalid. Expression is empty.' error message?  I have a text element declared that gets filled when a list cycles values, which I've done before, but it isn't working this time.
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: 13K, Visits: 104K
/ontrialbegin = [if ((values.diceoutcome > 50 ) values.highnumcolor = list.highdemandcolor.nextvalue]


Notice the additional (superfluous / unmatched) parenthesis.

Edited 10 Years Ago by Dave
DCole9
DCole9
Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)
Group: Forum Members
Posts: 42, Visits: 220
My mistake I had since fixed that error.  The other error is unrelated to that I think.

It is the element "text.highnumber" showing the error.
Attachments
DemandSelection.iqx (223 views, 27.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: 13K, Visits: 104K
This won't work / is invalid syntax:

<text highnumber>
/items = ("")
/position = (50%, values.numbery)
/fontstyle = ("Arial", values.focussize, true, false, false, false, 5, 0)
/txcolor = (values.highnumcolor)
/txbgcolor = (white)
/select = values.numberget
</text>

The way to do this is defining

<text highnumber>
/items = ("")
/position = (50%, values.numbery)
/fontstyle = ("Arial", values.focussize, true, false, false, false, 5, 0)
/txbgcolor = (white)
/select = values.numberget
</text>

and then doing

/ ontrialbegin = [text.highnumber.textcolor=values.highnumcolor]

Also, you need to get rid of the double-quotes in

<list highdemandcolor>
    /items = (yellow, blue)
    /replace = false
    /selectionrate = trial
</list>

for the items to be interpreted as colors.

DCole9
DCole9
Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)
Group: Forum Members
Posts: 42, Visits: 220
Ah got it.  It's working now.  

For your previous post I need to declare each stimulus frame as a separate line correct?  When I separated them by semi-colons it didn't work.

For example)
"/ontrialbegin = [if ((values.randomposition == 1) && (trial.InitialSelect.response == "patch1") && (values.randomdemand == "lowpatch1")) trial.patchtrial.setstimulusframe(focus, 1);]
/ontrialbegin = [if ((values.randomposition == 1) && (trial.InitialSelect.response == "patch1") && (values.randomdemand == "lowpatch1")) trial.patchtrial.setstimulusframe(choose, 1);]"


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: 13K, Visits: 104K
No, you do not. You need to use curly braces to bundle all the statements to be executed under the if-condition;

/ ontrialbegin = [if (true) { do stuff; do more stuff; do even more stuff; }]

Also, it's not clear to me why you use setstimulusframe() in both statements. You would only use it in the 1st and then insertstimulusframe() in all subsequent ones:

<list fixationduration>
/ items = (500, 5000, 10000)
</list>


<trial mytrial>
/ ontrialbegin = [if (true) {trial.mytrial.setstimulustime(text.a, list.fixationduration.nextvalue);
    trial.mytrial.insertstimulustime(text.b, list.fixationduration.nextvalue); }]
/ ontrialend = [trial.mytrial.resetstimulusframes()]
/ stimulustimes = [0=fixation]
/ validresponse = (57)
</trial>

<text fixation>
/ items = ("+")
</text>

<text a>
/ items = ("A")
/ position = (45%, 50%)
</text>

<text b>
/ items = ("B")
/ position = (55%, 50%)
</text>

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

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search