Filtering stimuli from participant response

Hello!

I am a new Psychopy and Pavlovia user, I searched the forum for related questions and couldn’t find an answer that helped me to resolve this.

I have a task based on text stimuli in a csv file organized by randomized set, in which I can also include information such as stimulus categories. In the task I will provide instructions then the main task loop involves reacting to randomly selected stimuli from equivalent sets. My ethics board is asking me to filter stimuli that may be distressing to participants from recent experience. Ideally, I would be able to ask participants something like “Have you experienced a recent death in the family?” before the core task loop and, if Yes, filter out stimuli related to family illness and death. I have enough stimuli that the same number are shown even if all objectionable stimuli are removed. Where would I go in the Builder (or through Code if needed) to use this information in the task loop?

Thank you!

There are three approaches I can think of off the top of my head.

  1. Exclude the appropriate rows before the loop starts and then select the rows you want. For example, a simple code could be:
useRows = []
for Idx in range(100):
     if avoidDeath and Idx in deathItems:
          pass
     elif avoidX and Idx in xItems:
          pass
     else:
          useRows.append(Idx)
  1. End the offending routines early
if avoidDeath and Condition == 'death':
     continueRoutine = False
elif avoidX and Condition == 'X':
     continueRoutine = False
  1. Switch out the offending items for different stimuli
thisImage = Item1 # Item1 from spreadsheet
if avoidDeath and Condition == 'death': # Condition from spreadsheet
     thisImage = Item2
     thisExp.addData('ConditionShown','Replacement')
elif avoidX and Condition == 'X':
     thisImage = Item2
     thisExp.addData('ConditionShown','Replacement')
else:
     thisExp.addData('ConditionShown',Condition)
thisExp.addData('ItemShown',thisImage) # Use thisImage in image component