Howdy, Stranger!

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

Supported by

[open] Random dot motion

edited April 2014 in OpenSesame

Hello, I heard there's an already implemented "Random dot motion" task in open sesame which i couldn't found in the standard tasks section. Is this task indeed available? Thanks, Rotem

Comments

  • edited 11:29PM

    What makes you think that this task has been implemented already? It could be, but I don't recall any mentions of it here on the forum.

    At any rate, it shouldn't be too hard to implement this using PsychoPy's DotStim.

    All parameters are documented under the link above, but the following script shows the basic idea:

    from psychopy.visual import DotStim
    # Create a DotStim, which is automatically updated with every `draw()` call.
    ds = DotStim(win, fieldSize=400, speed=10, dotLife=100, nDots=100, coherence=.5)
    # Show 100 frames
    for i in range(100):
        ds.draw()
        win.flip()
    

    Cheers!
    Sebastiaan

  • edited April 2014

    Thanks...I read about the phyton and inline scripts.
    Should i copy the following script also to the prepare and run phases?

    class psychopy.visual.DotStim(win, units='', nDots=1, coherence=0.5, fieldPos=(0.0, 0.0), fieldSize=(1.0, 1.0), fieldShape='sqr', dotSize=2.0, dotLife=3, dir=0.0, speed=0.5, rgb=None, color=(1.0, 1.0, 1.0), colorSpace='rgb', opacity=1.0, contrast=1.0, depth=0, element=None, signalDots='same', noiseDots='direction', name='', autoLog=True) 
    
  • edited 11:29PM

    No, that's part of the definition of the class! That's part of the PsychoPy module, you don't need to include it yourself.

    The only thing that you need to do to get a working example is copy the example script above into the run phase of an inline_script. However, there appears to be a problem with the fieldSize parameter of the DotStim class, as described here:

    This only affects recent versions of PsychoPy, which included with OpenSesame 2.8.1, but not 2.8.0. So if you this affects you as well, you can downgrade to 2.8.0 for now.

    If you have no experience with Python, I would also recommend walking through one of the many tutorials. If you want to work with these kinds of stimuli, you will certainly need a basic knowledge of Python:

    Cheers!
    Sebastiaan

  • edited 11:29PM

    Hey, I did the short basic python course plus now i have the random dot task in open sesame. The only thing is that i cant measure R.T cause the response is programmed after each frame. How can i change it so the subjects can response during the motion viewing?

  • edited 11:29PM

    Hi,

    Could you please upload your experiment (for example to pastebin), or at least post the inline_script that is relevant to your question?

    Cheers,
    Sebastiaan

  • edited April 2014

    Hi all,

    I'm trying to create an experiment with two circular areas filled with moving dots (RDK), on the left and right of a central fixation cross. See the picture I attached to get an idea of my ideal arrangement.

    image

    http://img.cogsci.nl/?q=5347ad6711830

    I managed to create the two circles filled with the dots moving on the xy plane (e.g. orizontally) using dotStim.
    BUT cannot get the same with the dot moving radially. I know there's the starField demo in Psychopy (I tried it in the stand alone version of that software). The problem is that it lets me create only a fullscreen scene of radially moving dots.
    I tried to create two circular areas (using fieldShape and fieldSize of ElementArrayStim) on the left and right visual fields (using fieldPos), but running the code I only get the background (monitor units = norm).

    Could you please give me a hint on this?
    Looking forward to hearing from you.

    Thanks in advance,
    Ambra

  • edited 11:29PM

    Hey Sebastiaan,
    Here it is
    http://pastebin.com/RphaaFKX
    Appriciate your help...

  • edited 11:29PM

    Hi @Rotem,

    In your case, you need to alternate between showing the DotStim and polling the keyboard. So simply inserting a keyboard_response item after the inline_script won't do the trick. What you need to is poll for keypresses in the same loop that you use to present the DotStim, for example like so:

    from psychopy.visual import DotStim
    from psychopy import event
    # Create a DotStim, which is automatically updated with every `draw()` call.
    ds = DotStim(win, fieldSize=900, speed=4, dotLife=3, nDots=400, coherence= \
        self.get('coher'),dotSize=2.0,signalDots='different',dir=self.get('dir'), \
        noiseDots='walk')
    # Show 100 frames
    t0 = self.time()
    while True:
        ds.draw()
        win.flip()
        # Get a list of pressed keys and break out of the loop as soon as this list
        # is not empty. Also note the timestamp of the response (t1)
        keys = event.getKeys(keyList=['s', 'l'])
        if keys != []:
            t1 = self.time()
            break
    # The response is the first pressed key (and usually the only one)
    response = keys[0]
    # The RT is the difference between t1 and t0
    response_time = t1 - t0
    # Set these response so that they are logged, etc.
    exp.set('response', response)
    exp.set('response_time', response_time)
    

    See also:

    Cheers!
    Sebastiaan

  • edited 11:29PM

    Hi Ambra (@ambraferrari),

    The DotStim only supports coherent motion in one direction. If you want to create radially moving dots, you need to implement this manually using the ElementArrayStim. It's actually not that difficulty, and all options are described in the PsychoPy documentation:

    To get you started, here's a working example, modified from the starField demo. Just walk through the code line-by-line and try to understand the logic, which is less complicated than it may seem. If you are not familiar with Python, I would also recommend walking through a basic tutorial first:

    (Note this bug related to the fieldSize keyword.)

    Cheers,
    Sebastiaan

    # Modified from
    # https://github.com/psychopy/psychopy/blob/master/psychopy/demos/coder/stimuli/starField.py
    
    from psychopy import visual, event
    from psychopy.tools.coordinatetools import pol2cart
    import numpy
    
    # The number of dots
    nDots = 500
    # The maximum speed of the dots
    maxSpeed = 10
    # The size of the field. Note that you also need to modify the `fieldSize`
    # keyword that is passed to `ElementArrayStim` below, due to (apparently) a bug
    # in PsychoPy
    fieldSize = 200
    # The size of the dots
    dotSize = 2
    # The number of frames
    nFrames = 1000
    
    # Initial parameters
    dotsTheta=numpy.random.rand(nDots)*360
    dotsRadius=(numpy.random.rand(nDots)**0.5)*200
    speed=numpy.random.rand(nDots)*maxSpeed
    
    # Create the stimulus array
    dots = visual.ElementArrayStim(win, elementTex=None, fieldShape='circle', \
        elementMask='circle', nElements=nDots, sizes=dotSize, units='pix', \
        fieldSize=10000)
    
    # Walk through each frame, update the dot positions and draw it
    for frameN in range(100):
        #update radius
        dotsRadius = (dotsRadius+speed)
        #random radius where radius too large
        outFieldDots = (dotsRadius>=fieldSize)
        dotsRadius[outFieldDots] = numpy.random.rand(sum(outFieldDots))*fieldSize
        dotsX, dotsY = pol2cart(dotsTheta,dotsRadius)
        dots.setXYs(numpy.array([dotsX, dotsY]).transpose())
        dots.draw() 
        win.flip()
    
  • edited May 2014

    Hi Sebastiaan,

    thanks for your help, your example works well. I now have my two experiments with:

    1. dots moving horizontally (left/right)
    2. dots moving radially (in/out)

    I'm now facing a new problem: how can I compare the dots speed across the two experiments? My aim is to make the dots move at the same speed, but in two different directions (horizontal vs. radial). So, I need to have equal speeds between the two experiments.
    In both I set units='pix' in the stimuli generation (inside DotStim() in 1. and inside ElementArrayStim() in 2.) so I guess speed is expressed in pixels/frame (or pixel/sec ...?)
    Is there a way to check for this?

    Empirically I see this: if I set the same speed in both experiments, the dots move much faster horizontally, so I have to decrease by a factor of 10 to gain perceptually comparable speeds. I am wondering what is the proper method to gain physically comparable speeds.

    Note that I changed your script above:
    from

    speed=numpy.random.rand(nDots)*maxSpeed -> different values of speed
    to
    speed=k (now set to 2) -> same value of speed for all the dots

    Maybe of interest:
    I'm working on Windows
    My monitor resolution: 1280 x 800
    My refresh rate: 60 Hz

    Thanks again,
    Ambra

  • edited May 2014

    Hi Ambra,

    Provided that you change the speed of the 'starfield' to a fixed value, which you appear to have done, both speeds are expressed in pixels per frame. And they do in fact move equally quickly for me, if I specify the same speed. Perhaps the framerate differs between the two stimuli? To check this, I would time the frame durations of both stimuli with a structure like this:

    t0 = self.time()
    for frameN in range(100):
        dots.draw() 
        ds.draw()
        win.flip()
        t1 = self.time()
        print 'frame duration: %.2f' % (t1-t0)
        t0 = t1
    

    If the frame duration of the starfield is higher than that of the dotStim then you will have to take this into account when specifying the speed. (or get a better system!)

    Is that it, you think?

    Cheers!
    Sebastiaan

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