Randomly select stimuli every two trials from rows of block csv

Hello,

I am currently designing a flanker task experiment and am stuck on how to pull conditions from specific rows from a block CSV every two trials.

Here is a summary of the experiment’s structure. There are two loops: an outer loop, “block” and an inner loop, “trials”. Within “block” loop only, there are two components: instructions and countdown. In the “trials” loop, there are two components: the image stimuli and feedback based on user’s response. The conditions of “block” are chooseBlock.csv, which contains blocks 1, 2, and 3, while the conditions of “trials” is $condsFile. Block 1 contains stimuli with color conditions only and Block 2 contains stimuli with shape conditions only. Block 3 contains both - the first chunk of rows (1-15) which are shape only and the second chunk of rows (16-31) which are color only.

During Block 3, I want the user to determine the stimuli’s color, and every two trials, to determine the stimuli’s shape. All of the images within the shape-only are the same as those in color-only. I was thinking something similar to this custom code:

import random;

if block.thisN == 3:
if trials.thisN % 3 == 0:
random(1)*15
else:
random(16)*31

The pseudo code would be, if this block trial number is the every 2nd,
select a random stimuli from the shape rows
if else,
select a random stimuli from color rows

I was wondering if anyone has any ideas on how to implement this in the builder? Thank you! Please let me know where I should be more specific.

Hi There,

I have adapted the title of this question to be easier for future users to find :slight_smile:

If your question is that you only want to change a parameter ever other trial, then your code component is the right direction. Say you wanted to change some text only on every other trial, you could use:

Begin experiment tab:
trialCount = 0

Begin Routine tab:

if trialCount %2:
    thisText = myText # where myText is the column header in your conditions file
else:
    thisText = ' '
trialCount +=1

Hopefully that helps,
Becca

If you only want this to occur in the third block. Then add a column to your chooseBlock.csv called Label and then extend this code to be:

if label == 'block3':
    if trialCount %2:
        thisText = myText # where myText is the column header in your conditions file
    else:
        thisText = ' '
trialCount +=1