Howdy, Stranger!

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

Supported by

[open] Stimulus presentation, keyboard timing and feedback beep

edited March 2016 in OpenSesame

Hi everyone!

I have had a lot of help from this forum for creating my Face Flanker task, so thanks so far!

It's a version of the Eriksen & Eriksen (1974) visual noise stimuli task.

I have a problem to do with stimulus timing, keyboard response timing and feedback sounds.

Basically, I want to present a set of three stimuli for 300ms, then present a visual mask for 3000ms, all the while polling for a SHIFT key response, left or right, and when a shift key is selected, I want a beep to sound, to let the participant know that their response has been recorded, and I want the loop to progress past all this once a correct or incorrect response is recorded. I want the participants reaction time (in ms) to be recorded in one data variable, and whether their response was correct also in one variable.

I have had several tries at organising all this into an experiment file, but I have not been able to achieve all those requirements in one attempt. It seems any arrangement of objects I try within a loop (see my three versions below), there is always one or more elements that I am missing. There are three different attempts at this that I would like to show you lovely people to see if one of them is capable of doing all I need.

Version 1.
https://www.dropbox.com/s/eef6fynmqv8g3m9/GM_take_5.osexp?dl=0
http://i.imgur.com/GyWXZVA.png
This version is just a logical progression of stimuli (300ms), then mask (1ms), then keyboard response (3000ms; so the sketchpad and the keyboard response both technicall run for 3000ms), then beep. The issue with this version is that if the participant responds within the first 300ms, no response is recorded. Theoretically, a response before 300ms is quite unlikely, but my supervisor and I do not want to have a systematic loss of some data. All ms response times, due to the keyboard polling beginning after the 300ms stimulus therefore need 300ms added onto it. A script to do that I have not had success in creating.

Version 2.
https://www.dropbox.com/s/iyriotu66b5ldd4/GM_take_5_Coroutines_Edit.osexp?dl=0
http://i.imgur.com/45WzHDF.png
This version uses the coroutines plugin for 3300 ms; 0-300ms are the stimulus, and from 300ms onwards, the mask is presented. The keyboard response item runs the entire 3300ms. The issues here are that a beep sound cannot be included into the coroutine, so participants do not have feedback when their response is recorded. This also means if participants hit a response key more than once, the keyboard response item seems to only log the latest keyboard press.

Version 3.
https://www.dropbox.com/s/tptxzf3xuhqeedw/GM_take_5_Two_KB_Inputs.osexp?dl=0
http://i.imgur.com/mE6Z5X3.png
This version uses two keyboard response items, one after each sketchpad. While this is arguably the most logical of the three versions, I have not had luck in having two beep items run conditionally on whether a response key was entered previously, nor was I able to have the visual mask sketchpad and the second keyboard response item run conditionally also; it just seemed that they ran every time. This organisation also gave me two keyboard responses, one of which was a timeout, the other would contain useful response time data. Also, in the output it is not apparently clear whether the participant actually pressed the right key.

I am hoping there might be a way to meet all the requirements I would like from my OpenSesame task. Any input you might have will be greatly appreciated! :)

Thanks!!

Rhett

Comments

  • edited March 2016

    Hi Rhett,

    How about a version 4 :)


    # Basically, it assumes that you have your three displays already prepared in # a canvas. Then, in a while loop, you keep on presenting a certain display/mask # depending on the current time. So that after 300 ms/3000ms, etc, the display # is updated # first, you have already prepared your three stimuli and your mask all_displays = [stim1_cv,mask1_cv,stim2_cv,mask2_cv,stim3_cv, mask3_cv] # then it is also handy yo have a list with the durations of each display all_timeouts = [300,3000,300,3000,300,3000] # create a keyboard to poll for the responses kb = keyboard(keylist=['SHIFT'] # also it should be known which key corresponds to the correct response correct_key = 'z' # just an example # give response times and correct response default values var.resp_time = None var.correct = None # finally, I assume that you already set up the sound file sound = sampler(file, volume=.5) # sample time, when the trial begins init_time = clock.time() # loop over each display for i,cv in enumerate(all_displays): # show one display t0 = cv.show() # poll for responses (waiting for respective timeout (300/3000ms)) key,time = kb.get_key(timeout=all_timeouts[i]) if key != None: sound.play() # set whether response was correct if key == correct_key: var.correct = 1 else: var.correct = 0 # I assume the very beginning of the trial (before the very first display) var.resp_time = time-init_time # if a key was pressed, you want to break out of loop break

    I hope this code makes sense to you. It doesn't work as it is right now, because I don't have defined any canvases and also no sound. If you need help, just ask or check out the documentation on how to do these kinda things in inline_scripts: http://osdoc.cogsci.nl/python/ (in particular, check out canvas and sampler)

    Good luck,

    Eduard

    Edit: To log the variables, you either have to use log.write_vars() in the end of your code, or add a logger item after the inline_script.

    Buy Me A Coffee

  • edited 5:27AM

    Hey Eduard!

    I think I am beginning to understand your code. Thank you very much for your response!

    The actual stimulus sketchpad consists of three images displayed along the x axis. Their filenames are variables that are randomly changed within the experiment loop.

    When I run your code, with the canvas defined in the prepare stage, it says that the variables that are the file names (i.e. one image points to [Center_Object].jpg, and [Center_Object].jpg has different values (i.e. Face_1, Face_1, etc) between each set) are not defined.

    How do I prepare sketchpads in advance of running that script, where objects within the sketchpad are linked to variables?

    Thanks!!

    Rhett

  • edited 5:27AM

    Hi rhett,

    If you want to draw 3 images on one canvas, you need to provide all the names for each file. One way to get this done rather easily, is to have three variables in the loop table, e.g. file1, file2,file3. Later in the inline_script, you then have to initialize and draw the images on it.

    # init canvas
    display = canvas()
    
    # draw images on the canvas
    display.image(file1,x=-300,y=0,scale=0.5)
    display.image(file2,x=0,y=0,scale=0.5)
    display.image(file3,x=300,y=0,scale=0.5)
    

    Of course, you need to make sure that the filename is a valid path to the files.

    Is this what you wanted to know? Let me know if you need more info.

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited 5:27AM

    Hey Eduard,

    I actually have the code in place for the images, but in the 'loop' object, there are variables (center object, left object, right object) that change between sets (i.e. center object becomes t_n1.jpg, left object becomes t_t1.jpg, etc)

    In the code, it looks like this http://imgur.com/a/LhKOc

    Hope this helps to elucidate my question!

    Thanks!

    Rhett

  • edited 5:27AM

    Hi Rhett,

    Sorry for the late response. Unfortunately, I'm still unsure whether I understand your issue. Let's take a step back and make sure we're on the same page.

    there are variables (center object, left object, right object) that change between sets

    With "change between sets", do you only mean, that the file names are different between trials of your experiment, or in some other way?

    According to how I understand your design, the only thing that changes between trials is which images are presented. Everything else (position,timing, response sampling) doesn't change, right? If so, which parts of the design are already working as you want them to?

    I actually have the code in place for the images

    Nice. But again, according to my understanding, having the image presenting part set, goes hand in hand with having the loop structure set. If this is not the case for you, maybe you should consider rethinking the image presentation code?

    I hope this make sense. Let me know whether I get you right.

    Good luck,

    edaurd

    Buy Me A Coffee

  • edited 5:27AM

    Hey Eduard,

    Thanks for your patience.

    I'll step it back~

    In the 'prepare' phase of my script, I have the stimuli and mask sketchpads written up (as per the screenshot in my comment above)

    The path of the file is path = exp.pool[[Flank_Object].bmp], 'Flank_Object' is a variable that changes between trials, from t_t, to t_t2 etc. The files in the file pool are named t_t1.bmp, t_t2.bmp etc

    When I run the OpenSesame task, it errors out when it comes to running the script part (i.e. it runs everythins before that) saying:

    item-stack: MainRun[run].Tr_Face[run].Tr_Face_Seq[prepare].Tr_Face_Script[prepare]
    exception type: NameError
    exception message: name 'Flank_Object' is not defined
    item: Tr_Face_Script
    time: Fri Apr 01 10:38:22 2016
    phase: prepare

    Any idea as to what might be causing this?

    Here's a link to the experiment at this point in time~ http://bit.ly/1Y2SjFp

    Thanks!

    Rhett

  • edited April 2016

    Hi Rhett,

    Here a version of that prepare phase that doesn't throw an error:

    Tr_Face_Flank_Image = canvas()
    path = exp.pool[str(var.Flank_Object)+'.BMP']
    Tr_Face_Flank_Image.image(path, center=True, x=480, y=None, scale=None)
    path = exp.pool[str(var.Flank_Object)+'.BMP']
    print path
    Tr_Face_Flank_Image.image(path, center=True, x=-480, y=None, scale=None)
    path = exp.pool[str(var.Central_Object)+'.BMP']
    Tr_Face_Flank_Image.image(path, center=True, x=0, y=None, scale=None)
    Tr_Face_Flank_Image.show()
    clock.sleep(500)
    Tr_Face_Visual_Mask = canvas()
    Tr_Face_Visual_Mask.show()
    

    A couple of comments:

    • once you created an instance of a canvas (let's say, you called it my_cv), you have to use this label to call all the canvas functions. That is use my_cv.image() instead of canvas.image

    • It might be easier and more efficient, if you're loop table already contained the path towards the files, not just the name, so also including the suffix (instead of t_n1, use t_n1.BMP as value in the table). Once you do it that way, you don't have to go through the trouble of adding the extension to the file (the main reason why it didn't work for you)

    • when you want to access variables that you define in the loop-table from within an inline_script, it is not [variable] (like it would in sketchpads and such), but rather var.variable.

    I hope this makes more sense now.

    Eduard

    Buy Me A Coffee

  • edited 5:27AM

    Hey Eduard,

    Thanks for your help! I think that resolves that problem!

    However, some other ones have come up.

    Firstly, the fixation cross only appears after the first set of facial images, and not before. I can't decipher what is telling the faces to appear prior to the fixation dot?

    Secondly, past the fixation dot / facial mixup, the experiment errors out, claiming that response_time is not defined. I have not had to define it in my other loops (i.e. the ones I have not implemented your code in) and it records time accurately in those loops. What am I missing?

    Thanks again for your help!

    Rhett

  • edited 5:27AM

    Hi Rhett,

    Firstly, the fixation cross only appears after the first set of facial images, and not before. I can't decipher what is telling the faces to appear prior to the fixation dot?

    Are you sure that the fixation cross is really not there? Sometimes, it just appears so, but in fact Opensesame proceeds to the next item super quickly, so that you just can't see it. In this case, changing the duration feature would fix it. Maybe it is also a problem of the ordering of the items in your experiment? Obviously, things that appear first in a sequence are executed first. I guess these are the most likely reasons for the fixation cross to not appear.

    past the fixation dot / facial mixup, the experiment errors out, claiming that response_time is not defined

    I'll have a look on it tomorrow, and let you know what could have caused that.

    Eduard

    Buy Me A Coffee

  • edited 5:27AM

    Hey Rhett,

    the script in TR_Face_Script has code in the prepare and in the run phase. Of all elements in a sequence Opensesame executes first all prepare phases and moves then on to the run phase. This probably explains your first problem, right?

    Indeed, the variable response_time is not defined, still you want to log it. The variable that logs the response time in your first sequence is called var.resp_time. So you would have to use this variable name to log it. However, variables with the prefix var are automatically logged. So you don't need to add it manually.

    Does this help?

    Eduard

    Buy Me A Coffee

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