Howdy, Stranger!

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

Supported by

[open] Randomizing pictures on form_base

edited April 2014 in OpenSesame

Hi :)

First of all, I should mention that I just recently have started working with OpenSesame. I am going to use a form_base, in which two pictures will shown on the screen and two check boxes will appear under them (each related to one of the pictures). SO , the task of subject is choosing one of the pics by selecting the checkbox under it. Moreover, I should mention that the pictures of the first choice are different from the pictures of the second choice. In other words, the pics that will appear on the screen are from two different categories.

Now, my question is related to the pictures. I have defined two variables, each related to one group of pictures. The pictures of each group appear randomly. But, the place of pictures are always same, I mean the picture of "gaze_cue" always appear on the right hand side of the form, and the pictures of "gaze" always appear on the left. However, I want these places also be randomly changed. However, I do not know how I should apply this to my form.
Here is the script of my form :

How I can randomly change the place of pictures of "gaze_cue" and "gaze" ? I Hope I could explain clearly and I appreciate if you help me in this regard.

Best Wishes,
-pa

Comments

  • edited 10:17AM

    Hi,

    Let's assume that you have three variables:

    • gaze_cue_pos indicates whether the gaze-cue image should be on the left or the right
    • gaze_cue is the gaze-cue image filename (i.e. the first picture)
    • gaze is the gaze image file (i.e. the second picture)

    Now you can do one of two things:

    Option 1: Create two version of the form_base, one where the gaze cue is on the left and one where it is on the right. Then you use a run-if statement ([gaze_cue_pos] = left for the one, and [gaze_cue_pos] = right for the other) to execute only of these items, depending on the value of gaze_cue_pos. See also:

    Option 2: Alternatively, you can insert an inline_script before the form_base, and add the following code to the prepare phase:

    if self.get('gaze_cue_pos') == 'left':
        exp.set('left_img', self.get('gaze_cue'))
        exp.set('right_img', self.get('gaze'))
    else:
        exp.set('right_img', self.get('gaze_cue'))
        exp.set('left_img', self.get('gaze'))
    

    ... and then you use the variables left_img and right_img in your form_base. The script is probably self-explanatory, but what it does is set the variable left_img to gaze_cue or gaze, depending on the value of gaze_cue_pos. And analogously for right_img. See also:

    Cheers!
    Sebastiaan

  • edited April 2014

    Dear Sebastiaan,

    I tried the second option. It perfectly works. Thank you so much for your explanations ! :)

    Bests,
    Pa

  • edited 10:17AM

    Hi again,

    I would like to ask you another question. Actually, I would like to record the mouse trajectory of participants. I have read the discussions about mouse tracking in opensesame, be honestly since it does not give the detailed graphs of mouse trajectory , I decided to use Mousetracker softwar (Jon Freeman). Now, my question is that, for combining these two together, they have mentioned that we should add "udpinterface" to our CSV. file. But, I do not know how I should add this parameter to my opensesame CSV file and actually, I do not know how I should combine these two software together. Here is their instruction:

    "Setup: Activating UDP Interface (udpinterface) and specifying trials to be interfaced
    Add into your experiment .CSV file a new experimental parameter, udpinterface. It specifies information about the UDP interface in the following order:
    ID number, input port, output port, [remote host] (optional)
    The ID number is arbitrary, but just makes sure that MouseTracker and the external environment are on the same page. This becomes important, however, if an environment on a remote "server" computer is controlling MouseTracker on two "client" computers, in which case the ID number serves to identify which "client" computer's MouseTracker is communicating (e.g., Player 1 or Player 2)."

    I really appreaciate if you could help me. [-O<

    Best Regards,
    Pa

  • edited 10:17AM

    Hi Pa,

    The .csv file in question is the one that belongs to MouseTracker, and not the OpenSesame log file. (.csv is just a generic name for any comma-separated-values file.) So I would ask the MouseTracker developer how you can set up UDP communication within MouseTracker.

    In addition, you would also need to set up a UDP connection within OpenSesame (i.e. in Python). Again, I would first check if the MouseTracker developer or other MouseTracker users have some example Python code. If not, we can see if we can adapt some of the MatLab examples for Python.

    However, my feeling is that it will be much easier to just implement everything in OpenSesame, or, if your experiment is simple enough, run everything with MouseTracker (which can also design simple experiments). Setting up a communication may be more trouble than it's worth.

    Why not ask the other users about their experiences in the discussion below?

    Cheers,
    Sebastiaan

  • edited 10:17AM

    Hi sebastiaan,

    Thank you so much for your quick reply. I really appreciate it. Yes, you are right, running these two software together is difficult and I could not manage it during past days! Actually, I somehow designed my experiment in opensesame and I am getting familiar with it and now, it's difficult for me to start with mouse tracker to design from the first point. But, thanks I will follow the link that you have sent me, maybe I could solve it there .

    Thank you so much for taking your time.
    Best Wishes,
    Pa

  • edited April 2014

    Hi :)

    First of all, sorry for several questions! Actually I have two questions; the first one is related to the image buttons on the form-base. As I explained previously I want to show two pictures at the top of the form ad participants should select one of them.
    My first question: I changed the row, column and also column and row span in many ways, but still I cannot reach to what I prefer. I want pictures to be presented at top of the screen and with a good horizontal distance between them, but, when the distance changes the size of the image buttons changes or vice versa (I have changed the number of columns, rows, the location and span in many ways but I could not reach to that point that I want!) Here is my form code:

    set rows "1;1"
    set cols "1;2;2;1"
    widget 0 0 2 1 image_button path="[left_img].jpg" var="my_response1"
    widget 2 0 2 1 image_button path="[right_img].jpg" var="my_response2" 
    

    image

    and this is a screen shot of the experiment. As I mentioned I want these two pics be more far away and also in the same size as they are now or even bigger! In the screen I have shown where I want pictures to be shown with two blank squares!

    The second question and actually the most important one : I decided to use the mouse tracking inline code, and I tried to apply it to my experiment. But since I am really amateur in coding I cannot define variables and apply codes to my experiment. Mostly, it gives error for the tracker-run phase code. I just would like to know whether there is any other tutorial beside the two discussions related to mouse tracking (I could not find anything else on the forum).
    I appreciate if you could help me with these two questions.

    Thanks in advance.
    Bests,
    PA

  • edited 10:17AM

    Hi
    I just would like to inform you that I solved the second problem and now, I get the mouse tracking data. The first problem is also somehow modified but I am still working on size and distance of pictures and I could not reach to a good solution for it. If you have any suggestion for the first problem I really appreciate if you let me know.

    Regards,
    PA

  • edited 10:17AM

    Hi,

    The way that a form's geometry is specified is explained in detail here:

    What I would do in your case is first draw out your preferred geometry on a piece of paper. Then you can draw a grid on the (paper) form, and from there estimate what kind of values you need for the rows, cols, spacing, and margins variables.

    Cheers!
    Sebastiaan

  • edited May 2014

    Dear Sebastiaan,

    Thank you so much for your suggestions. I will try to fix it. Thanks.

    Best Regards,
    PA

  • edited May 2014

    Hi,

    I am sorry for several questions. But, another time I faced with a problem that I cannot solve it. It is related to mouse-tracking. Actually, I could design the experiment in the way that a fixation point will be presented on the screen and then by click we go to the next page in which two images (image-button) are presented at the top-left and top-right of the page as well as a start button at the bottom of this page. The location of the mouse will be initialize each time and then the participant should click on the start button. When they click on the start button the mouse tracking starts to work until the participant makes her choice by clicking on one of the images on the top of the screen. Here is my code related to run-phase of the tracker as well as a screen shot of my design.

    image

    def my_function():
        print '#initialise
    
    start = self.time()
    my_mouse.set_visible()
    
    #initialise borders
    w,h = exp.resolution()
    
    #set a tracking loop
    flg=False 
    tracking = True
    
    
    while tracking:
    
        position, timestamp = my_mouse.get_pos()
        x, y = position
        t = timestamp - start
        #uncomment this to print to the debug window.
        print str(t)+', '+str(x)+', '+str(y)
        #write to myLog
        myLog.write(str(x) + ',' + str(y) + ',' + str(t) + ','+ self.get('gaze_cue_pos') + ',' + chr(10))
        #assemble to write trajectories to OS logger (duplicate data and could be removed)
        xList.append(x)
        yList.append(y)
        tList.append(t)
        #set up mouse click
        lclick, mclick, rclick =  get_pressed()
        get()
    
        #if rclick == 1:
            #print "jjjjj"
        if 768 < x < 1152 and y > 830 and lclick == 1:
            mouse_rt = timestamp - start    
            flg = True
        if x > 1152 and y < 540 and lclick == 1 and flg == True:
            resp = 1
            mouse_rt = timestamp - start
            print 'Clicked3'
            my_canvas.clear()
            tracking = False
    
        if x < 768 and y < 540 and lclick == 1 and flg == True:
            resp = 2
            mouse_rt = timestamp - start
            print 'Clicked4'        
            my_canvas.clear()
            tracking = False
    
    
        #This dictates sampling rate. 50 hertz is more than enough
        self.sleep(20)
    my_canvas.clear()
    print 'answered'
    tracking = True
    #if resp == self.get('correct'):
        #self.experiment.set("accuracy", 1)
    #else:
        #self.experiment.set("accuracy", 0)
    self.experiment.set("Mouse_RT", mouse_rt)
    self.experiment.set("xTrajectory", str(xList))
    self.experiment.set("yTrajectory", str(yList))
    self.experiment.set("tTrajectory", str(tList))
    self.experiment.set("position", position)
    '
    

    Now, my question: I should change the design of my experiment in this way:
    I should eliminate the fixation point and instead of that have the start button.
    The participant should click on the start button to go to the next page consisting of the two images. At the same time, when the participant clicks on the start button the data related to mouse tracking should be recorded. So, when they click on start button on the first page, at the same time the mouse tracking starts working and also we go to the page consisting of two images (in contrast to the previous design, this time we do not have start button at the same page with two images). The tracking will be finished when they click on one of the two pictures.And this trial continues for all the pairs.
    In this case, I think we can even have one inline script consisting of start-button code, then mouse-tracking and also the two image button for the pairs of pictures. However, I could not manage to build that.

    My second question is: Whether there is a possibility to show or hide an image-button in an inline script? If yes, what is that code?

    I really appreciate if you could help me in this regard.

    Regards,

    Pa

  • edited May 2014

    Hi,

    I am here with a new question. Actually, I should change another thing in my experiment. Previously, I defined two variables for my form and I manually pair the picture in the loop (variables gaze_cue and gaze). Thus, when I run the program it selects each pair from the ones that I had defined in my loop.

    image

    and these were my codes:


    def my_function(): print 'if self.get('gaze_cue_pos') == 'left': exp.set('left_img', self.get('gaze_cue')) exp.set('right_img', self.get('gaze')) else: exp.set('right_img', self.get('gaze_cue')) exp.set('left_img', self.get('gaze')) '

    def my_function(): print 'set rows "2;1;1" set cols "1;1;1;1;1" widget 0 0 2 1 image_button path="[left_img].jpg" var="mmmresponse1" widget 3 0 2 1 image_button path="[right_img].jpg" var="mmmresponse2" widget 2 2 1 1 image_button path="transparentsmall.png"'

    However I want to change the design in the way that I will explain but I was not successful with that !:

    I would like the program itself chooses the pairs randomly from the pool. I mean in each trial I need 60 pairs that should be selected randomly from the pool pics. How I can change the code to reach to this goal?

    moreover, I also should mention that I have six different categories (h.fo; un.fo ; h.de; un.de; h.ap; un.ap) which should be selected as pairs. Each of these categories are consisting of different pictures. For instance h.fo consists of 6 different pictures (h.fo.1; h.fo.2; h.fo.3; h.fo.4; h.fo.5; h.fo.6) and un.fo consists of 6 different pictures (un.fo.1; un.fo.2; un.fo.3; un.fo.4; un.fo.5; un.fo.6).This is also same for the other categories. I want the pairs of pictures be selected from the pictures of these categories (even from same categories such as h.fo and h.fo together). How I should manage that all pairs that I like have been selected? For instance, h.fo with un.fo and h.de with un.de and so on.

    My second question: I have two loops and subsequently, two different form_base. I want the pairs of the first loop (and its related form_base) be different from the second one. How I should control this?

    I really appreciate if you answer these questions since my design should be ready as soon as possible and I cannot find how I should change these things. Thank you in advance.

    Regards,
    Pa

  • edited 10:17AM

    Hi Pa,

    First off, please don't post your question multiple times and/ or send emails to the forum moderators in order to get a quick answer. I know that it can be stressful to be on a deadline, but 'pushy' behavior goes against forum etiquette.

    Regarding your questions. There's quite a lot of them, but let's start by making sure that you're not misunderstanding the role of forms in mouse tracking, because it sounds like you might be: A form does not do any tracking of mouse coordinates. Therefore, for the purpose of mouse tracking, forms are not very useful, except to implement things such as a start button that needs to be pressed before the mouse tracking begins.

    In your case, it sounds like you want the following:

    1. Show a start button that participants should click
    2. Present two images
    3. Collect the trajectory of the mouse while participants click on one of these two images.

    You could implement this as follows:

    1. Use a form_base to present a start button.
    2. Show two images using a sketchpad. Set the duration to 0 ms.
    3. Use the inline_script that you have (or a variation thereof) to do the actual mouse tracking.

    Does that make sense? So you don't use a form for the mouse tracking itself.

    Regarding your other questions. You probably don't want to hear this if you're on a deadline, but I would really walk through some of basic Python tutorials first. In your code you mix OpenSesame script with Python script, which are two entirely different languages that you cannot mix in a single script. The difference between the two is described here:

    And some good Python tutorials are linked to here:

    Once you have a basic grasp of Python, @EoinTravers has made an excellent tutorial that describes how to implement a mouse tracking paradigm. I suspect that this tutorial will be immensely helpful for you:

    Good luck!
    Sebastiaan

  • edited 10:17AM

    Dear Sebastiaan,

    Actually, I am sorry if I crossed the forum's rules with posting the last question two times! I have always appreciated your help and support and I did not want to force forum to answer my question!

    About the mouse tracking issue, you are right, during the days after that question I found out that the form-base is not suitable for this purpose. So what you have suggested is completely true.

    About the other question, thank you so much for sending the links. Sure, I will read them and try to solve the problem.

    Best Regards,
    PA

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