Howdy, Stranger!

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

Supported by

[open] N-back tasks

edited February 2014 in OpenSesame

Firstly, I would like to say Thank you for this awesome software.

Please bare with me, I am absolutely newbie for Opensesame. I have adapted python code from a technician at my uni. to suit my project (2- and 3- back tasks). The syntax for 2- and 3-back tasks are as follow.

(1) 2 back task

from numpy.random import randint, shuffle
from itertools import chain
from copy import copy

# generate stimulus list
# 1: create list of target letters (equal target prob each letter)
n = 2 # 2-back
Ntargets = 24
letters = ['K','B','C','D','T','F','G','H']
SLt = letters*(Ntargets/8)
for i in range(10000):
    shuffle(SLt)

# 2: create sequence & place target letters in it
listStimType = [ [['Standard'] + ['Target']] for i in range(Ntargets) ]
listStimType = list(chain(*listStimType))

listStim = [ [[''] + [t]] for t in SLt ]
listStim = list(chain(*listStim))

# 3: expand standards according to ITI
SLs = [randint(3,9) for i in range(Ntargets) ]
listStimType = [ [listStimType[i][0]]*SLs[i] + [listStimType[i][1]] for i in range(Ntargets) ]
listStimType = list(chain(*listStimType))

listStim = [ [listStim[i][0]]*SLs[i] + [listStim[i][1]] for i in range(Ntargets) ]
listStim = list(chain(*listStim))

# 4: expand targets according to n in n-back
for i in range(len(listStim)-n):
    if listStimType[i+n] == 'Target':
        listStim[i] = listStim[i+n]

# 5: assign remaining letters according to degrees of freedom
# do first couple

def sample(letters, listStim, n, i):
    global randint, copy
    x = copy(letters)
    for takeOut in range(1,n+1):
        try:
            x.remove( listStim[i+takeOut] )
        except ValueError: pass
    return x[ randint(0, len(x)) ]

for i in reversed(range(len(listStim)-n)):
    if listStim[i] == '':
        listStim[i] = sample(letters, listStim, n, i)
    else: continue

# export variables
self.experiment.items['trial_loop'].repeat = len(listStimType)
self.experiment.id = 0
self.experiment.listStimType = listStimType
self.experiment.listStim = listStim
self.experiment.isPrac = 1

(2) 3-back task

from numpy.random import randint, shuffle
from itertools import chain
from copy import copy

# generate stimulus list
# 1: create list of target letters (equal target prob each letter)
n = 3 # 3-back
Ntargets = 24
letters = ['Q','B','C','D','N','F','G','H']
SLt = letters*(Ntargets/8)
for i in range(10000):
    shuffle(SLt)

# 2: create sequence & place target letters in it
listStimType = [ [['Standard'] + ['Target']] for i in range(Ntargets) ]
listStimType = list(chain(*listStimType))

listStim = [ [[''] + [t]] for t in SLt ]
listStim = list(chain(*listStim))

# 3: expand standards according to ITI
SLs = [randint(3,9) for i in range(Ntargets) ]
listStimType = [ [listStimType[i][0]]*SLs[i] + [listStimType[i][1]] for i in range(Ntargets) ]
listStimType = list(chain(*listStimType))

listStim = [ [listStim[i][0]]*SLs[i] + [listStim[i][1]] for i in range(Ntargets) ]
listStim = list(chain(*listStim))

# 4: expand targets according to n in n-back
for i in range(len(listStim)-n):
    if listStimType[i+n] == 'Target':
        listStim[i] = listStim[i+n]

# 5: assign remaining letters according to degrees of freedom
# do first couple

def sample(letters, listStim, n, i):
    global randint, copy
    x = copy(letters)
    for takeOut in range(1,n+1):
        try:
            x.remove( listStim[i+takeOut] )
        except ValueError: pass
    return x[ randint(0, len(x)) ]

for i in reversed(range(len(listStim)-n)):
    if listStim[i] == '':
        listStim[i] = sample(letters, listStim, n, i)
    else: continue

# export variables
self.experiment.items['trial_loop'].repeat = len(listStimType)
self.experiment.id = 0
self.experiment.listStimType = listStimType
self.experiment.listStim = listStim
self.experiment.isPrac = 1

It has been working quite well - However, I have found two problems that I could not change proportion of target to stimuli from 15.48% to 25% and importantly, one letter disappears on the screen and output for 2-back task, also two letter disappears on the screen and output for 3-back.

It would be very appreciated if you could shed some light on these issues.

Cheers!!

[IMG]http://img.cogsci.nl/uploads/53077006100ab.jpg[/IMG]

image

[IMG]http://img.cogsci.nl/uploads/5307703c5e6f4.jpg[/IMG]

image

Comments

  • edited 11:54AM

    Hi Bentley,

    These scripts are so complicated that they inspire me, or probably anyone else, with very little desire to try to understand them! I think if you want to modify them, you're better off asking the technician who wrote them initially.

    Alternatively, we could take a step back and see whether the paradigm can be implemented in a more straightforward way. In principle, there is nothing terribly complicated about an N-back task, and it's something that a lot of other people would be interested in as well.

    Could you provide some details about what kind of paradigm you're trying to implement exactly?

    Cheers,
    Sebastiaan

  • Hey guys, has anyone in the meantime been able to implement the N-back task?

  • I have a sketchpad-target element, displaying a digit (variable name: target_digit)and a response_key element for correcting the right response. I need to write a line in the correct response field (set correct_response) which tells OpenSesame to press a key (e.g. Enter or "s") if and only if the same digit appeared N times ago. I am not very familiar with Python and since I have to run an experiment employing N back next week, I'd be extremely grateful if anyone could help!

  • Hi all,

    I also need to use the n-back task for my study, but I'm not sure how to even begin to build it.

    If anyone has a working version of it and would be willing to share, I would greatly appreciate it.

    @bentley @Daxide --maybe your efforts have been successful?

    Thank you in advance,

    Kyriaki

  • Hi Kyriaki,

    You can check other discussion and the experiments that are linked there.

    For example:

    Those versions won't work out of the box as they were written for older versions of Opensesame, but at least they should give you an idea about how to approach the problem.

    Hope this helps,

    Eduard

    ps. if you are still unfamiliar with Opensesame, I recommend you do one or more of our tutorials. That's the best way to understand the software and by doing so getting inspiration for your own paradigm.

    Buy Me A Coffee

  • Hi Eduard,

    Looking back through those discussions helped.

    Many thanks,

    Kyriaki

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games