0

I'm trying to add a timestamp in my code using the TrialHandler.addData() methode. However, the precision of the underlying array makes it impossible to get the exact value I need.

print(core.getAbsTime())    
hand.addData('time', core.getAbsTime())
print(hand.data['time'])
#prints 1410454966
#       [[1410454912.0] ...

Is there a way to change the underlying type to be able to acheive the needed precision?

Olivier
  • 153
  • 3
  • 5

1 Answers1

2

You probably don't want to use core.getAbsTime() which returns the unix timestamp. It is not mean for timing in experiments. For timing of events in the experiments use

myClock = core.Clock()
myClock.reset()  # start timing
# do something here
elapsedTime = myClock.getTime()  # yay

... which returns the time in microseconds. Se the documentation for core.Clock and core.getAbsTime() in psychopy.core documentation and in the Coder demos.

If you want the absolute time (year, hour, minutes etc.), see the time python module or search Google for similar modules and methods.

Jonas Lindeløv
  • 5,442
  • 6
  • 31
  • 54