Creating list or vector with numerical values & getting n-th element out of this list


Author
Message
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 problem. Let me know how it goes!

fasteddie9141
fasteddie9141
Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)
Group: Forum Members
Posts: 2, Visits: 32
Thanks for this I will give it a hack so to speak

Apologies for doubling up with PM

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
Assuming you did something like

<expressions>
/ getlossdeck1 = sequence(0, 0, 0, 0, 0, 0, 0, 0, 0, 1250)
/ getlossdeck2 = sequence(0, 0, 0, 0, 0, 150, 200, 250, 300, 350)
/ getlossdeck3 = sequence(0, 0, 0, 0, 0, 0, 50, 50, 50, 50)
/ getlossdeck4 = sequence(0, 0, 0, 0, 0, 0, 0, 0, 0, 250)
</expressions>

there is no reason why the decks should be "in sync". If e.g. "deck 1" is selected
<trial igt>
...
/ ontrialend = [ if (trial.igt.response == "deck1") {... ; values.loss=expressions.getlossdeck1; ...}]
...
</trial>

A single sample is retrieved from expressions.getlossdeck1. The remaining expressions are (supposed to be) wholly unaffected -- no samples are retrieved.

The quickest, but somewhat hack-ish, way to change that is to retrieve a sample from *every* expression regardless of the deck chosen:

<trial igt>
...
/ ontrialend = [ if (trial.igt.response == "deck1") {... ; values.loss=expressions.getlossdeck1; expressions.getlossdeck2; expressions.getlossdeck3; expressions.getlossdeck4;...}]
/ ontrialend = [ if (trial.igt.response == "deck2") {... ; values.loss=expressions.getlossdeck2; expressions.getlossdeck1; expressions.getlossdeck3; expressions.getlossdeck4;...}]
...
</trial>

fasteddie9141
fasteddie9141
Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)Respected Member (498 reputation)
Group: Forum Members
Posts: 2, Visits: 32
Dave

I know I'm dredging this from the mists of time but I am also trying to do a linear sequence with the iowa gambling task from the web scripts.

I have used the sequence command to select a fixed loss value and modified other elements of the script so that it only shows one value for loss gain over the card

Its 90% there but I cannot get the getlossdeck sequence to step together so that it doesn't step back when users select a different response.

i.e if they keep hitting deck A the cards are in correct sequence but if they change from deck to deck it does the decks in order but not so the sixth card in A leads to the 7th in B etc

Is there a simple way of explaining your example of counters so that I can get the existing code to step in time so to speak 

I have some code you can look at to see the modifications I've made if it would help

J
Tags
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

You're welcome. BTW, if you're into risk-taking card tasks, definitely check out the Columbia Card Task script available from the Inquisit Task Library.


Cheers,


~Dave


Olga Kunina
Olga Kunina
Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)
Group: Forum Members
Posts: 4, Visits: 1

Dear Dave,


thanks for these examples and your answers. They were very helpfull. [:)]


Have a good weekend. With best wishes,


Olga


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

Can you tell me how one would have to define "counter.deck", "text.presenteditems", or "item.useritems" so that this function is executed regularely?


Hmm, I don't think there's much more too it. Let's do this by way of an example. Suppose you have defined a counter element:


<counter fruit>
/ items = ("apple", "banana", "cherry", "damson", "elderberry")
[...]
</counter>


Now, suppose you want to retrieve the third item from the counter, i.e. "cherry", with the getitem function. You can use that function either by way of the <expressions> element


<expressions>
/ getcherry = getitem(counter.fruit, 3)
[...]
</expressions>


or by way of Inquisit's event attributes ('/ onexptbegin', '/ onexptend', '/ onblockbegin', '/ onblockend', '/ ontrialbegin', '/ ontrialend') available at the <expt>, <block> and <trial> level


<trial getcherry>
/ ontrialbegin = [text.favoritefruit.item.1 = getitem(counter.fruit, 3)]
/ stimulusframes = [favoritefruit]
[...]
</trial>

<text favoritefruit>
[...]
</text>


and do all sorts of things with it, e.g. write it to a <text> element or to a <values> entry. Note that the item index number, i.e. the second argument of the getitem function  ( 3 for "cherry") may also be a variable. So you might as well define another <values> entry (or use anything that returns a valid numerical value) and use it as the functions argument:


<values>
/ cherryindex = 3
[...]
</values>


<expressions>

/ getcherry = getitem(counter.fruit, values.cherryindex)

[...]

</expressions>


Best wishes from a fellow Inquisit user,


~Dave


Olga Kunina
Olga Kunina
Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)Expert (1.3K reputation)
Group: Forum Members
Posts: 4, Visits: 1

Dear Dave,


thank you so much for your help. That is indeed a very simple soultion for this probelm. [:D]


However, we are developing a new card risking task and there it would be helpful to be able to get the n-th element of a counter. Unfortunatelly there are not many examples for the usage of the function getitem in the documentation .




getitem(counter.deck, 1)

getitem(text.presenteditems, text.presenteditems.itemcount)

getitem(item.useritems, item.useritems.itemcount - 1)


Can you tell me how one would have to define "counter.deck", "text.presenteditems", or "item.useritems" so that this function is executed regularely?


Kind regards,


Olga




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

Okay, I had a quick look at your script and compared it to the original IGT script available from millisecond.com. Well, if all you want is a fixed sequence of losses for each deck, there's a much easier way to pull this off. In the original script, losses are randomly determined by the following expressions:


<expressions>
/ getlossdeck1 = noreplace(0, 0, 0, 0, 0, 0, 0, 0, 0, 1250)
/ getlossdeck2 = noreplace(0, 0, 0, 0, 0, 150, 200, 250, 300, 350)
/ getlossdeck3 = noreplace(0, 0, 0, 0, 0, 0, 50, 50, 50, 50)
/ getlossdeck4 = noreplace(0, 0, 0, 0, 0, 0, 0, 0, 0, 250)
</expressions>


Each time the subject selects e.g. deck1, a random value is returned from expressions.getlossdeck1 (without replacement). Now, if you want to switch that behavior to a predictable, fixed sequence in which certain amounts of losses should occur, you may simply define:


<expressions>
/ getlossdeck1 = sequence(0, 0, 0, 0, 0, 0, 0, 0, 0, 1250)
/ getlossdeck2 = sequence(0, 0, 0, 0, 0, 150, 200, 250, 300, 350)
/ getlossdeck3 = sequence(0, 0, 0, 0, 0, 0, 50, 50, 50, 50)
/ getlossdeck4 = sequence(0, 0, 0, 0, 0, 0, 0, 0, 0, 250)
</expressions>


I.e.only when the subject selects deck1 for the tenth time, a loss of 1250 will occur. No further changes are necessary as you can see from the attached script.


Let me know if that helps,


~Dave


Attachments
igt_sequential.exp (1.2K views, 7.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

 Unfortunately
it does not work. It seems to be a problem with the expression "getitem(counter.deck1_loss,
values.cards_deck1)".


What exactly isn't working?


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search