def __init__(self,noisetag,*args,**kwargs): super(DrawWindow,self).__init__(*args,**kwargs) self.frame=0 self.segments=[] self.objIDs=[] self.noisetag=None self.lastfliptime=0 self.flipstats=sumstats() self.fliplogtime=self.lastfliptime self.noisetag=noisetag
#------------------------------------------------------------------------ # Initialization: display, utopia-connection # use noisetag object as time-stamp provider def getTimeStamp(): if 'nt' in globals(): global nt return nt.getTimeStamp() else: # fall back if not connected to utopia client import time return (int(time.perf_counter()*1000) % (1<<31)) import types from mindaffectBCI.noisetag import sumstats flipstats=sumstats(); fliplogtime=0 def timedflip(self): '''pseudo method type which records the timestamp for window flips''' type(self).flip(self) olft=self.lastfliptime self.lastfliptime=getTimeStamp() flipstats.addpoint(self.lastfliptime-olft) global fliplogtime if self.lastfliptime > fliplogtime: fliplogtime=fliplogtime+5000 print("\nFlipTimes:"+str(flipstats)) print("Hist:\n"+flipstats.hist()) def initPyglet(fullscreen=False): '''intialize the pyglet window, keyhandler''' global window
else: # end self.screen = None #------------------------------------------------------------------------ # Initialization: display, utopia-connection # use noisetag object as time-stamp provider def getTimeStamp(): global nt return nt.getTimeStamp() import types from mindaffectBCI.noisetag import sumstats flipstats = sumstats() fliplogtime = 0 def timedflip(self): '''pseudo method type which records the timestamp for window flips''' type(self).flip(self) olft = self.lastfliptime self.lastfliptime = getTimeStamp() flipstats.addpoint(self.lastfliptime - olft) global fliplogtime if self.lastfliptime > fliplogtime: fliplogtime = fliplogtime + 5000 print("\nFlipTimes:" + str(flipstats)) print("Hist:\n" + flipstats.hist())
pyglet.app.exit() # terminate app when noisetag is done return # draw the display with the instructed colors if target_state is not None and target_state >= 0: print("*" if target_state > 0 else '.', end='', flush=True) else: print('.', end='', flush=True) if stimulus_state: draw_squares(state2color[stimulus_state[0]], state2color[stimulus_state[1]]) # used to record statistics about the flip timing -- for debugging logTime = 0 ss = sumstats() # override window's flip method to record the exact *time* the # flip happended import types def timedflip(self): '''pseudo method type which records the timestamp for window flips''' type(self).flip(self) # call the 'real' flip method... oft = self.lastfliptime self.lastfliptime = nt.getTimeStamp() ss.addpoint(self.lastfliptime - oft) global logTime if self.lastfliptime > logTime: print("\nFlipTimes:" + str(ss))