Error Window.getTimeOnFlip() after switching to USB

Hi all,

First time posting, if I’m incomplete, sorry and please indicate what I’m doing wrong (I’m a psychopy dummy). We programmed an experiment with a digitimer shock machine. We reprogrammed the code to give the ttl signal via USB instead of a parallel port (and changed some of the underlying files).

Before we did so and without connection to the machine, our programming worked, but our adjustments now provide the following error:
Traceback (most recent call last):
File “C:\Users\lenovo\Desktop\shocks\shock paradigm\trial_v1.py”, line 740, in
win.flip()
File “C:\users\nazanin\python\lib\site-packages\psychopy\visual\window.py”, line 847, in flip
callEntry[‘function’](*callEntry[‘args’], **callEntry[‘kwargs’])
File “C:\users\nazanin\python\lib\site-packages\psychopy\visual\window.py”, line 721, in _assignFlipTime
.format(repr(obj)))
TypeError: Window.getTimeOnFlip() should be called with an object and its
attribute or a dict and its key. In this case it was called with obj=<psychopy.visual.image.ImageStim object at 0x000001FAB1CD3B70>

Our current code is here: https://www.dropbox.com/sh/goofs7u3ql17pkb/AABqrHeVaaTntkz0foa-uA16a?dl=0 (our last changes that may have caused the errors are documented there, which may help). Does anyone have an idea what is going on?

Your chances of getting help would be increased if you can narrow down the region of code rather than post multiple .py files in the hope that someone will read through all of them.

I haven’t delved into those files. But my guess if that this is likely to be related to a line where you call win.timeOnFlip(something)

Can you provide that line/those lines specifically here, and indicate what you intend them to achieve?

hi Michael,

thanks a bunch and sorry about that. Yes, sure. I am first including line 740 from the above errors

Then next, I am including the win.timeOnFlip where comment did work (the experiment ran through the training block without a problem. In the training block, we do not shock yet).

Then I am including where the program stops (this is the actual experimental phase, where we started shocking).
(This image will follow in a reply, I could not add more than two)

Just some other background: from the last version (where did this work) to this, we switched from parallel to USB. In order to do so, we created an init.py file and created a usbTtl/ directory, and changed a text.py file in the visual directory. Not sure if I am clear enough (I was not the programmer and getting help, but will send the post as well to the programmer).

additional image.

As far as I can see the USB/parallel aspect it not the issue.

The error is to do with the call to win.getTimeOnFlip() in relation to the ImageStim not the USB port.

I think this is the change where you did the damage (around line 27):

-        trialsComponents = [stimuli2, p_port]
+        #trialsComponents = [stimuli2, p_port]
+        trialsComponents = [usb_ttl]

You turned off resetting the timestamps for stimuli2, and then it failed to update the timestamps for stimuli2. You could fix by turning off the stimuli2 timestamping (in the data tab for that component) or reverting this line to what it was (unless this change was needed?)

(As an aside, my guess is that you’ve compiled the script into Python and then hacking the script rather than using Code Components inside Builder, which is what I’d recommend).

hi Jon, thanks a bunch for your reply and sorry for my late reply. We are trying to look into this right now. We will keep you updated if this resolves the issue.

1 Like