| Reference | Downloads | Github

Display a stimulus with one condition without using a loop or TrialHandler class

Hi, I’ve got a bank of 2 types of images. I want to display 1 image from this bank, randomly selecting either one type or the other (but knowing which type I displayed).
I know how to do that for several images with a routine, a loop and a condition file in the Builder (or the TrialHandler class in the coder). My condition file is basically just three lines: is_typeA, 0, 1.
But I’d like to know if there is an easy way, either in the builder or in the coder, to randomly display 1 image from this bank in my routine.

I’m asking this because I want to add a PsiHandler staircase procedure on top of this and I am not confortable with the 2 loops made up of my PsiHandler class and the TrialHandler class.


Can you provide a little clarification about what you’re going for? If I’m understanding this correctly, you want to select condition between subjects, and then use PsiHandler staircasing to control image presentation? Or are you switching between the two types of image on a trial-by-trial basis and track the staircasing separately for each one?

So to clarify, what I wanted to do is show an image, type 1 or type 2, randomly. Participants have to answer after each image display whether it is type 1 or type 2 (2AFC). Then, I wanted to add a staircase procedure to control the duration of the image display depending on their accuracy to the 2AFC.
I wanted to use the builder and I didn’t understand how to use a loop with a condition file (for type 1/2) PLUS a staircase loop.

I avoided using a loop and a condition file by adding this to “Begin routine”:

    is_type1 = random.getrandbits(1)
    if is_type1 == 1:
        filename_image = type1_images_array.pop(np.random.randint(len(type1_images_array)))
        correctAns = 'p'
        filename_image = type2_images_array.pop(np.random.randint(len(type2_images_array)))
        correctAns = 'a'
    image = join(images_folder, filename_image)

Eventually, I did more complex stuff with a PsiHandler staircase directly in the Coder. If people are interested, I could explain a bit more.