Howdy, Stranger!

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

Supported by

psychopy visual TypeError: 'str' object is not callable

edited May 28 in OpenSesame

Hi there,

I am writing to ask for your help because I get an error in my OpenSesame script that I can't really solve.

In my program there is an algorithm running which changes state (i.e. seizure/non-seizure) detecting in real time a stream of EEG data. The algorithm runs with a clock that is independent from the clock of the main experiment (i.e. the visual stimuli presentation). Using the psycho back-end, stimuli and a background animated background are shown. The subject has to press a Joystick button (implemented via PyGame) in order to give the right response. Therefore, while the subject sees the stimuli appear on the screen and responds to them by pressing the Joystick button, the algorithm processes the EEG data and makes the stimuli change according to the state the algorithm enters.

What happens is that anytime the algorithm enters the "seizure" state and the subject does not press the button in time, the function I repeatedly use both for the practice and the experimental session during a "non-seizure" state, does not work. I get this error: TypeError: 'str' object is not callable

The function I am talking about is the following:

def no_resp():
    draw_after()
    TextStim3.draw()
    win.flip()
    clock.sleep(1000)

In particular the error in no_resp() is related to the line of win.flip(), which sounds very weird to me because all the other functions defined (which use win.flip() as well) when the subject gives both a correct or a wrong button press work fine in both states of the algorithm. Here it is how these functions are called in the inline script I use for stimuli presentation:

#If correct answer is given within time
if var.responseKey == var.correct_response:
     [var.resRate_seizure, var.accu_seizure] = good_resp(var.resRate_seizure, var.accu_seizure)
#If false answer is given within time
elif var.responseKey != var.correct_response and var.responseTime != 0:
     var.resRate_seizure = false_resp(var.resRate_seizure)
#No response
elif var.responseTime == 0:
     no_resp()

Also, the same function (i.e. no_resp()) works perfectly during the practice trial and in the "non-absence" state of the algorithm.


I tried to check if any possible string I defined would show a similar name to win.flip. I tried to readdress all the win I have in the program (e.g. Distractor_r = visual.Circle(win =win, units="pix", radius=50, fillColor=random.choice(["green", "Blue", "Red", "Magenta", "Orange"]), pos = (-800,85)).

I also tried to remove the function from that condition (i.e. elif var.responseTime == 0:) and just print something. In that case the error still persists on win.flip(), but this time it appears in the pre-stimuli animated background that is shown before stimuli are presented.

I have a hard time understanding what is happening. Can you maybe help me figuring it out? Is something somebody is familiar with as well?


Thanks a lot in advance for your time!


Best,

Valentina

Comments

  • Hi @Valeebarons ,

    If the error indeed originates from win.flip() then this means that somewhere a str is assigned to this (win.flip = 'a string'), so that what should be a function has become a str .

    But are you sure that the error originates from this line? Can you post the full error message, including the traceback and the item stack?

    -- Sebastiaan

    Buy Me A Coffee

  • edited June 1

    Hi Sebastiaan,

    Here it is:

    item: Stimuli
    phase: run
    item-stack: experiment[run].Real_exp[run].absence_loop[run].absence_trial[run].Stimuli[run]
    exception type: TypeError
    exception message: 'str' object is not callable
    


    Traceback:
    File "C:\Users\vb\Anaconda3\envs\opensesame-py3\lib\site-packages\libopensesame\inline_script.py", line 116, in run
      self.workspace._exec(self.crun)
     File "C:\Users\vb\Anaconda3\envs\opensesame-py3\lib\site-packages\libopensesame\base_python_workspace.py", line 124, in _exec
      exec(bytecode, self._globals)
     Inline script, line 47, in <module>
     Inline script, line 115, in no_resp
     File "C:\Users\vb\Anaconda3\envs\opensesame-py3\lib\site-packages\psychopy\visual\window.py", line 1132, in flip
      callEntry['function'](*callEntry['args'], **callEntry['kwargs'])
    TypeError: 'str' object is not callable
    


    Line 47 in module corresponds to no_resp(), and line 115 in no_resp() corresponds to win.flip.


    Thank you for your help.


    Best,


    Valentina

  • Hi @Valeebarons ,

    Are you trying to register a function by calling win.callOnFlip() and then accidentally passing a string rather than a function to it?

    — Sebastiaan

    Buy Me A Coffee

  • Hi Sebastiaan,

    ouch, yes that was the case, I forgot to add the function in one of the win.callOnFlip() I am using. My bad.

    Thank you so much for your help!!


    Best,


    Valentina

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