Present target in random letter location, depending on word length


Author
Message
Lizzy
Lizzy
Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)
Group: Forum Members
Posts: 26, Visits: 105
Hi,

I want to run a modified dot-probe task in which first a cue slope, then 2 words (matched for length), and then a target slope (/ or \) are presented. The task is to indicate whether or not the slope direction of the cue and target slope match. I want the cue and target slopes to be presented randomly in one of the letter locations of the words. So, if the words have 4 letters, the cue and target should appear at random in one of 4 positions.

I have created a script where I have a list of items for the words, and counter element (lengthT) where the length of each word is specified. Words length ranges between 4  and 12 letters. Here's what I've done next:

<item SubSL4>
/ 1 =  "    \       "   (12 characters, 11 spaces 1 slope)
/ 2 =  "     \      "
/ 3 =  "      \     "
/ 4 =  "       \    "
</item>

<item SubSL5>
/ 1 =  "   \        "
/ 2 =  "    \       "
/ 3 =  "     \      "
/ 4 =  "      \     "
/ 5 =  "       \    "
</item>

<item SubSL6>
/ 1 =  "   \        "
/ 2 =  "    \       "
/ 3 =  "     \      "
/ 4 =  "      \     "
/ 5 =  "       \    "
/ 6 =  "        \   "
</item>

and so on to SubSL12:
<item SubSL12>
/ 1 =  "\           "
/ 2 =  " \          "
/ 3 =  "  \         "
/ 4 =  "   \        "
/ 5 =  "    \       "
/ 6 =  "     \      "
/ 7 =  "      \     "
/ 8 =  "       \    "
/ 9 =  "        \   "
/ 10 =  "         \  "
/ 11 =  "          \ "
/ 12 =  "           \"
</item>

Same for the right tilting slopes:

<item SubSR4>
/ 1 =  "    /       "
/ 2 =  "     /      "
/ 3 =  "      /     "
/ 4 =  "       /    "
</item>

and so on to SubSR12

The idea is that with a monospaced font, this should correspond to the letter locations of the words.

Then, pick one option at random for each possible word length:

<text ProbeSL4S>
/ items = SubSL4
/ select = noreplace
</text>

<text ProbeSL5S>
/ items = SubSL5
/ select = noreplace
</text>

<text ProbeSL6S>
/ items = SubSL6
/ select = noreplace
</text>

and so on to ProbeSL12S

Same for right slopes:

<text ProbeSR4S>
/ items = SubSR4
/ select = noreplace
</text>

And so on to ProbeSR12S


Then I've created an item element where, depending on word length, the randomly chosen slope is assigned to at the start of the trial

<item ProbeSLfinal>
/ 1 = ""
</item>

<item ProbeSRfinal>
/ 1 = ""
</item>

Lastly, this item is taken and presented at either the bottom (60%) or top location (40%) of the screen

<text ProbeSLB>
/ items = ProbeSLfinal
/ fontstyle = ("Courier", 24)
/ position = (50%, 60%)
/ txcolor = (255,0,0)
/ txbgcolor = (0,0,0)
</text>

<text ProbeSLT>
/ items = ProbeSLfinal
/ fontstyle = ("Courier", 24)
/ position = (50%, 40%)
/ txcolor = (255,0,0)
/ txbgcolor = (0,0,0)
</text>

<text ProbeSRB>
/ items = ProbeSRfinal
/ fontstyle = ("Courier", 24)
/ position = (50%, 60%)
/ txcolor = (255,0,0)
/ txbgcolor = (0,0,0)
</text>

<text ProbeSRT>
/ items = ProbeSRfinal
/ fontstyle = ("Courier", 24)
/ position = (50%, 40%)
/ txcolor = (255,0,0)
/ txbgcolor = (0,0,0)
</text>

The script for a trial is:

<trial ThreatT_ATSL_TTSR_DESMM> (one of many options)
/ ontrialbegin = [if (counter.lengthT = 4) item.ProbeSLfinal.item.1 = text.ProbeSL4S.item.1]
/ ontrialbegin = [if (counter.lengthT = 5) item.ProbeSLfinal.item.1 = text.ProbeSL5S.item.1]
/ ontrialbegin = [if (counter.lengthT = 6) item.ProbeSLfinal.item.1 = text.ProbeSL6S.item.1]
/ ontrialbegin = [if (counter.lengthT = 7) item.ProbeSLfinal.item.1 = text.ProbeSL7S.item.1]
/ ontrialbegin = [if (counter.lengthT = 8) item.ProbeSLfinal.item.1 = text.ProbeSL8S.item.1]
/ ontrialbegin = [if (counter.lengthT = 9) item.ProbeSLfinal.item.1 = text.ProbeSL9S.item.1]
/ ontrialbegin = [if (counter.lengthT = 10) item.ProbeSLfinal.item.1 = text.ProbeSL10S.item.1]
/ ontrialbegin = [if (counter.lengthT = 11) item.ProbeSLfinal.item.1 = text.ProbeSL11S.item.1]
/ ontrialbegin = [if (counter.lengthT = 12) item.ProbeSLfinal.item.1 = text.ProbeSL12S.item.1]
/ ontrialbegin = [if (counter.lengthT = 4) item.ProbeSRfinal.item.1 = text.ProbeSR4S.item.1]
/ ontrialbegin = [if (counter.lengthT = 5) item.ProbeSRfinal.item.1 = text.ProbeSR5S.item.1]
/ ontrialbegin = [if (counter.lengthT = 6) item.ProbeSRfinal.item.1 = text.ProbeSR6S.item.1]
/ ontrialbegin = [if (counter.lengthT = 7) item.ProbeSRfinal.item.1 = text.ProbeSR7S.item.1]
/ ontrialbegin = [if (counter.lengthT = 8) item.ProbeSRfinal.item.1 = text.ProbeSR8S.item.1]
/ ontrialbegin = [if (counter.lengthT = 9) item.ProbeSRfinal.item.1 = text.ProbeSR9S.item.1]
/ ontrialbegin = [if (counter.lengthT = 10) item.ProbeSRfinal.item.1 = text.ProbeSR10S.item.1]
/ ontrialbegin = [if (counter.lengthT = 11) item.ProbeSRfinal.item.1 = text.ProbeSR11S.item.1]
/ ontrialbegin = [if (counter.lengthT = 12) item.ProbeSRfinal.item.1 = text.ProbeSR12S.item.1]
/ stimulustimes = [0 =   crossB, crossT, arrowUp; 1000 = blankmid, blanktop, blankbottom, ProbeSLT; 1150 = blanktop, blankbottom, zThreatTop, zNonBottom; 1650 = blanktop, blankbottom, ProbeSRT]
/ inputdevice = mousekey
/ validresponse = (lbuttondown, rbuttondown)
/ correctresponse = (lbuttondown)
</trial>

The script partly works in that right or left tilting slopes (accurate) are presented at the top or bottom of the screen (accurate), however the slope is always at the same location on the x-axis, slightly off-centre to the left (looks like corresponding to the first letter position of a 5 letter word). The slopes (whether cue or target) are always in that position, independent of word length. There is no variation in the x-axis position of the slope, which I had hoped to achieve by randomly picking one of the possible options, and feeding that forward through the script.

I tried reprogramming it in a dozen ways to fix the problem, but have been unsuccessful so far.
Any help with this would be much appreciated!!

Cheers


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: 108K
Not sure if it's the only problem (hard to tell based on code snippets only), but syntax in your /ontrialbegin attributes is off.

/ ontrialbegin = [if (counter.lengthT = 4) item.ProbeSLfinal.item.1 = text.ProbeSL4S.item.1]

#1: counter.lengthT does not mean or do anything. It is missing the actual counter *property* you want to refer to, such as (perhaps?) counter.lengthT.selectedvalue. See the language reference for the <counter> element for a full listing of available properties.

#2: if (counter.lengthT = 4) is using the *wrong operator*. '=' is the *assignment* operator, but you'll want '==' as *logical* operator here. Details can be found in the 'Operators' topic in the documentation.

Hope this helps.

Lizzy
Lizzy
Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)
Group: Forum Members
Posts: 26, Visits: 105
Thanks Dave, that solved the problem! I can't believe I spent such a long time on such a stupid script error. The joys of programming... :)

One extra question: is there a way to have 1 if and multiple then's?

For example if I want to say 

/ ontrialbegin = [
if (counter.lengthT.selectedvalue == 4)
then item.AnchorSRfinal.item.1 = text.AnchorSR4S.item.1
and item.TargetSRfinal.item.1 = text.TargetSR4S.item.1

Just separating the then statements with a comma doesn't seem to work. Is there a way to do this or do I have to repeat the if statement?

Cheers!

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: 108K
Yes:

/ ontrialbegin = [ if (boolean) {expression; expression; expression; ...} ]

Note the curly braces.
Lizzy
Lizzy
Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)
Group: Forum Members
Posts: 26, Visits: 105
Thanks Dave!

Although my original problem seemed solved at first, it turns out it isn't, and I've found an extra, substantial problem. I attached a simplified version of the script.

Basically, the tasks shows a neutral word (in Romanian) and a matched nonword on the screen, preceded and followed by a slanting line (/ or \). The task is to indicate whether the orientation of these two lines match.

What I want the task to do is the following:

(1) The neutral word can either be presented at the top location and the matched nonword at the bottom location, or vice versa. I've created two item elements for the two sets of words, that' I linked using the current function in a text item. Thus, I've created text elements to read in the selected neutral word and matched nonword [select = current(neutral word)] and presents them either at the top or bottom location.
(2) Ideally, the position of the slanted line on the x axis corresponds to one of the letter positions of the words that are presented, picked randomly from all the possible option for that particular word length.

The corresponding problems are:
(1) When the neutral word is presented at the top location and the nonword at the bottom location, the script works fine. It is the matched nonword that shows up on the screen. However, when I want to present the neutral word at the bottom location and the nonword at the top location, a different nonword than the one that should appear, appears. 
I have used the same script successfully before (with Inquisit 3), and I can't figure out why the same script suddenly doesn't work any more. Also, it is basically the same script as the first option (neutral top, nonword bottom), with a simple reversal. It hurts my brain.
(2) the x-axis location of the sloping lines still doesn't vary according to word length. I added some debugging script and on every trial, it appears the word length is read as "4", aka the first item in my items list of word lengths, it's not matching it up to the length of the currently selected item in the word lists.

I wonder whether I have too many "current"s in there, and something is getting mixed up, but despite hours of messing with the script, I haven't been able to figure it out. 
Again, your wisdom would be much appreciated!!

Attachments
Puzzle.iqx (235 views, 19.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: 108K
Lizzy,

order does matter -- and always has mattered (including in Inquisit 3): Selection in <text wNonBottom> depends on selection in <text wNeutTop>. In other words, for this to work, selection in <text wNeutTop> *must occur first*.

<text wNonBottom>
...
/ select = current(wNeutTop)
...
</text>

It indeed does in the respective <trial>: wNeutTop comes *before* wNonBottom, and that's why that works.

<trial NeutT_ATSL_TTSL>
...
/ stimulustimes = [...; 1150 = blanktop, blankbottom, wNeutTop, wNonBottom; ...]
...
</trial>

However, in the 2nd case, you've switched dependencies around. Selection in <text wNeutBottom> depends on <text wNonTop>:

<text wNeutBottom>
...
/ select = current(wNonTop)
...
</text>

Now look at the corresponding <trial>:

<trial NeutB_ATSL_TTSL>
...
/ stimulustimes = [...1150 = blanktop, blankbottom, wNeutBottom, wNonTop; ...]
...
</trial>

Edited 11 Years Ago by Dave
Lizzy
Lizzy
Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)
Group: Forum Members
Posts: 26, Visits: 105
Dave, you are my hero. I swapped the order around and it works (I must have not accidentally mis-ordered the items in the previous task). This was such a major problem and the study is due to run on Friday. What a relief! Thank you!!

I shall write it 100 times: Order is important!

I still have to figure out the word length selection bit, but that's a more minor thing!

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: 108K
As far as I can see, the length issue essentially boils down to the same thing. You've encoded lengths in a <text> element whose selection depends on other <text> elements displayed in the course of a <trial>:

<text LengthsB>
/ items = iLength
/ select = current(wNeutBottom)
</text>

However, you try to make use of that information /ontrialbegin, i.e., before any stimuli have been presented / before any selections that <text LengthsB> depends on have occured:

<trial NeutB_ATSL_TTSL>
/ ontrialbegin = [if (text.LengthsB.currentitem == "4") {item.AnchorSLfinal.item.1 = text.AnchorSL4S.item.1; item.TargetSLfinal.item.1 = text.TargetSL4S.item.1; item.AnchorSRfinal.item.1 = text.AnchorSR4S.item.1; item.TargetSRfinal.item.1 = text.TargetSR4S.item.1}]
...
</trial>

Thus the element's currentitem property cannot correspond to anything that only happens later in the trial.

Lizzy
Lizzy
Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)
Group: Forum Members
Posts: 26, Visits: 105
So I could potentially fix it by reading in the NeutBottom element first in an ontrialbegin, and then reading in the corresponding length item?
That feels like a fairly roundabout way of getting these word-length-dependent slope selections to happen, but I'll just be happy if it works!
If you have any other (more elegant) suggestions for how I could program this, I'd be happy to hear them!

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: 108K
Well, there are dozens of ways to do this. The high-level is answers is that you need to make sure that you already know everything you need to know *at the beginning of a given <trial>* (i.e., which stims are going to be presented later on). Using a <counter> and a bunch of <values> seems like the most obvious / least intrusive option given your script as it currently exists.

As for more "elegant" approaches, it's largely a matter of taste / personal preference, but personally I'd have used string functions to pull this off (i.e., insert the probe at a random position in a given word) and I would have used <list> or <counter> elements to randomize on-screen positions instead of setting up separate <text> and <trial> elements to do this.

Hope this helps.



GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search