Howdy, Stranger!

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

Supported by

N-Back Task problem

I have been encountering some problems while I try to use OpenSesame to develop a N-Back Task
Here's the link to my script file: https://drive.google.com/file/d/1wFmetLhfQaqYBf4gZWKmIALddNgqO000/view?usp=sharing

This is my first time using software like OpenSesame. I was trying to develop a 2-back task which participants have to judge and respond to item that matches the one that presented 2 items ago. I used 8 letters (B, F, K, H, M, Q, R, X) as stimuli, and I wanted each letter to appear 6 times within a list, once as a target. Before the experimental trials begin, there will be 10 trials of training with feedback. Afterwards, participants will perform four blocks 48 trials without feedback.

However, when I performed a quick run of my experiment, I found it cannot give feedback properly. I used two sketchpads, one with a red cross and one with a green circle to represent incorrect and correct responses. Sometimes the feedback came before the keyboard response and sometimes when I gave the correct response it gave me an incorrect response feedback.

I have defined those two sketchpads to run if [correct] = 0 and [correct] = 1 but it was still not working.

Moreover, I have no idea how to enter the target letter with the full-factorial design button as my experiment wasn't a factorial experiment. Therefore, I entered the stimuli manually:

It was okay for me to enter the trials manually for the practice block as there was 10 trials only. However, it would be quite time consuming if I have to manually enter all four experimental blocks of 48 trials. So I would like to know is there any way that is more convenient to develop a block loop for my 2-back task? I have tried to search for Python codes for N-Back Task but I have no idea how to use them.

Comments

  • Hi,

    However, when I performed a quick run of my experiment, I found it cannot give feedback properly.

    Does it work if you replace the sketchpads with feedback items (without changing the content?). See here for an explanation.

    So I would like to know is there any way that is more convenient to develop a block loop for my 2-back task?

    I recommend using an inline_script. There is probably also a way doing it with the loop table, but in my opinion, you have more control and understand better if you do it programmatically. For example, you can create a random sequence of targets/nontargets for as many trials as you have. Then, assign target letters to each target position, and finally fill the rest with distractors.

    Something like this: (untested code)

    # assuming each letter will be target once
    
    import random
    
    # create a sequence and randomize it. Match trials are 1, mismatch trials are 0
    seq = [0,0,0,0,0,1]*6
    
    random.shuffle(seq)
    # make sure there is no target in the first two trials
    while seq[0] == 1 or seq[1] == 1:
        random.shuffle(seq)
    
    # target letters
    letters = ['a','f','u','k','j','e','d','b']
    random.shuffle(letters)
    
    # populate
    stim = [None]*len(seq)
    # skip the first two 
    for idx,item in enumerate(seq[2:]):
        if item == 1:
            stim[idx] = letters.pop()
            stim[idx-2] = stim[idx]
    

    Please note the code is incomplete! Currently, I don't take into account the situation in which a match might overwrite a previously assigned pair. Also, you would have to fill unassigned positions with distractor letters. But I hope this code can get you started. If you need more help, let us know.

    Eduard

    Thanked by 1Natalie
  • Does it work if you replace the sketchpads with feedback items (without changing the content?). See here for an explanation.




    It was still not working after I replaced the sketchpads with feedback items :s

    Please note the code is incomplete! Currently, I don't take into account the situation in which a match might overwrite a previously assigned pair. Also, you would have to fill unassigned positions with distractor letters. But I hope this code can get you started. If you need more help, let us know.

    This is my first time using OpenSesame and Python code so it will take me sometime to figure this out. I'm not sure this would work or not but I'm so grateful for your help. Many thanks!

  • Are you sure? I downloaded your experiment (from the beginning) and changed it the way I suggested (slightly different than you) and it seems to work (see attachment).

    Good luck with coding. It can be fun :smile:

    Thanked by 1Natalie
  • Thanks a lot :) ! However, I reckon there is some problem with my block loop because even when I gave the correct response during the quick run it was logged as an incorrect response. Sorry for bothering you this much but I really need your help

    Also if I wanted to use the inline script above I could just replace the trial sequence with it? Because I don't quite understand how it works

    Once again, Thanks for your help!

  • Hi,

    I think you shouldn'T be worried about the feedback yet. Once you can produce sequences that are correct, you can dive into providing proper feedback. It is a little cumbersome to fix the feedback before you actually have the sequence.

    Also if I wanted to use the inline script above I could just replace the trial sequence with it? Because I don't quite understand how it works

    There are different options. You could replace it altogether, but it would suffice if you put this inlinescript in the beginning of a block loop and all you would do in that sequence is then creating the sequence ( a list) of trials. In the trial loop you can then call one trial after another and present the stimuli the way you already doing it. If you choose this option, your loop table would largely get obsolete.

    Btw. One more piece of advice, before getting at the proper implementation, you should try to create the algorithm with paper & pen in pseudocode, so that you have some scaffold to orient yourself while programming.

    Eduard

    Thanked by 1Natalie
  • There are different options. You could replace it altogether, but it would suffice if you put this inlinescript in the beginning of a block loop and all you would do in that sequence is then creating the sequence ( a list) of trials.

    I think this way is better than inputing the trials one by one. But I don't know how to run the script

    I followed this tutorial but still it isn't working :s

  • Try to take one step at a time. For example, never mind the n-back task for now, but just try to create a list of stimuli in the beginning of a block, and present them one by one in the trial loop on the screen. It may appear overwhelming now, but if you break it down into pieces, you will see it will be doable. And don't despair if it doesn't work out of the box. Trying to figure out what is wrong with your code is a major part of programming.
    Maybe you can also just follow the tutorial and try to reproduce what Sebastiaan is doing, it will give you at least a feeling of the logic to keep in mind.

    If I just wrote the script for you, you wouldn't get better, you know...

    Eduard

    Thanked by 1Natalie
  • I will try to create the task from the beginning again. Thanks a lot for your help! :blush:

  • edited September 12

    Just another question

    Is it ok for me to follow this tutorial if I'm running OpenSesame on Mac OS and using Expriment as the back-end of my experiment?

    Because I followed this tutorial step by step but the experiment still not running properly, and I'm not sure where the problem was

  • It should be working. If you run into a problem, you can ask a specific question. There will probably be a reason for it.

Sign In or Register to comment.