psychopy.org | Reference | Downloads | Github

Randomly pick rows between two Excel files

OS : Win10
PsychoPy version : 3.2.4
Standard Standalone?: yes
What are you trying to achieve?:

Hi all,

I am having trouble with a specific part of the experiment I am building. I have an existing Builder program I made a while ago for a completed study that I want to modify, so I would prefer to keep things as is and just make changes to the current build if possible. In this experiment, participants go through two separate blocks of trials. One block contains visual stimuli, and the other block contains olfactory (odor) stimuli delivered by a device that Psychopy send triggers to.

I’ll quickly explain how the experiment works in its current form. When we start the Psychopy program for a participant, it first randomly determines whether they will start with visual trials, or whether they will start with olfactory trials. Therefore, a person will first complete a set of visual trials and then a set of olfactory trials, or vis versa. When the participant starts a block, Psychopy randomly selects one Excel file from a list of 30 potential Excel files. Importantly, there are separate Excel files per sensory modality (vision and olfaction). So, if a person starts with visual trials, Psychopy will randomly choose 1 visual stimulus Excel file from a list of 30 potential files, and then when they start the olfactory trials Psychopy will randomly choose 1 olfactory stimulus Excel file from a different list of 30 Excel files. Each Excel file contains 24 trails, and participants complete all 24 trials (randomly) before moving to the other block. Below is an image of the experiment structure:

Before the blocks start, there is a routine called randomizeLists containing a code component. Under Begin Experiment, there are two lists. Each list contains all of the Excel files for one of the two conditions. So, the first list has all of the Olfactory Excel files, and the second list has all of the Visual Excel files. Under Begin Routine, Psychopy shuffles each list so that it can randomly select the first Excel file from each list and use that for the upcoming blocks.

The entire run, including the randomizeLists routine, has a giant loop surrounding it called routineController. This loop contains an Excel file in Conditions called RC. RC has two columns (nRepsOne and nRepsTwo), and if I remember correctly, these randomize the order of the visual and olfactory blocks. The two columns just contain the number 1.

Next, there are two loops surrounding the visual and olfactory blocks called routineThree and routineFour. Under nReps, I link it to the RC Excel file, which tells Psychopy to only run through each loop once.

Finally, the olfactory and visual blocks each have another loop (innerThree and innerFour, respectively) where Psychopy continues to loop that specific set of trials until the entire Excel file (24 trials) has been completed.

We want to modify this paradigm. Now, instead of completing the entire modality-specific set of trials, we want to shift back and forth between visual and olfactory stimuli every 4 trials. However, we want the shift to sometimes happen and sometimes not happen, and for this to be random. That means that after 4 visual trials, Psychopy has a 50% chance of competing another 4 visual trials, and a 50% chance of switching to the olfactory condition and completing 4 trials there. This would continue until both the 24 visual and 24 olfactory trials are completed.

I have included the build file if it helps. Additionally, what I am supplying is already a modified version of a previous experiment. This version is much simpler than what I used previously, so it might be possible that some of the loops, or some of the code, are no longer necessary. However, in its current form it runs through 1 Visual and 1 Olfactory block randomly, which is what I want, I just want it to switch back and forth as described above.
Thank you,

Stephen

Experiment 1_fMRI_Attempt2.psyexp (467 KB)