• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python clock.get_time函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pygaze.libtime.clock.get_time函数的典型用法代码示例。如果您正苦于以下问题:Python get_time函数的具体用法?Python get_time怎么用?Python get_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_time函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_key

	def get_key(self, keylist='default', timeout='default', flush=False):

		# See _keyboard.basekeyboard.BaseKeyboard
		
		# set keylist and timeout
		if keylist == 'default':
			keylist = self.klist
		if timeout == 'default':
			timeout = self.timeout

		# flush if necessary
		if flush:
			psychopy.event.clearEvents(eventType='keyboard')

		# starttime
		starttime = clock.get_time()
		time = clock.get_time()

		# wait for input
		while timeout == None or time - starttime <= timeout:
			keys = psychopy.event.getKeys(keyList=keylist,timeStamped=False)
			for key in keys:
				if keylist == None or key in keylist:
					return key, clock.get_time()
			time = clock.get_time()

		return None, time
开发者ID:KurtisReid,项目名称:PyGaze,代码行数:27,代码来源:psychopykeyboard.py


示例2: wait_for_blink_start

    def wait_for_blink_start(self):
        """See pygaze._eyetracker.baseeyetracker.BaseEyeTracker"""

        # # # # #
        # EyeLink method

        if self.eventdetection == 'native':
            t, d = self.wait_for_event(pylink.STARTBLINK)
            return t, d.getTime()

        # # # # #
        # PyGaze method

        else:

            blinking = False

            # loop until there is a blink
            while not blinking:
                # get newest sample
                gazepos = self.sample()
                # check if it's a valid sample
                if not self.is_valid_sample(gazepos):
                    # get timestamp for possible blink start
                    t0 = clock.get_time()
                    # loop until a blink is determined, or a valid sample occurs
                    while not self.is_valid_sample(self.sample()):
                        # check if time has surpassed 150 ms
                        if clock.get_time() - t0 >= 150:
                            # return timestamp of blink start
                            return t0
开发者ID:neuropil,项目名称:PyGaze,代码行数:31,代码来源:libeyelink.py


示例3: get_key

	def get_key(self, keylist='default', timeout='default', flush=False):

		# See _keyboard.basekeyboard.BaseKeyboard
		
		# set keylist and timeout
		if keylist == 'default':
			keylist = self.klist
		if timeout == 'default':
			timeout = self.timeout
		
		# flush if necessary
		if flush:
			pygame.event.get(pygame.KEYDOWN)
			
		# starttime
		starttime = clock.get_time()
		time = clock.get_time()

		# wait for input
		while timeout == None or time - starttime <= timeout:
			time = clock.get_time()
			for event in pygame.event.get():
				if event.type == pygame.KEYDOWN:
					time = clock.get_time()
					key = pygame.key.name(event.key)
					if keylist == None or key in keylist:
						return key, time
					
		# in case of timeout
		return None, time
开发者ID:AA33,项目名称:PyGaze,代码行数:30,代码来源:pygamekeyboard.py


示例4: wait_for_saccade_start

    def wait_for_saccade_start(self):
        """See pygaze._eyetracker.baseeyetracker.BaseEyeTracker"""

        # # # # #
        # EyeLink method

        if self.eventdetection == 'native':
            t, d = self.wait_for_event(pylink.STARTSACC)
            return t, d.getStartGaze()

        # # # # #
        # PyGaze method

        else:

            # get starting position (no blinks)
            newpos = self.sample()
            while not self.is_valid_sample(newpos):
                newpos = self.sample()
            # get starting time, position, intersampledistance, and velocity
            t0 = clock.get_time()
            prevpos = newpos[:]
            s = 0
            v0 = 0

            # get samples
            saccadic = False
            while not saccadic:
                # get new sample
                newpos = self.sample()
                t1 = clock.get_time()
                if self.is_valid_sample(newpos) and newpos != prevpos:
                    # check if distance is larger than precision error
                    sx = newpos[0] - prevpos[0]
                    sy = newpos[1] - prevpos[1]
                    # weigthed distance: (sx/tx)**2 + (sy/ty)**2 > 1 means
                    # movement larger than RMS noise
                    if (sx/self.pxdsttresh[0])**2 + (sy/self.pxdsttresh[1])**2 \
                     > self.weightdist:
                        # calculate distance
                        # intersampledistance = speed in pixels/ms
                        s = ((sx)**2 + (sy)**2)**0.5
                        # calculate velocity
                        v1 = s / (t1 - t0)
                        # calculate acceleration
                        a = (v1 - v0) / (t1 - t0
                                         )  # acceleration in pixels/ms**2
                        # check if either velocity or acceleration are above
                        # threshold values
                        if v1 > self.pxspdtresh or a > self.pxacctresh:
                            saccadic = True
                            spos = prevpos[:]
                            stime = clock.get_time()
                        # update previous values
                        t0 = copy.copy(t1)
                        v0 = copy.copy(v1)
                    # udate previous sample
                    prevpos = newpos[:]
            return stime, spos
开发者ID:neuropil,项目名称:PyGaze,代码行数:59,代码来源:libeyelink.py


示例5: wait_for_saccade_end

	def wait_for_saccade_end(self):

		"""See pygaze._eyetracker.baseeyetracker.BaseEyeTracker"""

		# # # # #
		# EyeLink method
		
		if self.eventdetection == 'native':
			d = self.wait_for_event(pylink.ENDSACC)
			return d.getTime(), d.getStartGaze(), d.getEndGaze()
		
		
		# # # # #
		# PyGaze method
		
		else:
		
			# get starting position (no blinks)
			t0, spos = self.wait_for_saccade_start()
			# get valid sample
			prevpos = self.sample()
			while not self.is_valid_sample(prevpos):
				prevpos = self.sample()
			# get starting time, intersample distance, and velocity
			t1 = clock.get_time()
			# = intersample distance = speed in px/sample
			s = ((prevpos[0]-spos[0])**2 + (prevpos[1]-spos[1])**2)**0.5
			v0 = s / (t1-t0)
			# run until velocity and acceleration go below threshold
			saccadic = True
			while saccadic:
				# get new sample
				newpos = self.sample()
				t1 = clock.get_time()
				if self.is_valid_sample(newpos) and newpos != prevpos:
					# calculate distance
					# = speed in pixels/sample
					s = ((newpos[0]-prevpos[0])**2 + \
						(newpos[1]-prevpos[1])**2)**0.5
					# calculate velocity
					v1 = s / (t1-t0)
					# calculate acceleration
					# acceleration in pixels/sample**2 (actually is
					# v1-v0 / t1-t0; but t1-t0 = 1 sample)
					a = (v1-v0) / (t1-t0)
					# check if velocity and acceleration are below threshold
					if v1 < self.pxspdtresh and (a > -1*self.pxacctresh and \
						a < 0):
						saccadic = False
						epos = newpos[:]
						etime = clock.get_time()
					# update previous values
					t0 = copy.copy(t1)
					v0 = copy.copy(v1)
				# udate previous sample
				prevpos = newpos[:]
	
			return etime, spos, epos
开发者ID:AA33,项目名称:PyGaze,代码行数:58,代码来源:libeyelink.py


示例6: wait_for_fixation_start

	def wait_for_fixation_start(self):

		"""See pygaze._eyetracker.baseeyetracker.BaseEyeTracker"""

		# # # # #
		# EyeLink method
		
		if self.eventdetection == 'native':
			d = self.wait_for_event(pylink.STARTFIX)
			return d.getTime(), d.getStartGaze()
		
		
		# # # # #
		# PyGaze method
		
		else:
		
			# function assumes a 'fixation' has started when gaze position
			# remains reasonably stable for self.fixtimetresh
			
			# get starting position
			spos = self.sample()
			while not self.is_valid_sample(spos):
				spos = self.sample()
			
			# get starting time
			t0 = clock.get_time()
	
			# wait for reasonably stable position
			moving = True
			while moving:
				# get new sample
				npos = self.sample()
				# check if sample is valid
				if self.is_valid_sample(npos):
					# check if new sample is too far from starting position
					if (npos[0]-spos[0])**2 + (npos[1]-spos[1])**2 > \
						self.pxfixtresh**2: # Pythagoras
						# if not, reset starting position and time
						spos = copy.copy(npos)
						t0 = clock.get_time()
					# if new sample is close to starting sample
					else:
						# get timestamp
						t1 = clock.get_time()
						# check if fixation time threshold has been surpassed
						if t1 - t0 >= self.fixtimetresh:
							# return time and starting position
							return t1, spos
开发者ID:AA33,项目名称:PyGaze,代码行数:49,代码来源:libeyelink.py


示例7: wait_for_fixation_end

	def wait_for_fixation_end(self):

		"""Returns time and gaze position when a simulated fixation is ended"""

		stime, spos = self.wait_for_fixation_start()

		return clock.get_time(), spos
开发者ID:KurtisReid,项目名称:PyGaze,代码行数:7,代码来源:libdumbdummy.py


示例8: wait_for_fixation_end

    def wait_for_fixation_end(self):
        """See pygaze._eyetracker.baseeyetracker.BaseEyeTracker"""

        # # # # #
        # EyeLink method

        if self.eventdetection == 'native':
            t, d = self.wait_for_event(pylink.ENDFIX)
            return t, d.getTime(), d.getStartGaze()

        # # # # #
        # PyGaze method

        else:

            # function assumes that a 'fixation' has ended when a deviation of
            # more than fixtresh from the initial 'fixation' position has been
            # detected

            # get starting time and position
            stime, spos = self.wait_for_fixation_start()

            # loop until fixation has ended
            while True:
                # get new sample
                npos = self.sample()  # get newest sample
                # check if sample is valid
                if self.is_valid_sample(npos):
                    # check if sample deviates to much from starting position
                    if (npos[0]-spos[0])**2 + (npos[1]-spos[1])**2 > \
                     self.pxfixtresh**2: # Pythagoras
                        # break loop if deviation is too high
                        break

            return clock.get_time(), spos
开发者ID:neuropil,项目名称:PyGaze,代码行数:35,代码来源:libeyelink.py


示例9: wait_for_fixation_start

	def wait_for_fixation_start(self):

		"""Returns starting time and position when a simulated fixation is started"""

		# function assumes a 'fixation' has started when 'gaze' position remains reasonably
		# stable for five samples in a row (same as saccade end)

		maxerr = 3 # pixels
		
		# wait for reasonably stable position
		xl = [] # list for last five samples (x coordinate)
		yl = [] # list for last five samples (y coordinate)
		moving = True
		while moving:
			npos = self.sample()
			xl.append(npos[0]) # add newest sample
			yl.append(npos[1]) # add newest sample
			if len(xl) == 5:
				# check if deviation is small enough
				if max(xl)-min(xl) < maxerr and max(yl)-min(yl) < maxerr:
					moving = False
				# remove oldest sample
				xl.pop(0); yl.pop(0)
			# wait for a bit, to avoid immediately returning (runs go faster than mouse moves)
			clock.pause(10)

		return clock.get_time(), (xl[len(xl)-1],yl[len(yl)-1])
开发者ID:esdalmaijer,项目名称:PyGaze,代码行数:27,代码来源:libdummytracker.py


示例10: wait_for_saccade_end

	def wait_for_saccade_end(self):

		"""Returns ending time, starting and end position when a simulated saccade is ended"""

		# function assumes that a 'saccade' has ended when 'gaze' position remains reasonably
		# (i.e.: within maxerr) stable for five samples
		# for saccade start algorithm, see wait_for_fixation_start

		stime, spos = self.wait_for_saccade_start()
		maxerr = 3 # pixels
		
		# wait for reasonably stable position
		xl = [] # list for last five samples (x coordinate)
		yl = [] # list for last five samples (y coordinate)
		moving = True
		while moving:
			# check positions
			npos = self.sample()
			xl.append(npos[0]) # add newest sample
			yl.append(npos[1]) # add newest sample
			if len(xl) == 5:
				# check if deviation is small enough
				if max(xl)-min(xl) < maxerr and max(yl)-min(yl) < maxerr:
					moving = False
				# remove oldest sample
				xl.pop(0); yl.pop(0)
			# wait for a bit, to avoid immediately returning (runs go faster than mouse moves)
			clock.pause(10)

		return clock.get_time(), spos, (xl[len(xl)-1],yl[len(yl)-1])
开发者ID:esdalmaijer,项目名称:PyGaze,代码行数:30,代码来源:libdummytracker.py


示例11: show_part

    def show_part(self, rect, screen=None):

        # See _display.basedisplay.BaseDisplay for documentation

        if len(rect) > 1:
            for r in rect:
                pygaze.expdisplay.set_clip(r)
                if screen:
                    pygaze.expdisplay.blit(screen.screen, (0, 0))
                pygame.display.update(r)
                pygaze.expdisplay.set_clip(None)

        elif len(rect) == 1:
            pygaze.expdisplay.clip(rect)
            if screen:
                pygaze.expdisplay.blit(screen.screen, (0, 0))
            pygame.display.update(rect)
            pygaze.expdisplay.set_clip(None)

        else:
            raise Exception(
                "Error in libscreen.Display.show_part: rect should be a single rect (i.e. a (x,y,w,h) tuple) or a list of rects!"
            )

        return clock.get_time()
开发者ID:jockehewh,项目名称:PyGaze,代码行数:25,代码来源:pygamedisplay.py


示例12: wait_for_blink_end

    def wait_for_blink_end(self):
        """See pygaze._eyetracker.baseeyetracker.BaseEyeTracker"""

        # # # # #
        # EyeLink method

        if self.eventdetection == 'native':
            t, d = self.wait_for_event(pylink.ENDBLINK)
            return t

        # # # # #
        # PyGaze method

        else:

            blinking = True

            # loop while there is a blink
            while blinking:
                # get newest sample
                gazepos = self.sample()
                # check if it's valid
                if self.is_valid_sample(gazepos):
                    # if it is a valid sample, blinking has stopped
                    blinking = False

            # return timestamp of blink end
            return clock.get_time()
开发者ID:neuropil,项目名称:PyGaze,代码行数:28,代码来源:libeyelink.py


示例13: get_joybutton

	def get_joybutton(self, joybuttonlist='default', timeout='default'):

		"""Waits for joystick buttonpress
		
		arguments
		None
		
		keyword arguments
		joybuttonlist	-- list of buttons that are allowed (e.g.
					   [0,2,4]), None to allow all buttons or
					   'default' to use jbuttonlist property
					   (default = 'default')
		timeout	-- time in milliseconds after which None is returned
				   when no buttonpress is registered; None for no
				   timeout or 'default' to use the timeout property
				   (default = 'default')
		
		returns
		button, presstime	-- button is an integer, indicating which button
					   has been pressed or None when no button has
					   been pressed
					   presstime is the time (measured from
					   expbegintime) a buttonpress or a timeout
					   occured
		"""

		# set joybuttonlist and timeout
		if joybuttonlist == 'default':
			joybuttonlist = self.jbuttonlist
		if timeout == 'default':
			timeout = self.timeout
		# register start time
		starttime = clock.get_time()
		time = starttime
		# wait for button press
		while timeout == None or time - starttime <= timeout:
			time = clock.get_time()
			for event in pygame.event.get():
				if event.type == pygame.JOYBUTTONDOWN:
					time = clock.get_time()
					if joybuttonlist == None or event.button in joybuttonlist:
						pressed = event.button
						return pressed, time
		# in case of timeout
		return None, time
开发者ID:AA33,项目名称:PyGaze,代码行数:45,代码来源:pygamejoystick.py


示例14: show_part

	def show_part(self, rect, screen=None):

		# See _display.basedisplay.BaseDisplay for documentation

		self.fill(screen)
		self.show()
		print("WARNING! screen.Display.show_part not available for PsychoPy display type; fill() and show() are used instead")
		
		return clock.get_time()
开发者ID:Versatilus,项目名称:PyGaze,代码行数:9,代码来源:psychopydisplay.py


示例15: stop_recording

	def stop_recording(self):

		"""Dummy for stopping recording, prints what would have been the recording end"""

		self.simulator.set_visible(visible=False)
		dumrectime = clock.get_time()

		self.recording = False

		print("Recording would have stopped at: " + str(dumrectime))
开发者ID:esdalmaijer,项目名称:PyGaze,代码行数:10,代码来源:libdummytracker.py


示例16: close

	def close(self):

		"""Dummy for closing connection with eyetracker, prints what would have been connection closing time"""

		if self.recording:
			self.stop_recording()
		
		closetime = clock.get_time()

		print("eyetracker connection would have closed at: " + str(closetime))
开发者ID:esdalmaijer,项目名称:PyGaze,代码行数:10,代码来源:libdummytracker.py


示例17: start_recording

	def start_recording(self):

		"""Dummy for starting recording, prints what would have been the recording start"""

		self.simulator.set_visible(visible=True)
		dumrectime = clock.get_time()

		self.recording = True
		
		print("Recording would have started at: " + str(dumrectime))
开发者ID:esdalmaijer,项目名称:PyGaze,代码行数:10,代码来源:libdummytracker.py


示例18: wait_for_blink_start

	def wait_for_blink_start(self):

		"""Waits for a blink start and returns the blink starting time
		
		arguments
		None
		
		returns
		timestamp		--	blink starting time in milliseconds, as
						measured from experiment begin time
		"""
		
		# # # # #
		# SMI method

		if self.eventdetection == 'native':
			
			# print warning, since SMI does not have a blink detection
			# built into their API
			
			print("WARNING! 'native' event detection has been selected, \
				but SMI does not offer blink detection; PyGaze algorithm \
				will be used")

		# # # # #
		# PyGaze method
		
		blinking = False
		
		# loop until there is a blink
		while not blinking:
			# get newest sample
			gazepos = self.sample()
			# check if it's a valid sample
			if not self.is_valid_sample(gazepos):
				# get timestamp for possible blink start
				t0 = clock.get_time()
				# loop until a blink is determined, or a valid sample occurs
				while not self.is_valid_sample(self.sample()):
					# check if time has surpassed 150 ms
					if clock.get_time()-t0 >= 150:
						# return timestamp of blink start
						return t0
开发者ID:AA33,项目名称:PyGaze,代码行数:43,代码来源:libsmi.py


示例19: wait_for_blink_start

	def wait_for_blink_start(self):

		"""Returns starting time and position of a simulated blink (mousebuttondown)"""

		# blinks are simulated with mouseclicks: a right mouseclick simulates the closing
		# of the eyes, a mousebuttonup the opening.

		while not self.blinking:
			pos = self.sample()

		return clock.get_time(), pos
开发者ID:esdalmaijer,项目名称:PyGaze,代码行数:11,代码来源:libdummytracker.py


示例20: wait_for_saccade_end

	def wait_for_saccade_end(self):

		"""Returns ending time, starting and end position when a simulated saccade is ended"""

		# function assumes that a 'saccade' has ended when 'gaze' position remains reasonably
		# (i.e.: within maxerr) stable for five samples
		# for saccade start algorithm, see wait_for_fixation_start

		stime, spos = self.wait_for_saccade_start()

		return clock.get_time(), spos, (190,190)
开发者ID:KurtisReid,项目名称:PyGaze,代码行数:11,代码来源:libdumbdummy.py



注:本文中的pygaze.libtime.clock.get_time函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python screen.Screen类代码示例发布时间:2022-05-25
下一篇:
Python keyboard.Keyboard类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap