vendredi 28 février 2020

Displaying different types of stimuli within a trial - PsychoPy Coding

I am facing an issue that I do not know how to solve. I created different trials with blocks of stimuli. Each block consists either of words being shown or audio files being played. To keep the attention of the subjects, I have to incorporate target items which are either an image or a word. So far I managed to replace a random stimulus of the blocks with the target, but I do not know how to display the target item. To explain the problem a little further: I am creating random lists of stimuli and with the probability of 1/3 one stimulus of each list is replaced by a target item. This is no problem if the target item is the same type as the items in the list. However, when I am trying to display an image in a block with words or audios this does not work. Because the lists are run by a code that is specific to the type of the list items.

This is how I exchange on item of the stimulus list (in this case a list of words) with a random item from the target list (a list containing words and pathways to images):

    #randomly swapping an item of the list with a probability of 1/3 
    print(WordV_item) #debug check
    swap= random.choice(prob)
    print(swap) #debug check
    if swap == 1:
        a= list(range(1,len(WordV_item)))
        m= random.choice(a)
        WordV_item[m] = random.choice(Target)
    print(WordV_item) #debug check

Afterwards I am running each list with a specific code that either displays them as text on a screen or plays them as audio files. What I need is something to understand if there is a target item in the list that has to be displayed differently. I'm just not sure how to make this happen. I was thinking maybe I could build in an if condition that checks when the code is running if the list items are target items and runs them differently, but I am unsure how I could make this work.

Thank you very much in advance! I could also upload my code but it's very lengthy, so I'd rather try to explain it a bit better if the issue is not clear.

Have a great day!




Aucun commentaire:

Enregistrer un commentaire