Howdy, Stranger!

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

Supported by

Constrain NoGo trials in a Go-NoGo task

Hi all,

I am running a Go-NoGo task and want the number of successive NoGo trials to be constrained so there is at least one Go trials in between two NoGo trials. I should just be able to use constrain trial_type maxrep=1 to make sure only one NoGo trial can be presented successively. However, when I try and run the task, or press preview, it freezes until I click the mouse and then it says not responding and I have to force quit.

At the moment, I just have 25 trials imported from a file to test it works before increasing the number of trials. I have attached the script for the loop. I saw there was a previous bug with using constrain when reading from file: https://github.com/smathot/OpenSesame/issues/570. However, Sebastiaan posted a fix and I am running the most recent version of OpenSesame.

When I remove constrain trial_type maxrep=1 everything works fine, so it is clearly that causing the issue. However, I cannot work out what is causing it to freeze.

Any help would be greatly appreciated!

Best wishes,
James

Comments

  • Hi James,
    can you share your experiment? I'd like to have a look.

    Eduard

  • Hi Eduard,

    I've attached here, and the constrain code is within the script of the block_loop component.

    I've been thinking, and I think I know the reason it's crashing. Each block has 25 trials, 20 go trials and 5 nogo trials. If I am constraining trial_type to a max repetition of 1, then it would not know what to do when there are several go trials in succession. If you have any advice on how I could just constrain the nogo trials, I would be very grateful.

    Best wishes,
    James

  • edited January 12

    Hi James,

    I don't really use use the loop functionalities a lot, so maybe there is an option to do that with those functions that I don't know about, but usually I solve these kind of problems programmatically. So just use an inline_script and create a possible trial sequence in the beginning of a block. Like this you have more control over the sequence, i.e. you can specify all kinds of constrains (if you manage to think about how to implement them). Here an example:

    import random
    
    def checkDuplicates(list, test_item):
        """
        Takes a list and checks whether there are duplicates of the test_items. Returns true, if there are duplicates
        """
        # loop over list items, starting at the second. If you encounter a nogo trial, check whether the previous trial is also a nogo trial. If so return true. If nothing like this was encountered, return False
        for idx,item in enumerate(list[1:]):
            if item == test_item:
                 if list[idx-1]==test_item:
                      return True
        return False
    
    
    
    # make a list with all trials
    trials = ['go']*20 + ['nogo']*5
    
    # shuffle until no duplicates
    random.shuffle(trials)
    while checkDuplicates(trials,'nogo'):
         random.shuffle(trials)
    
    

    Hope this helps!

    Eduard

  • Hi Eduard,
    This looks like it would do the trick. Thank you very much.
    Best wishes,
    James

Sign In or Register to comment.