Howdy, Stranger!

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

Supported by

[solved] Using Parallel plug-in in OpenSesame

edited November 2015 in OpenSesame

I want to display two blocks (say squares) that will blink with two different frequencies, on the screen. How can I achieve this using the 'parallel plug-in' in OpenSesame?

Comments

  • edited 1:50AM

    Hi,

    I have no experience in using the parallel plug-in myself (and I've also heard that it is a bit unstable), but I do think this is achievable without the parallel plug-in in the first place. How well it works depends on the desired frequencies though; very high frequencies may not be displayed properly.
    The idea would be to create 4 canvases in an inlinescript, one for each 'state', i.e., a canvas with two squares on, a canvas with one square on and one square off, etc. In the run phase, you start a timer by means of start_time = self.time(). Next, you keep track of time in a while-loop, and present the canvases accordingly. Say these are the frequencies and states (1 for on, -1 for off):

      square1_freq = 12
      square2_freq = 8
      square1_state = 1
      square2_state = 1 
    

    As an example, you want the second square to go on/off at 1/8*1000 milliseconds and all multiplications of this value. Hence, you get something like this:

      end_reached = False
      stimuli_presentation_duration = 2000
    
      current_multiplication_sq1 = 1
      current_multiplication_sq2 = 1      
      while end_reached == False:
             canvas_change = False
             current_time = self.time() - start_time
             if current_time >= float(1)/square1_freq*1000*current_multiplication_sq1:
                   square1_state = square1_state * -1
                   current_multiplication_sq1 += 1
                   canvas_change = True
             if current_time >= float(1)/square2_freq*1000*current_multiplication_sq2:
                   square2_state = square2_state * -1
                   current_multiplication_sq2 += 1
                   canvas_change = True
    
             if canvas_change == True:
                   if square1_state == 1 and square2_state == 1:
                          canvas1.show()
                   elif square1_state == -1 and square2_state == 1:
                          canvas2.show()
                   elif square1_state == 1 and square2_state == -1:
                          canvas3.show()
                   elif square1_state == -1 and square2_state == -1:
                          canvas4.show()
    
             if current_time >= stimuli_presentation_duration:
                   end_reached = True      
    

    Let me know if this works.

    Cheers,

    Josh

  • edited November 2015

    Hi Josh,

    Thanks for the tip.
    I'm a kinda new to OpenSesame and it took me a while to understand the use of inline code. I compiled the code and run it with 4 sketchpads c1, c2, c3, c4 in the experiment modifying your code as shown below.


    start_time = self.time() square1_freq = 12 square2_freq = 8 square1_state = 1 square2_state = 1 canvas1 = canvas() canvas2 = canvas() canvas3 = canvas() canvas4 = canvas() canvas1.c1() canvas2.c2() canvas3.c3() canvas4.c4() end_reached = False stimuli_presentation_duration = 2000 current_multiplication_sq1 = 1 current_multiplication_sq2 = 1 while end_reached == False: canvas_change = False current_time = self.time() - start_time if current_time >= float(1)/square1_freq*1000*current_multiplication_sq1: square1_state = square1_state * -1 current_multiplication_sq1 += 1 canvas_change = True if current_time >= float(1)/square2_freq*1000*current_multiplication_sq2: square2_state = square2_state * -1 current_multiplication_sq2 += 1 canvas_change = True if canvas_change == True: if square1_state == 1 and square2_state == 1: canvas1.show() elif square1_state == -1 and square2_state == 1: canvas2.show() elif square1_state == 1 and square2_state == -1: canvas3.show() elif square1_state == -1 and square2_state == -1: canvas4.show() if current_time >= stimuli_presentation_duration: end_reached = True

    But it reported me the following error.


    File "dist\libqtopensesame\misc\process.py", line 140, in run File "dist\libopensesame\experiment.py", line 390, in run File "dist\libopensesame\item_store.py", line 94, in execute File "dist\libopensesame\item_store.py", line 126, in prepare File "dist\libopensesame\sequence.py", line 106, in prepare File "dist\libopensesame\item_store.py", line 126, in prepare File "dist\libopensesame\sketchpad.py", line 103, in prepare File "dist\openexp\_canvas\xpyriment.py", line 98, in prepare File "dist\expyriment\stimuli\_visual.py", line 752, in plot File "dist\expyriment\stimuli\_visual.py", line 289, in surface_size File "dist\expyriment\stimuli\_visual.py", line 391, in _get_surface File "dist\expyriment\stimuli\_rectangle.py", line 112, in _create_surface error: Invalid resolution for Surface

    Can you please help me to get out of this?

    Cheers.

    Sachinthana

  • edited 1:50AM

    Hi Sachinthana,

    How did you construct (i.e. place the squares on) your canvases? At first glance it seems to me that something went wrong there. You could try to present your canvases in a simplified manner, like this:

       canvas1.show()
       self.sleep(5000)
       canvas2.show()
       self.sleep(5000)   # et cetera.
    

    and see if that works normally.

    Cheers,

    Josh

  • edited 1:50AM

    Hey Josh,

    It worked. Thank you very much. :)

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