Win10 / version 2021.1.2
Hello,
I am stuck with a problem in my experiment. It seems that the number of calculations I want to perform prior to each trial is generating a delay that gets bigger as the experiment advances. The consequence is that my ITI gets longer than it should and that the stimuli are presented on the screen during less time thay they should.
In previous versions of this experiment the number of calculations for each trial were considerable (I guess),
After I asked for help in the forum (Inter-Trial Interval (ITI) gets longer as the experiment advances - Builder - PsychoPy and Most efficient way to set the position and orientation of stimuli randomly on every trial - #5 by Paula - Coding - PsychoPy) I have simplified the code a lot, but still, I need (or I think I need) a minimum code to do what I want to do.
Participants must do one task (the CATEGORIZATION task) in odd trials and a different task (the SELECTION task) on even trials.
This is how the flow of these two tasks looks like
The CATEGORIZATION trials are specified in the first most inner loop. The loop is linked to the CAT excel file, which has 16 different conditions.
The SELECTION trials are specified in the second most inner loop. The loop is linked to the SEL excel file, which also has 16 different conditions.
I want the program to present the CAT conditions randomly without replacement on odd trials and the SEL conditions randomly without replacement on even trials.
To do so, a code component prior to this flow specifies the following:
cat_indices=list(range(16)) #creates a list of 16 numbers
shuffle(cat_indices) #suffles them
cat_selected_rows=cat_indices[-1:] #takes one number that will be used in the field "row" in the following cat loop.
sel_indices=list(range(16)) #same with the SEL conditions.
shuffle(sel_indices)
sel_selected_rows=sel_indices[-1:]
When the program has run one CAT trial and one SEL trial, I need to eliminate the row that has just been used and select a new one. To do so, after one repetition of those inner loops has occurred, I have a code component as this one:
cat_indices=cat_indices[:-1] #eliminates the CAT row that has just been used.
cat_selected_rows=cat_indices[-1:] #takes a new number from the shuffled list.
sel_indices=sel_indices[:-1] #same for SEL conditions
sel_selected_rows=sel_indices[-1:]
As I am eliminating one number from the shuffled lists after each trial, once the 16 cat trials and the 16 sel trials have been run (once a big block of 32 trials has been run), the shuffled lists would be empty. Since I want to run several times that big block of 32 trials, once the 32 trials have passed, the program goes back to the first code of this post.
This is pretty much all the code I have in the experiment. Another code is used to provide the correct feedback on each trial.
I case it is useful, this is how my inner loops are specified.
I have tried to:
- replace the code
cat_selected_rows=cat_indices[-1:]
cat_indices=cat_indices[:-1]
with
cat_selected_rows=cat_indices.pop()
but I get the following error message:
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\data\utils.py”, line 438, in importConditions
elif len(selection) > 0:
TypeError: object of type ‘int’ has no len()
- I have also included the second code component of this post in the ITI routine (whith the hope that those calculations would be done during the ITI), and set the ITI to be 2 seconds instead of 1 second, but the problem is still there.
I am a bit confused with this problem, because, as I mentioned, I have simplified my code considerably compared to prior versions (e.g, prior versions determined randomly the position and orientation of my stimuli before each trial, also, the two different condition files were “called” with a code component) but I still have this problem.
To give an idea of the problem… the stimuli that should be on the screen for two seconds, end up lasting around 1.30 secs.
I would appreciate any idea on how to solve this
Paula.