Howdy, Stranger!

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

Supported by

Use Expyriment script on Android devices

I would like use simple Scripts, made with Expyriment, for visual stimuli presentations and answer collections on a samsung galaxy Tab S2 (android 7.0). But I have problems when I try to run them. The example experiments "line-bisection.py" works correctly but if I only add the drawing of a circle or the use of circular (instead of rectangular) keys the program no longer works. Can you tell me what is the problem or what I wrong? There are limitations on the Python/Expyriment commands that are recognized during the execution of experiments in android. Thank you.

Comments

  • Very difficult to say without knowing your code, sorry.

  • This is the code:

    I wrote in bold the changes to the original program "line-bisection.py"

    Thanks you

    very much


    #!/usr/bin/env python

    # -*- coding: utf-8 -*-


    """

    A line bisection task.

    This example is appropriate to illustrates the use of the Android runtime environment for Exypriment on tablet PC.

    """

    from __future__ import division


    from expyriment import control, stimuli, io, design, misc


    # settings

    design.defaults.experiment_background_colour = misc.constants.C_GREY

    design.defaults.experiment_foreground_colour = misc.constants.C_BLACK

    line_length = 200


    def line_bisection_task(line_length, position):

      # make button

      button = stimuli.Rectangle(size=(40,20),

            position=(exp.screen.size[0]//2-25, 15-exp.screen.size[1]//2))

      button_text = stimuli.TextLine(text="ok", position=button.position, text_colour=misc.constants.C_WHITE)

      mark_position = None

      while True:

        canvas = stimuli.BlankScreen()

        line = stimuli.Rectangle(size=(line_length,3), position=position,

              colour=misc.constants.C_BLACK)

        line.plot(canvas)

        if mark_position is not None:

          # plot button and mark line on canvas

          button.plot(canvas)

          button_text.plot(canvas)

          markline = stimuli.Rectangle(size=(1,25),

                position=(mark_position, line.position[1]),

                colour=misc.constants.C_RED)

          markline.plot(canvas)

        # present stimulus

        canvas.present()

        # wait for mouse or touch screen response

        _id, pos, _rt = exp.mouse.wait_press()

        # process clicked position position

        if abs(pos[1]-line.position[1])<=50 and\

              abs(pos[0]-line.position[0])<=line_length//2:

          mark_position = pos[0]

        else:

          if button.overlapping_with_position(pos): # is button pressed

            return mark_position - line.position[0]


    ### init ###

    exp = control.initialize()


    # create touch button box

    buttonA = stimuli.Circle(radius= 20, position=(-60, 0))

    buttonB = stimuli.Circle(radius= 20, position=(60, 0))

    textA = stimuli.TextLine(text="quit", position=buttonA.position, text_colour=misc.constants.C_WHITE)

    textB = stimuli.TextLine(text="next", position=buttonB.position, text_colour=misc.constants.C_WHITE)

    touchButtonBox = io.TouchScreenButtonBox(button_fields=[buttonA, buttonB], stimuli=[textA, textB])

    ### start ###

    control.start(exp)

    exp.mouse.show_cursor()


    # trial loop

    while True:

      # find random position

      rx, ry = ((exp.screen.size[0]-line_length)//2, (exp.screen.size[1]-50)//2)

      pos = [design.randomize.rand_int(-rx, rx), design.randomize.rand_int(-ry, ry)]

      # present task

      judgment = line_bisection_task(line_length, position=pos)

      # save data

      exp.data.add(pos +[judgment])

      # ask for new trail

      touchButtonBox.show()

      btn, _rt = touchButtonBox.wait()

      if btn==buttonA:

        break


    ## end##

    control.end()

  • The Android Runtime is currently still based on Expyriment 0.7.0. The Circle stimulus in this release does not have a parameter called "radius", but one called "diameter".

  • I have installed experiment 0.7.0 on my PC and modified the program. Now it works correctly on the PC and on the tablet.

    Thanks you very much

  • Glad it works now for you!

  • I would like to know if it is possible to create a python/Expyriment 7 code to record vocal responses. This is because the code should then be used on an android tablet; this code should then be usable with the Expyriment's App on an android tablet.

    Thank you.

  • You could have a look at sounddevice maybe.

  • Yes, sounddevice should be fine but I think it is not present in the Android Runtime and I can't use it with the tablet.

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