Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Using "Skip" in a loop

Hi Forum,

We have a nested loop that we're going "in" and "out" of and are trying to have the nested loop to run in a sequence. Currently, it's repeatedly running the first item in the list over and over. So far we've tried to use the "skip" function and insert a "counter" to skip a given number of trials (n + 1 when n = number of trials completed). This led to the error: The value of skip is too high in loop item "deviant_trial_block1":: You cannot skip more cycles than there are.

Any help resolving this issue would be greatly appreciated.

Comments

  • Hi,

    It is hard to tell what exactly went wrong without knowing the structure of your experiment. Would you mind uploading it? Or at least give a lot more information on your design/structure?

    Thanks,

    Eduard

    Buy Me A Coffee

  • Hi Eduard,

    Thanks for the response. I'll try to be more clear on what the problem is. Our experimental setup is as follows:

    • Participants are to switch back and forth between viewing two different stimuli types (numbers and letters). This is our 1st Loop
    • In one stimuli type, participants are to repeatedly view the same stimulus (i.e., the number 6). This is our first nested loop
    • In the other stimulus type (letters), participants are to view one novel stimulus out of a predetermined list. This is our second nested loop
    • What we're hoping for is that the second nested list will be presented sequentially. This is where we're having problems.
    • Currently, the program presents the first item in the list every time our first loop runs the second nested loop (i.e., the letter A is always presented).

    This is what we want the experiment to look like:

    • 6,6,6,6, A, 6,6,6, B, 6, 6, 6, 6, C, 6,6,6,6,6,6,6, D ....etc. (the number 6 needs to randomly appear 5 to 9 times and the letters need to be sequentially presented between each number string)

    We think the problem is that the nested list doesn't keep track (has no memory) for where the letter is in the sequence (if we put a flag down it repeatedly presents A, but if we have no flag and set are number of cycles to .02 times [so that the participants only see one item], the letters are randomly selected)

    Any help is greatly appreciated!! We're stuck

  • Alright, I can see now.

    I'm not sure how to fix this, while keeping your structure as is (i.e. skipping cycles is a tricky business, which I try to avoid as far as possible).

    However, I think your goal can be rather easy accomplished, if you move most of your scripts into inline_scripts. Such an inline_script (or rather inline_scripts) would replace pretty much everything that is in your curreny loops (both of the nested ones). Below, there is a small example of how this could work. It is just a small demo, of course you would have to adjust it to make it do exactly what you want to.

    The first inline_script can be seen as a preparation in which you have to set the sequence in which you want to present stimuli. It needs to be placed outside the trial_loop.

    import random
    # your letter list
    letter_list = ["A","B","C","D","E"] 
    
    # pick a random digit which to present on the screen
    number = random.choice(range(10))
    
    # actual list of stimuli that will be presented later
    trial_list = []
    
    for letter in letter_list:
        # pick a random number of repetitions of this number
        rep = random.choice(range(5,10))
        trial_list += rep*[str(number)]
        trial_list += letter
    
    # visualization
    # print trial_list
    trial_no = 0
    

    Next, within the trial_loop, you pick the current stimulus draw and present it:


    # prepare phase cv = canvas() kb = keyboard() # requires that you have a trial counter stim = trial_list[trial_no] cv.text(stim) trial+= 1 # run phase cv.show() # either sleep for a certain amount of time # clock.sleep(1000) # or wait for keyboard_response key,time = kb.get_key()

    Does this make sense?

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.