Presenting a subset of conditions after break

My experiment has the same number of word trials and non_word trials. All trials are listed in my conditions_file.csv linked to my loopTrial loop as showed in the screeshot below.

32%20AM

I need to tweak my code in such a way that a given number of non_word trials (let’s say 1, for simplicity) is presented after each of the three breaks. I am not sure how to implement this, since the selection option of the function importConditions() will subset a given range of rows to presented for the entire experiment. What I need instead is to set up some sort of pseudo-randomizing constraint that will present 1 non_word trials after each break, but all trials listed in the condition file will still need to be presented once throughout the experiment.

Can anybody give me some hint on how to accomplish this? I was thinking of doing the following:

  1. Split the condition file imported for the loopTrial loop in two: one only containing 1*3=6 prime-target non_word trials that will be presented after each break; and the other one containing the rest of the trials. I am not sure how to implement this.
    (Another option I thought of is to create an inner loop within the loopTrial loop that would run right after the break and to which a separate conditions file with the non_word after-break trials. This loop could randomly select the trial to be presented after each break before getting to the outer loop again, although this means that the same after-break trial may potentially be selected at the following repeat.)

  2. Mark the end of the break somehow. At the moment, I have no idea of how this could be done.

  3. Use (2) when selecting the trials to present, e.g.:

# primeRoutineBegin loop
if blahblah # where blah blah must be replaced with the variable in (2) above
    text_prime.setText(filler_break[prime]) # or something like that
else: text_prime.setText(prime)

...

# targetRoutineBegin loop
if blahblah: # where blah blah must be replaced with the variable in (2) above
    text_target.setText(filler_break[target]) # or something like that
else: text_target.setText(target)

I have no idea if this will work or not and, especially, if (1) and (2) can be accomplished somehow in PsychoPy and/or PsychoJS. I would really appreciate if anyone can help. Thank you in advance!!

EDIT: I switched category from #online to #coder since I realized this is a more general question on implementation (rather than a specific question on PsychoJS.

I think I made some progress, but I would still need some help.

This is the flow I am working on:

  1. fmaskWarm, primeWarm, targetWarm are components that refer to the conditions file of the loopWarm loop.
  2. breakWarm is a component with a the following code component:
#Begin routine
breakWarmRoutine = True
if loopWarm.thisTrialN not in [2,5,7]: 
    breakWarmRoutine = False #take a break after the 3rd, the 6th and 8th trials

text_breakWarm.text = "You can now take a short break.\n\n There are " + str(loopWarm.nRemaining + 1) + " words left. \n\n When you are ready, press RETURN to resume the experiment."

#Each frame
continueRoutine = breakWarmRoutine
  1. Inside the loopWarm2 loop:
    a. fmaskWarm2 has the following code component:
#Begin experiment
loopWarm2Counter = 0 #initialize a counter

#Begin routine
if breakWarmRoutine is False: #if the breakWarm routine does not pop up
    continueRoutine = False #do the same
else:
    loopWarm2Counter += 1 #otherwise, increase the counter by 1

if loopWarm2Counter >= 1: # this defines the number of trials we want to present after each break
    loopWarm2.finished = True # if the counter reaches the threshold, the loop terminates
    continueRoutine = False # the routine does not pop up
    loopWarm2Counter = 0 # and the counter is set to zero

b. primeWarm2 and targetWarm2 has each the following code component:

#Begin routine
if breakWarmRoutine is False: #if the breakWarm routine does not pop up
    continueRoutine = False #do the same

This should set up a pseudo-random organization of the first trial/s after the break. I am now facing two issues:
a. I would need to make sure that the trials inside the loopWarm2 loop do not get repeated at the next loop repeat. The present setting does not prevent that. Maybe I need to “depopulate” the conditions file at every repeat…?
b. In this setting (i.e., with two nested loops), the information about the remaining trials given in the text_breakWarm textComponent of the breakWarm routine is updated with respect to the outer loop (i.e., loopWarm), but of course does not take into consideration the trials presented in the inner (i.e., loopWarm2). Any idea of how to fix this? Notice that I can’t do something like

loopWarm.nRemaining + loopWarm2.nRemaining,

since loopWarm2 is defined only after the first repeat of loopWarm.

Any comment and/or feedback is much appreciated!

Hi there, does anybody have idea of how to do this? I can’t seem to think up a way to code this, but it should be possible somehow. Thank you in advance!