Howdy, Stranger!

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

Supported by

[solved] Flicker Paradigm Change Blindness Task

edited September 2015 in OpenSesame

I am currently trying to develop a change blindness task for use in my Master's thesis. I have a good start from reading this post here: http://forum.cogsci.nl/index.php?p=/discussion/663/open-change-blindness-experiment-with-flicker-paradigm/p1

However, it does not follow the quite same procedure that I would like to implement. I am using mouse inputs rather than keyboard responses and would prefer to do the task completely on the computer to avoid interruptions in participant focus. What I would like to do is have OpenSesame record all of an individuals mouse clicks while they are working on the task so that I can have a total for the number of incorrect guesses made by a participant. I am still very new to coding, but was wondering if there was a way to record all of the mouse responses and to only stop the loop of images when they either correctly identify the change on the image or when they run out of time.

I need to be able to specify a spot on the canvas as the "right" answer, but am unsure how to go about this. I thought that maybe using the touch response tool would allow me to specify specific zones on the canvas? I have also read some posts about mouse tracking and using "max click error" to create a radius of pixels, but I believe that the mouse tracking would provide me with much more data than I need. I only want to log their guesses and be able to insert a break command that stops the loop when they obtain the correct answer.

I am using the following script to run my pairs of images in a loop with a gray screen to interrupt and to attempt to record mouse clicks when they occur:

frame_dur = 250
repetitions = 45
start_time = self.time

from openexp.mouse import mouse
from openexp.canvas import canvas

my_mouse = mouse(exp)
my_mouse.set_visible(visible=True)

my_canvas1 = canvas(exp)
my_canvas1.image(exp.get_file(u'Barn1.png')) 
my_canvas2 = canvas(exp)
my_canvas2.image(exp.get_file(u'Barn2.png'))
my_canvas_gray = canvas(exp, bgcolor='gray')

for i in range(repetitions):

    my_canvas1.show()
    resp, position, timestamp = my_mouse.get_click()
    if resp != None:
        button, position, timestamp = my_mouse.get_click()

    my_canvas_gray.show()
    resp, position, timestamp = my_mouse.get_click(timeout=80)

    my_canvas2.show()
    resp, position, timestamp = my_mouse.get_click()
    if resp != None:
        button, position, timestamp = my_mouse.get_click()

    my_canvas_gray.show()
    resp, position, timestamp = my_mouse.get_click(timeout=80)

My mouse coding is probably not correct, I am still not clear about how to record the mouse clicks through the inline_script.
Any help would be greatly appreciated.

Thanks,
Ashley E.

Comments

  • edited September 2015

    Hi Ashley,

    Firstly, yes it is possible to collect all mouse responses and stop when the correct location in your stimulus has been clicked. In your inline_script you could start off by defining that location: e.g.

      x_min = 50
      x_max = 55
      y_min = 100
      y_max = 105   # these coordinates indicate a square with x=50 to 55 and
                             # y = 100 to 105
    

    The get_click() command returns a set of coordinates, (in your code that's a variable named 'position'). Here is an example of how you could append responses to a list, and stop when the correct location was clicked:

      response_list = [] # we start off with an empty list.
      correct_response_given = False
    
      while correct_response_given = False:
             resp, position, timestamp = my_mouse.get_click(timeout=80)
             if position != 'none':
                  response_list.append(position)
                  if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):
                          correct_response_given = True
    

    Regardless of how often participants clicked a wrong location, the last response in that list would be the correct one. You could do all kinds of things with that list, e.g. len(response_list) would show you how many clicks a participant needed to get it right.

    Hope this helps.

    Josh

  • edited 2:55AM

    Josh,

    I really appreciate your help! This did help me to make sense of recording the mouse responses. However, I am getting an "invalid syntax" error for the line "while correct_response_given = False"

    I inserted your suggestion into my code like this, but is this incorrect?

    for i in range(repetitions):
    
        my_canvas1.show()
        resp, position, timestamp = my_mouse.get_click()
        while correct_response_given = False:
        if position != 'none':
                  response_list.append(position)
                  if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):
                          correct_response_given = True
    

    Thanks,
    Ashley

  • edited 2:55AM

    Oops, I made a mistake there; it's while correct_response_given == False:, so, with two equals signs instead of one!

    For all logic statements (such as "if this" or "while that"), 'equals' is denoted with two equals signs. The single = is best interpreted as 'becomes'.

    Cheers,

    Josh

  • edited 2:55AM

    Great! This makes a lot more sense.

    I ran into one more snag though, I am now getting this error:

    "Error while executing inline script

    phase: run
    item: Practice_pair
    line: 32
    exception message: 'NoneType' object has no attribute 'getitem'
    exception type: TypeError

    Traceback:
    File "dist\libopensesame\inline_script.py", line 173, in run
    File "dist\libopensesame\python_workspace.py", line 111, in _exec
    File "", line 33, in
    TypeError: 'NoneType' object has no attribute 'getitem' "

    Line 32 is this "if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):"

    Is this something to do with position being "none" when a timeout happens? How can I work around this?

    Again, I appreciate all of your help!

  • edited 2:55AM

    Hi Ashley,

    This can't be due to position being 'none', as line 30 indicates to only run line 32 if position is not 'none'. Are you sure you defined your x_min, x_max, y_min and y_max somewhere?

    Cheers
    Josh

  • edited September 2015

    Josh,

    Yes, I believe that I defined the x and y variables correctly. This is the complete code that I have right now:

    frame_dur = 250
    repetitions = 45
    start_time = self.time
    
    from openexp.mouse import mouse
    from openexp.canvas import canvas
    
    x_min = -256
    x_max = -64
    y_min = 64
    y_max = 224
    
    my_mouse = mouse(exp, timeout=frame_dur)
    my_mouse.set_visible(visible=True)
    
    my_canvas1 = canvas(exp)
    my_canvas1.image(exp.get_file(u'Barn1.png')) 
    my_canvas2 = canvas(exp)
    my_canvas2.image(exp.get_file(u'Barn2.png'))
    my_canvas_gray = canvas(exp, bgcolor='gray')
    
    response_list = [] 
    correct_response_given = False
    
    for i in range(repetitions):
    
        my_canvas1.show()
        resp, position, timestamp = my_mouse.get_click()
        while correct_response_given == False:
            if position != 'none':
                  response_list.append(position)
                  if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):
                          correct_response_given = True
                  else:
                      resp, position, timestamp = my_mouse.get_click()    
    
        my_canvas_gray.show()
        resp, position, timestamp = my_mouse.get_click(timeout=80)
    
        my_canvas2.show()
        resp, position, timestamp = my_mouse.get_click()
        while correct_response_given == False:
            if position != 'none':
                  response_list.append(position)
                  if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):
                          correct_response_given = True
                  else:
                      resp, position, timestamp = my_mouse.get_click()
    
        my_canvas_gray.show()
        resp, position, timestamp = my_mouse.get_click(timeout=80)
    
    len(response_list)
    

    Is it a problem with the coordinates that I am using?

    Thanks,
    Ashley

  • edited 2:55AM

    Hi Ashley, did you put the for-loop part in the 'run phase' of your inline_script? (Everything before the for-loop can be kept in the 'prepare phase')

    Cheers,

    Josh

  • edited 2:55AM

    Josh,

    I had everything in the "run" phase. I moved everything before the loop commands to the prepare phase, but I am still getting the same error.

    "Error while executing inline script
    phase: run
    item: Practice_pair
    line: 8
    exception message: 'NoneType' object has no attribute 'getitem'
    exception type: TypeError

    Traceback (also in debug window):
    File "dist\libopensesame\inline_script.py", line 173, in run
    File "dist\libopensesame\python_workspace.py", line 111, in _exec
    File "", line 9, in
    TypeError: 'NoneType' object has no attribute 'getitem'"

    Thanks,
    Ashley

  • edited September 2015

    Hi,

    I didn't read the entire discussion super-thoroughly, but does it solve the issue if you change this line:

    if position != 'none': into that: if position != None:?

    If the mouse wasn't clicked position should be of None type and not a string.

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited 2:55AM

    Eduard,

    Yes, that solved the error. Thank you for your help.

    I am starting to understand what they say about writing code; fix one thing and something else breaks.
    My cycle is no longer working and I really cannot find a reason why. Before adding Josh's suggestions I had no trouble with the image cycle. When I try to run the experiment now it shows me the first canvas, but will not advance. When I try to click (either in the correct or incorrect zone) the experiment locks up and becomes unresponsive.

    Any ideas?

    Thanks again for all the help,
    Ashley

  • edited 2:55AM

    Hi Ashley,

    it locks up, if you click in one of the incorrect areas of the screen, it freezes, because you have no mechanism to avoid an infinite loop. Add a counter to the loop (either based on repetitions or on time), to set a limit to that.

    If you click in the correct area, it should work though. Can you verify that the logic of the loop is correct, by adding a print statement after this line:

    if (x_min <= position[0] <= x_max)

    Something like: print 'been here'

    If the check works fine, it should print this string to the debug window. If it doesn't appear, there is probably something wrong with the logic.

    Good luck,

    Eduard

    Edit: I just saw the values of x_max, x_min and the y equivalents. Usually, screen coordinates in Opensesame are only positive integers, starting with (0,0) in the topleft corner. Is there a reason why you use negative values there?

    Buy Me A Coffee

  • edited 2:55AM

    Eduard,

    I thought this section of code set a limit to the repetitions:

    frame_dur = 250
    repetitions = 45
    

    When the image is clicked the window becomes unresponsive, and nothing ever prints in the debug window. It does not even respond to the escape key once the images appear. So perhaps I am misunderstanding the loop instructions. It was working fine before I added the response lines of code.

    For the x, y I was using the coordinates on the canvas item where it indicates the center is (0,0).

    ~Ashley

  • edited 2:55AM

    I did some reading on the forum and understand that I misinterpreted the origin for the coordinates. I now have all of my coordinates based on a (0,0) in the top left and thus all of my x y coordinates are positive integers.

    However, this did not solve my freezing problem. This is pretty confusing! :-/

  • edited September 2015

    Hi,

    I thought this section of code set a limit to the repetitions:
    ~~~ .python

    frame_dur = 250
    repetitions = 45

    ~~~

    This part doesn't prevent infinite loops that originate in one of the while loops, e.g., if correct_response_give stays False. Do you see that?

    Another problem that could have caused these issues is the fact that both of your while loops contain only computing steps, if a mouse button was clicked. However, since there is no command waiting for the mouse click to occur, which is run on every iteration of the while loop, nothing happens. So, have a look at this:

     while correct_response_given == False:
            # anything from here on, won't be run, because position was once defined as
            # being None, and was not sampled again since then. 
    
            if position != 'none':
                  response_list.append(position)
                  if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):
                          correct_response_given = True
                  else:
                      # this else is never executed
                      resp, position, timestamp = my_mouse.get_click()
    

    I hope you see the problem. A solution is to move the else statement one level up:

     while correct_response_given == False:
            # now either the if or the else statement will inevitably executed
    
            if position != 'none':
                  response_list.append(position)
                  if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):
                          correct_response_given = True
            else:
                  # now the loop is waiting for a button to be clicked on every iteration
                  resp, position, timestamp = my_mouse.get_click()
    

    Let us know if this worked.

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited September 2015

    Okay, definitely getting closer! Thanks so much! With the above changes my experiment now runs, but with a few small hiccups.
    This is my current code in the "run" phase:

    for i in range(repetitions):
    
        my_canvas1.show()
        resp, position, timestamp = my_mouse.get_click()
        while correct_response_given == False:
            if position != None:
                  response_list.append(position)
                  if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):
                          correct_response_given = True
            else:
                resp, position, timestamp = my_mouse.get_click(timeout=250)
    
        my_canvas_gray.show()
        resp, position, timestamp = my_mouse.get_click(timeout=80)
    
        my_canvas2.show()
        resp, position, timestamp = my_mouse.get_click()
        while correct_response_given == False:
            if position != None:
                  response_list.append(position)
                  if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):
                          correct_response_given = True
            else:
                resp, position, timestamp = my_mouse.get_click(timeout=250)
    
        my_canvas_gray.show()
        resp, position, timestamp = my_mouse.get_click(timeout=80)
    
    len(response_list)
    

    My only problem now is that the loop will not start until the correct location is clicked, and then after that the loop will not end until after the specified 45 repetitions regardless of where I click. If I begin by clicking on an incorrect location on canvas1 nothing happens, but if I continue to click outside of the correct x,y coordinates the experiment will freeze.

    I tried adding a line such as

    if correct_response_given == True
         break 
    

    but this only gives me an error or causes the experiment to freeze.

    What I need to happen is for the loop to start automatically and only stop if either the correct response is given or the maximum number of repetitions has occurred.

    Thanks again,

    Ashley

  • edited 2:55AM

    Well, if you answer the first time correctly, correct_response_given is already true, so you won't ever enter the second while loop. If you don't give the correct response, you're still being caught in the first while loop. I'm not sure what exactly it is that you want to accomplish (still haven't read your first post, sorry...), but would it work if you wrote the code like this:

    for i in range(repetitions):
    
        my_canvas1.show()
        resp, position, timestamp = my_mouse.get_click()
        response_list.append(position)
        if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):
            correct_response_given1 = True
            break
    # if you wanna show the gray canvas, only if the correct response was given:
    # if correct_response_given1:
    my_canvas_gray.show()
    for i in range(repetitions):
        my_canvas2.show()
        resp, position, timestamp = my_mouse.get_click()
        response_list.append(position)
        if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):
            correct_response2_given = True
            break 
    
    my_canvas_gray.show()
    
    len(response_list)
    
    

    Does this make sense?

    Buy Me A Coffee

  • edited 2:55AM

    Eduard,

    Yes, that makes sense but does not work for what I want to accomplish.

    In a change blindness task the objective is to quickly switch back and forth between two images with a gray mask in between. Participants are to identify the change and click on it, which ideally would end the loop and proceed to the next set of images.

    There is not a "correct" answer on the first cycle as they haven't been shown the change until canvas2 is presented, and it is very unlikely that anyone would be able to identify the change even in the first 20 cycles. So I want the loop to run until the correct answer is given, and to record any incorrect responses, but not to wait for any mouse input before continuing through the loop.

    Is there a way to do this?

    Thanks,
    Ashley

  • edited 2:55AM

    Oh, of course. Now it makes much more sense to me. Sorry.

    What about this code?

    for i in range(repetitions):
    
        my_canvas1.show()
        resp, position, timestamp = my_mouse.get_click(250)
        if correct_response_given == False:
            if position != None:
                  response_list.append(position)
                  if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):
                          correct_response_given = True
                          break
    
        my_canvas_gray.show()
    
        my_canvas2.show()
        resp, position, timestamp = my_mouse.get_click(250)
        if correct_response_given == False:
            if position != None:
                  response_list.append(position)
                  if (x_min <= position[0] <= x_max) and (y_min <= position[1] <= y_max):
                          correct_response_given = True
                          break
    
        my_canvas_gray.show()
    
    len(response_list)
    

    The difference here is that I changed the whiles into ifs and removed the elses, because I don't think they added much to the logic. You just have to make sure, that my_mouse.get_click() is waiting for just as much time as you want to present each of the images' versions.

    Eduard

    Buy Me A Coffee

  • edited 2:55AM

    Eduard,

    Yes, this is perfect! Thank you so much for all your help! :)

    Ashley

  • edited 2:55AM

    Good to hear. We could have saved much time, if I would have been more attentive right from the beginning. Sorry again.

    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