Access entire content of list element?


Author
Message
AKrishna
AKrishna
Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)
Group: Forum Members
Posts: 113, Visits: 386
Hi all,

I was just wondering if there's any way to access the entire content of a list element. For example, if I have a list:
<list MyList>
/items = ("ham","eggs")
</list>

...is there any way to get Inquisit to make something like "ham, eggs" accessible (e.g., for writing in data via values) WITHOUT needing to access the list elements "by hand" (i.e. without list.MyList.item(1))?

The background for this question is that I'm programming an experiment where I'm mapping word colors to (two distinct) response categories and I want to assign the word colors to the response categories randomly for each participant at experiment start. However, I also need to record which colors are associated with which response category in the data file, and I'm unsure how many colors we'll end up using per category. So I'm trying to program the script flexibly such that my collaborators can just enter any number of colors in a master list at the top of the script and the experiment script will a) divide those colors into two response categories per participant and b) record which color ended up where per participant.

I'm managing a) by using a trialduration = 0 trial that pulls one color from the master list and adds it to the first response category list, then loops until the number of items in the response category list is at least half the number of items in the master list before doing a similar loop to fill the second response category list. But b) is causing me some trouble - I can't dynamically add columns to my <data> element as far as I'm aware, so I need to somehow record the entire list contents of a list with an indeterminate number of elements. Is this possible or am I reaching too far here?

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: 102K
AKrishna - 12/16/2021
Hi all,

I was just wondering if there's any way to access the entire content of a list element. For example, if I have a list:
<list MyList>
/items = ("ham","eggs")
</list>

...is there any way to get Inquisit to make something like "ham, eggs" accessible (e.g., for writing in data via values) WITHOUT needing to access the list elements "by hand" (i.e. without list.MyList.item(1))?

The background for this question is that I'm programming an experiment where I'm mapping word colors to (two distinct) response categories and I want to assign the word colors to the response categories randomly for each participant at experiment start. However, I also need to record which colors are associated with which response category in the data file, and I'm unsure how many colors we'll end up using per category. So I'm trying to program the script flexibly such that my collaborators can just enter any number of colors in a master list at the top of the script and the experiment script will a) divide those colors into two response categories per participant and b) record which color ended up where per participant.

I'm managing a) by using a trialduration = 0 trial that pulls one color from the master list and adds it to the first response category list, then loops until the number of items in the response category list is at least half the number of items in the master list before doing a similar loop to fill the second response category list. But b) is causing me some trouble - I can't dynamically add columns to my <data> element as far as I'm aware, so I need to somehow record the entire list contents of a list with an indeterminate number of elements. Is this possible or am I reaching too far here?

> I can't dynamically add columns to my <data> element as far as I'm aware

Correct.

> so I need to somehow record the entire list contents of a list with an indeterminate number of elements. Is this possible or am I reaching too far here?

Loop through the list and concat() everything in a single value? Then you have only one variable per category to record, regardless of how many colors end up being assigned to each category.


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: 102K
Dave - 12/16/2021
AKrishna - 12/16/2021
Hi all,

I was just wondering if there's any way to access the entire content of a list element. For example, if I have a list:
<list MyList>
/items = ("ham","eggs")
</list>

...is there any way to get Inquisit to make something like "ham, eggs" accessible (e.g., for writing in data via values) WITHOUT needing to access the list elements "by hand" (i.e. without list.MyList.item(1))?

The background for this question is that I'm programming an experiment where I'm mapping word colors to (two distinct) response categories and I want to assign the word colors to the response categories randomly for each participant at experiment start. However, I also need to record which colors are associated with which response category in the data file, and I'm unsure how many colors we'll end up using per category. So I'm trying to program the script flexibly such that my collaborators can just enter any number of colors in a master list at the top of the script and the experiment script will a) divide those colors into two response categories per participant and b) record which color ended up where per participant.

I'm managing a) by using a trialduration = 0 trial that pulls one color from the master list and adds it to the first response category list, then loops until the number of items in the response category list is at least half the number of items in the master list before doing a similar loop to fill the second response category list. But b) is causing me some trouble - I can't dynamically add columns to my <data> element as far as I'm aware, so I need to somehow record the entire list contents of a list with an indeterminate number of elements. Is this possible or am I reaching too far here?

> I can't dynamically add columns to my <data> element as far as I'm aware

Correct.

> so I need to somehow record the entire list contents of a list with an indeterminate number of elements. Is this possible or am I reaching too far here?

Loop through the list and concat() everything in a single value? Then you have only one variable per category to record, regardless of how many colors end up being assigned to each category.


In a nutshell:

<parameters>
/ colorspercategory = 4 // select value between 1 and 5
</parameters>

<values>
/ a_colors = ""
/ b_colors = ""
</values>

<expt>
/ onexptbegin = [
    var i = 0;
    while (i < parameters.colorspercategory) {
        list.a.appenditem(list.master.nextvalue);
        values.a_colors = concat(concat(values.a_colors, list.master.currentvalue), " ");
        i += 1;
    };
    i = 0;
    while (i < parameters.colorspercategory) {
        list.b.appenditem(list.master.nextvalue);
        values.b_colors = concat(concat(values.b_colors, list.master.currentvalue), " ");
        i += 1;
    };
]
/ blocks = [1=myblock]
</expt>

<list master>
/ items = ("red", "green", "blue", "yellow", "black", "white", "orange", "brown", "purple", "limegreen")
/ selectionrate = always
</list>

<list a>
</list>

<list b>
</list>

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

<trial mytrial>
/ validresponse = (0)
/ trialduration = 0
</trial>

<data>
/ columns = (date time subject group session blocknum blockcode trialnum trialcode response latency correct
    values.a_colors values.b_colors)
/ separatefiles = true
</data>


Edited 3 Years Ago by Dave
AKrishna
AKrishna
Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)
Group: Forum Members
Posts: 113, Visits: 386
Great, that's a perfect solution that I should really have thought of myself. :D Thanks!

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search