psychopy.org | Reference | Downloads | Github

Inserting Data for Each Loop Repetition

For my experiment I have a loop with 8 repetitions. For each loop there is a different graph shown, these graphs are either exponential or reciprocal graphs. The problem I am having is getting my data output to show the graph type as a variable within each loop repetition. I would like a column in my data table labeled (GraphType) which displays exponential or reciprocal for each repetition of the loop.
I already have this code which sorts the graph stimuli.

exponential = [['stim_exp_1.04+2.jpg','exp'],['stim_exp_1.04+6.jpg','exp'],['stim_exp_1.04+10.jpg','exp'],['stim_exp_1.05+2.jpg','exp'],['stim_exp_1.05+6.jpg','exp'],['stim_exp_1.05+10.jpg','exp'],['stim_exp_1.06+2.jpg','exp'],['stim_exp_1.06+6.jpg','exp'],['stim_exp_1.06+10.jpg','exp']]

reciprocal = [['stim_recip_1.04+2.jpg','recip'],['recip_1.04+6.jpg','recip'],['recip_1.04+10.jpg','recip'],['recip_1.05+2.jpg','recip'],['recip_1.05+6.jpg','recip'],['recip_1.05+10.jpg','recip'],['recip_1.06+2.jpg','recip'],['recip_1.06+6.jpg','recip'],['recip_1.06+10.jpg','recip']]

shuffle(exponential)
shuffle(reciprocal)
graphs = []
for Idx in range(4):
     graphs.append(exponential[Idx])
     graphs.append(reciprocal[Idx])
shuffle(graphs)

Thanks!!

thisExp.addData(‘GraphType’,graphs[trials.thisN][1])

1 Like

This is the error message I get. Screen Shot 2020-06-15 at 2.07.44 PM

I think you’ve got funny quotes round “GraphType”. Try typing single simple quotes.