Variable column based on group

I know how to variably select files based on groups (e.g. by using $“spreadsheets/list_”+expInfo[“list”]+“.xlsx”), but what I would like to do is to have separate columns in one spreadsheet instead of 4 separate spreadsheets (i.e. with columns “question1”, “question2”, “question3” for the three lists/groups). This seems cleaner than whole separate spreadsheets, especially when piloting since changing some aspect of the stimuli could be done in one spreadsheet than separately for each list.

The experiment presents an audio stimuli (4 different audio_prompts) and the order of these should vary by group, so when calling the audio component, I’d like to refer to the variable/column questionN (where N = the list number (1, 2, or 3) entered at the beginning of the experiment), if that makes sence.

Does anyone have suggestions about how to do this? Thanks for your time!!

Jade

Do you mean like this?

Hi Wakefield, thanks for the incredibly fast response!

Hmm, I think this is more complex than what need. Sorry I probably haven’t explained it very well. Below is a minimal example using the practice stimuli spreadsheet assuming there were two lists. So, at the start of the experiment, I’ll assign some participants to list 1 and others to list 2. Those in list 1 should hear the audio files in question1 in relation to the individual stimuli (e.g. ‘blondt hår’ + ‘hva var dumt’) and those in list 2 should hear the audio files in question2 in relation to the individual stimuli (e.g. ‘blondt hår’ + ‘hva var dyrt’).

So, it’s not about randomisation. The thing is simply that we have a slightly asymmetric match between the number of stimuli to number of audio files, but want every stimuli to occur with every audio file at an equal amount across the lists. Hence we need multiple lists with specified stimuli & audio file combinations. If that makes sense?

So basically, instead of saying I want the audio stimulus to be $question1, I’d like to have a kind of $“question”+expInfo[“list”] (this is probably incorrect) so that I only have to have one spreadsheet, but differing audio prompts based on the selected list at the start of the experiment. :slight_smile:

I meant that it was code for you to simplify. Something like

if thisExp['list'] == '1': #Note the quotes
     thisText = question1
elif  thisExp['list'] == '2':
     thisText = question2
...    

Oh, I see, thanks, it looks like that should work, but I get an error currently. Sorry, I’m not the best coder. I’ve added that code to a code component (practice_code), set to the beginning of the routine and then referred to $thisText in the audio component (see picture below), but I get the following error:

if thisExp['list'] == '1': #Note the quotes

TypeError: ‘ExperimentHandler’ object is not subscriptable

Probably I’ve done something simply wrong? I really appreciate the help!

Sorry, my fault. I get confused between thisExp and expInfo. You need the latter.

That’s perfect! Thanks so much, Wakefield!

So for future people with the same problem, adding the following code at Begin Routine with separate columns question1 and question2 solves it. :slight_smile:

if expInfo['list'] == '1': #Note the quotes
     thisText = question1
elif  expInfo['list'] == '2':
     thisText = question2