当前位置: 首页>>代码示例>>Python>>正文


Python VisionEgg.time_func方法代码示例

本文整理汇总了Python中VisionEgg.time_func方法的典型用法代码示例。如果您正苦于以下问题:Python VisionEgg.time_func方法的具体用法?Python VisionEgg.time_func怎么用?Python VisionEgg.time_func使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VisionEgg的用法示例。


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

示例1: run

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
    def run(self):
        p = pyaudio.PyAudio()
        time_stamped = False
        stream = p.open(
            format=self.format,
            channels=self.channels,
            rate=self.rate,
            input=self.input,
            frames_per_buffer=self.frames_per_buffer,
        )

        print "* recording"
        all = []
        start_time = VisionEgg.time_func()
        i = 0
        while (i <= self.rate / self.chunk * self.time) and (
            (not time_stamped) or (VisionEgg.time_func() < end_time + 2)
        ):
            # for i in range(0, self.rate / self.chunk * self.time):
            data = stream.read(self.chunk)
            samps = numpy.fromstring(data, dtype=numpy.int16)
            all.append(data)
            loud = loudness(samps)
            # print str(i) + "   " + str(loud)
            if (not time_stamped) and loud > self.sound_threshold:
                end_time = VisionEgg.time_func()
                self.q.put(start_time)
                self.q.put(end_time)
                # self.f.write("%s\t%f\t%f\t%f\t" % (self.item, end_time-start_time, start_time, end_time))
                # self.f.flush()
                print "Crossed Threshold!"
                time_stamped = True
            i = i + 1

        if not time_stamped:
            self.q.put(start_time)
            self.q.put(10000000)
            # self.f.write("%s\t%f\t%f\t%f\t" % (self.item, 10000000, start_time, 10000000.0))

        print "* done recording"
        stream.close()
        p.terminate()

        # write data to WAVE file
        data = "".join(all)
        wf = wave.open(self.file_name, "wb")
        wf.setnchannels(self.channels)
        wf.setsampwidth(p.get_sample_size(self.format))
        wf.setframerate(self.rate)
        wf.writeframes(data)
        wf.close()
开发者ID:urcavelab,项目名称:InLabExperimentCode,代码行数:53,代码来源:ExperimentLibrary03.py

示例2: run

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
    def run(self, ID=0):
        self.ID = ID
        self.sound_fired = 0
        super(RMLTrial, self).run()
        while not self.stopped:
            self.run_time = VisionEgg.time_func() - self.start_time
            if self.phase == 0:
                self.pre_experiment_time = VisionEgg.time_func()
                # this trial phase is ended with a enter press or TR pulse
                if self.ID != 0:
                    self.phase_forward()
            if self.phase == 1:
                self.pre_stimulus_time = VisionEgg.time_func()
                if (self.pre_stimulus_time - self.pre_experiment_time) > self.phase_durations[1]:
                    self.phase_forward()
            if self.phase == 2:
                self.stimulus_time = VisionEgg.time_func()
                if (self.stimulus_time - self.pre_stimulus_time) > self.phase_durations[2]:
                    self.phase_forward()
            if self.phase == 3:
                self.tone_time = VisionEgg.time_func()
                if self.sound_fired == 0:
                    if self.tracker != None:
                        self.tracker.sendMessage(
                            "trial "
                            + str(self.ID)
                            + " sound "
                            + str(self.parameters["sound"])
                            + " at "
                            + str(self.tone_time)
                        )
                    if self.parameters["sound"] == 0:
                        self.session.play_np_sound(self.noise_tone_array)
                    elif self.parameters["sound"] == 1:
                        self.session.play_sound(sound_index="reward")
                    self.sound_fired = 1
                    # this trial phase is timed
                if (self.tone_time - self.stimulus_time) > self.phase_durations[3]:
                    self.stopped = True

                    # events and draw
            self.event()
            self.draw()

        self.stop()
开发者ID:JvSlooten88,项目名称:pupil_prediction_error,代码行数:47,代码来源:Reversal_Learning.py

示例3: __init__

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
 def __init__(self, **kw):
     VisionEgg.Core.Stimulus.__init__(self,**kw)
     # store positions normalized around 0 so that re-sizing is ok
     num_dots = self.constant_parameters.num_dots # shorthand
     self.centers = np.random.standard_normal((3,num_dots))
     self.colors = np.ones((num_dots,4))
     self.colors[:self.constant_parameters.num_dark,:3] = 0
     self.last_time_sec = VisionEgg.time_func()
     self.start_times_sec = None # setup variable, assign later
开发者ID:Complex501,项目名称:visionegg,代码行数:11,代码来源:Dots.py

示例4: run

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
	def run(self, ID = 0):
		self.ID = ID
		super(DetectTrial, self).run()
		while not self.stopped:
			self.run_time = VisionEgg.time_func() - self.start_time
			if self.phase == 0:
				self.prestimulation_time = VisionEgg.time_func()
				# this trial phase is ended with a space press on the first trial of a run, but timed on all other trials of a run.
				if ( self.prestimulation_time - self.start_time ) > self.phase_durations[1] and self.ID != 0:
					self.phase_forward()
			elif self.phase == 1:
				self.adaptation_time = VisionEgg.time_func()
				# this trial phase is timed
				if ( self.adaptation_time  - self.prestimulation_time ) > self.phase_durations[1]:
					self.phase_forward()
			elif self.phase == 2:
				# this trial phase is timed
				self.post_adaptation_time = VisionEgg.time_func()
				if ( self.post_adaptation_time  - self.adaptation_time ) > self.phase_durations[2]:
					self.session.play_sound( sound_index = 1 )
					self.phase_forward()
			elif self.phase == 3:
				# this trial phase is timed
				self.first_test_time = VisionEgg.time_func()
				if ( self.first_test_time  - self.post_adaptation_time ) > self.phase_durations[3]:
					self.phase_forward()
			elif self.phase == 4:
				# this trial phase is timed
				self.inter_test_time = VisionEgg.time_func()
				if ( self.inter_test_time  - self.first_test_time ) > self.phase_durations[4]:
					self.session.play_sound( sound_index = 1 )
					self.phase_forward()
			elif self.phase == 5:
				# this trial phase is timed
				self.last_test_time = VisionEgg.time_func()
				if ( self.last_test_time  - self.inter_test_time ) > self.phase_durations[5]:
					self.phase_forward()
			elif self.phase == 6:
				self.answer_time = VisionEgg.time_func() - self.last_test_time
			elif self.phase == 7:
				self.post_answer_time = VisionEgg.time_func() - self.answer_time
			
			# events and draw
			self.event()
			self.draw()
		
		# we have stopped. 
		self.stop()
开发者ID:jwdegee,项目名称:Pupil-dilation-2,代码行数:50,代码来源:1a_forced_choice_FINAL.py

示例5: event

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
 def event(self):
     for event in pygame.event.get():
         super(RMLTrial, self).key_event(event)
         if event.type == KEYDOWN:
             if event.key == pygame.locals.K_ESCAPE:
                 self.events.append([-99, VisionEgg.time_func() - self.start_time])
                 self.stopped = True
                 self.session.stopped = True
                 # it handles both numeric and lettering modes
             elif (
                 event.key == pygame.locals.K_RETURN or event.key == pygame.locals.K_t
             ):  # press enter (or TR pulse) to start experiment
                 self.events.append([0, VisionEgg.time_func() - self.start_time])
                 if self.phase == 0:
                     self.phase_forward()
             elif event.key == pygame.locals.K_SPACE:
                 if self.phase != 0:  # only register space bar presses after experiment has started
                     self.events.append(
                         [1, VisionEgg.time_func() - self.start_time]
                     )  # register space bar presses with '1' and save timestamp
                     self.session.reversal_keypresses += (
                         1
                     )  # save self.reversal_keypresses to be able to print it in the terminal later
开发者ID:JvSlooten88,项目名称:pupil_prediction_error,代码行数:25,代码来源:Reversal_Learning.py

示例6: draw

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
    def draw(self):
        # XXX This method is not speed-optimized. I just wrote it to
        # get the job done. (Nonetheless, it seems faster than the C
        # version commented out above.)

        p = self.parameters # shorthand

        now_sec = VisionEgg.time_func()
        if self.start_times_sec is not None:
            # compute extinct dots and generate new positions
            replace_indices = Numeric.nonzero( Numeric.greater( now_sec - self.start_times_sec, p.dot_lifespan_sec) )
            Numeric.put( self.start_times_sec, replace_indices, now_sec )

            new_centers = np.random.standard_normal((3,len(replace_indices)))
            for i in range(3):
                Numeric.put( self.centers[i,:], replace_indices, new_centers[i,:] )
        else:
            # initialize dot extinction values to random (uniform) distribution
            self.start_times_sec = RandomArray.uniform( now_sec - p.dot_lifespan_sec, now_sec,
                                                        (self.constant_parameters.num_dots,))

        time_delta_sec = now_sec - self.last_time_sec
        self.last_time_sec = now_sec # reset for next loop
        self.centers = self.centers + np.array(p.signal_vec)[:,np.newaxis]*time_delta_sec

        xyz = self.centers*p.start_position_variance + np.array(p.start_position_mean)[:,np.newaxis]
        xs = xyz[0,:]
        ys = xyz[1,:]
        zs = xyz[2,:]

        if p.on:
            gl.glEnable( gl.GL_POINT_SMOOTH )
            # allow max_alpha value to control blending
            gl.glEnable( gl.GL_BLEND )
            gl.glBlendFunc( gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA )

            gl.glPointSize(p.dot_size)

            # Clear the modeview matrix
            gl.glMatrixMode(gl.GL_MODELVIEW)
            gl.glPushMatrix()

            gl.glDisable(gl.GL_TEXTURE_2D)

            draw_dots(xs,ys,zs,self.colors)
            gl.glDisable( gl.GL_POINT_SMOOTH ) # turn off
            gl.glPopMatrix()
开发者ID:Complex501,项目名称:visionegg,代码行数:49,代码来源:Dots.py

示例7: __init__

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
    def __init__(self, **kw):
        VisionEgg.Core.Stimulus.__init__(self,**kw)
        # store positions normalized between 0 and 1 so that re-sizing is ok
        num_dots = self.constant_parameters.num_dots # shorthand
        self.x_positions = RandomArray.uniform(0.0,1.0,(num_dots,))
        self.y_positions = RandomArray.uniform(0.0,1.0,(num_dots,))
        if self.parameters.mode == "wind":
            self.random_directions_radians = RandomArray.uniform(0.0,2*math.pi,(num_dots,))
            self.velocities = RandomArray.uniform(self.parameters.velocity_max-1, self.parameters.velocity_max,(num_dots,))            

        elif self.parameters.mode == "Gaussian":    
            self.random_directions_radians = numpy.random.normal(self.parameters.signal_direction_deg/180.0*math.pi, self.parameters.signal_fraction,(num_dots,))
            self.velocities = RandomArray.uniform(self.parameters.velocity_min, self.parameters.velocity_max,(num_dots,))

        self.last_time_sec = VisionEgg.time_func()
        self.start_times_sec = None # setup variable, assign later
        self._gave_alpha_warning = 0
开发者ID:urcavelab,项目名称:InLabExperimentCode,代码行数:19,代码来源:MyDots.py

示例8: event

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
	def event(self):
		for event in pygame.event.get():
			if event.type == KEYDOWN:
				if event.key == pygame.locals.K_ESCAPE:
					self.events.append([-99,VisionEgg.time_func()-self.start_time])
					self.parameters.update({'correct': 0})
					self.stopped = True
					self.session.stopped = True
				# it handles both numeric and lettering modes 
				elif event.key == pygame.locals.K_SPACE:
					self.events.append([0,VisionEgg.time_func()-self.start_time])
					if self.phase in (0, 4):
						self.phase_forward()
					# else:
					# 	self.stopped = True	
				elif event.key == pygame.locals.K_LEFT:
					self.events.append([1,VisionEgg.time_func()-self.start_time])
					if self.version == 1:
						if self.phase == 2:
							self.parameters.update({'answer':1})
							if self.parameters['target_present_in_stimulus'] == 0:
								self.parameters['correct']= 1
							else:
								self.parameters['correct']= 0
							if self.phase == 2:
								self.phase_forward()
					if self.version == 2:
						if self.phase == 2:
							self.parameters.update({'answer':1})
							if self.parameters['target_present_in_stimulus'] == 1:
								self.parameters['correct']= 1
							else:
								self.parameters['correct']= 0
							if self.phase == 2:
								self.phase_forward()
					if self.phase == 0:
						self.nr_buttons_pressed = self.nr_buttons_pressed + 1
						self.tracker.sendCommand('record_status_message "Trial %d, Buttonpress %d"'%(self.ID, self.nr_buttons_pressed))
				elif event.key == pygame.locals.K_RIGHT:
					self.events.append([-1,VisionEgg.time_func()-self.start_time])
					if self.version == 1:
						if self.phase == 2:
							self.parameters.update({'answer':-1})
							if self.parameters['target_present_in_stimulus'] == 1:
								self.parameters['correct']= 1
							else:
								self.parameters['correct']= 0
							if self.phase == 2:
								self.phase_forward()
					if self.version == 2:
						if self.phase == 2:
							self.parameters.update({'answer':-1})
							if self.parameters['target_present_in_stimulus'] == 0:
								self.parameters['correct']= 1
							else:
								self.parameters['correct']= 0
							if self.phase == 2:
								self.phase_forward()
					if self.phase == 0:
						self.nr_buttons_pressed = self.nr_buttons_pressed + 1
						self.tracker.sendCommand('record_status_message "Trial %d, Buttonpress %d"'%(self.ID, self.nr_buttons_pressed))
				if event.key == pygame.locals.K_c:
					if self.ID % 15 == 0:
						self.session.tracker_setup(auto_trigger_calibration = True, calibration_type = 'HV5', sample_rate = 1000)
				elif event.key == pygame.locals.K_a:
					if self.phase > 3:
						self.parameters['confidence'] = 0
					if self.phase == 4:
						self.phase_forward()
				elif event.key == pygame.locals.K_s:
					if self.phase > 3:
						self.parameters['confidence'] = 1
					if self.phase == 4:
						self.phase_forward()
				elif event.key == pygame.locals.K_d:
					if self.phase > 3:
						self.parameters['confidence'] = 2
					if self.phase == 4:
						self.phase_forward()
				elif event.key == pygame.locals.K_f:
					if self.phase > 3:
						self.parameters['confidence'] = 3
					if self.phase == 4:
						self.phase_forward()

			super(DetectTrial, self).key_event( event )
开发者ID:jwdegee,项目名称:Pupil-dilation-2,代码行数:88,代码来源:EXP2+-+2a_yes_no.py

示例9: draw

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
    def draw(self):
        p = self.parameters  # shorthand
        if p.on:
            if p.mask:
                gl.glActiveTextureARB(gl.GL_TEXTURE0_ARB)
            if p.depth_test:
                gl.glEnable(gl.GL_DEPTH_TEST)
            else:
                gl.glDisable(gl.GL_DEPTH_TEST)
            if p.polygon_offset_enabled:
                gl.glEnable(gl.GL_POLYGON_OFFSET_EXT)
                gl.glPolygonOffset(p.polygon_offset_factor, p.polygon_offset_units)
            gl.glBindTexture(gl.GL_TEXTURE_1D, self._texture_object_id)
            gl.glEnable(gl.GL_TEXTURE_1D)
            gl.glDisable(gl.GL_TEXTURE_2D)
            if p.bit_depth != self.cached_bit_depth:
                self.calculate_bit_depth_dependencies()

            # allow max_alpha value to control blending
            gl.glEnable(gl.GL_BLEND)
            gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

            if p.color2:
                gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_BLEND)
                gl.glTexEnvfv(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_COLOR, p.color2)
                ## alpha is ignored because the texture base internal format is luminance
            else:
                gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE)

            if p.t0_time_sec_absolute is None and not p.ignore_time:
                p.t0_time_sec_absolute = VisionEgg.time_func()

            w = p.size[0]
            inc = w / float(p.num_samples)
            if p.ignore_time:
                phase = p.phase_at_t0
            else:
                t_var = VisionEgg.time_func() - p.t0_time_sec_absolute
                phase = t_var * p.temporal_freq_hz * -360.0 + p.phase_at_t0
            if p.recalculate_phase_tolerance is None or abs(self._last_phase - phase) > p.recalculate_phase_tolerance:
                self._last_phase = phase  # we're re-drawing the phase at this angle
                floating_point_sin = (
                    numpy.sin(
                        2.0 * math.pi * p.spatial_freq * numpy.arange(0.0, w, inc, dtype=numpy.float)
                        + (phase / 180.0 * math.pi)
                    )
                    * 0.5
                    * p.contrast
                    + p.pedestal
                )
                floating_point_sin = numpy.clip(
                    floating_point_sin, 0.0, 1.0
                )  # allow square wave generation if contrast > 1
                texel_data = (floating_point_sin * self.max_int_val).astype(self.numpy_dtype).tostring()

                gl.glTexSubImage1D(
                    gl.GL_TEXTURE_1D,  # target
                    0,  # level
                    0,  # x offset
                    p.num_samples,  # width
                    self.format,  # format of new texel data
                    self.gl_type,  # type of new texel data
                    texel_data,
                )  # new texel data

            # in the case of only color1,
            # the texel data multiplies color1 to produce a color

            # with color2,
            # the texel data linearly interpolates between color1 and color2

            gl.glColor4f(p.color1[0], p.color1[1], p.color1[2], p.max_alpha)

            if p.mask:
                p.mask.draw_masked_quad_3d(
                    0.0, 1.0, 0.0, 1.0, p.lowerleft, p.lowerright, p.upperright, p.upperleft  # for texture coordinates
                )
            else:
                # draw unmasked quad
                gl.glBegin(gl.GL_QUADS)

                gl.glTexCoord2f(0.0, 0.0)
                gl.glVertex(*p.lowerleft)

                gl.glTexCoord2f(1.0, 0.0)
                gl.glVertex(*p.lowerright)

                gl.glTexCoord2f(1.0, 1.0)
                gl.glVertex(*p.upperright)

                gl.glTexCoord2f(0.0, 1.0)
                gl.glVertex(*p.upperleft)
                gl.glEnd()  # GL_QUADS

            gl.glDisable(gl.GL_TEXTURE_1D)
            if p.polygon_offset_enabled:
                gl.glDisable(gl.GL_POLYGON_OFFSET_EXT)
开发者ID:visionegg,项目名称:visionegg,代码行数:99,代码来源:Gratings.py

示例10: Viewport

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
                           shrink_texture_ok=True,
                           internal_format=gl.GL_RGBA,
                           )

viewport = Viewport(screen=screen,
                    stimuli=[stimulus])

frame_timer = FrameTimer()
quit_now = False
spinning = True
while not quit_now and spinning:
    for event in pygame.event.get():
        if event.type == QUIT:
            quit_now = True
        elif event.type in (KEYDOWN,MOUSEBUTTONDOWN):
            spinning = False
    screen.clear()
    stimulus.parameters.angle = (VisionEgg.time_func()*-180.0)%360.0 # rotate
    viewport.draw()
    swap_buffers()
    frame_timer.tick()
while not quit_now:
    for event in pygame.event.get():
        if event.type in (QUIT,KEYDOWN,MOUSEBUTTONDOWN):
            quit_now = True
    screen.clear()
    viewport.draw()
    swap_buffers()
    frame_timer.tick()
frame_timer.log_histogram()
开发者ID:Complex501,项目名称:visionegg,代码行数:32,代码来源:spiral.py

示例11: go

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
def go(mode, time=2):
    global x
    global escape_code 
    quit_now = False
    response = None
    other_responses = []
    rt = -1000
    frame_timer = FrameTimer()
    if mode == "isi":
        time = stimulus.isi_time
    elif mode == "ippi":
        time = stimulus.ippi_time
    elif mode == "prime":
        time = stimulus.prime_time
    elif mode == "probe":
        time = stimulus.probe_time


    if(mode == "prime"):

        x = x + 1
        print "collecting " + str(x)
        ac = Audio_collection(FORMAT, CHANNELS, RATE, SOUND_THRESHOLD, stimulus.itemNumber, True, \
                         chunk, outputdir + "audio"+ str(subjectID) +"/" + EXPERIMENT_CODE + str(subjectID)+stimulus.itemNumber+".wav", prime_time, chunk, q)
        ac.start()

    start_time = VisionEgg.time_func()
    while not quit_now:





        # Process keyboard inputs
        for event in pygame.event.get():
            if event.type == pygame.locals.QUIT:
                quit_now = True
            elif event.type == pygame.locals.KEYDOWN:
                if event.key == pygame.locals.K_BACKQUOTE :
                    quit_now = True
                    escape_code = True
                    f.close()
                    screen.close()
                    #screen2.close()
                    sys.exit()
                    
                elif event.key == response_key_1 :
                    if response==None:
                        rt = VisionEgg.time_func() - start_time
                        response = "LeftResponse"
                        if click_through_stimuli:
                            quit_now = True
                    else :
                        other_responses.append(str(event.key) + " " + str(VisionEgg.time_func() - start_time))
                elif event.key == response_key_2 :
                    if response==None:
                        rt = VisionEgg.time_func() - start_time
                        response = "RightResponse"
                        if click_through_stimuli:
                            quit_now = True
                    else :
                        other_responses.append(str(event.key) + " " + str(VisionEgg.time_func() - start_time))


                elif event.key == pygame.locals.K_BACKQUOTE:
                    quit_now =  True
                else :
                        other_responses.append(str(event.key) + " " + str(VisionEgg.time_func() - start_time))
                    #text.parameters.text+=event.unicode
        screen.clear()
        viewport.draw()
        swap_buffers()
        frame_timer.tick()
        time_since_start = VisionEgg.time_func()
        if((time_since_start - start_time > time) ):
            quit_now = True
        if (mode == "prime") and not (ac.is_alive()):
            quit_now = True


    

    if(mode=="prime"):
        ac.join()
        #while threading.activeCount() > 2: # This is sheer magic.  I'm not sure why there are two threads active at this point, so it could break at any moment.
        #    print threading.activeCount()
    
        audio_start_time = q.get()
        audio_end_time = q.get()

        if not (audio_end_time == 10000000):
            f.write("%s\t%f\t%f\t%f\t%s\t%d\t%s\t%f\t%f\t%s\n" % (stimulus.itemNumber, audio_end_time-audio_start_time, audio_start_time, \
                                                                audio_end_time, \
                                                                stimulus.pretty_name(timings=False), \
                                                                subjectID, mode, start_time, time_since_start-start_time, \
                                                                " . ".join(other_responses)))
        else:
            f.write("%s\t%f\t%f\t%f\t%s\t%d\t%s\t%f\t%f\t%s\n" % (stimulus.itemNumber, audio_end_time, audio_start_time, \
                                                                audio_end_time, \
                                                                stimulus.pretty_name(timings=False), \
#.........这里部分代码省略.........
开发者ID:urcavelab,项目名称:InLabExperimentCode,代码行数:103,代码来源:DSX-4.py

示例12: get_default_screen

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
screen = get_default_screen()
screen.parameters.bgcolor = (0.0,0.0,0.2) # background blue (RGB)

text=VisionEgg.Text.PangoText(
    color=(1.0,1.0,1.0), # alpha is ignored (set with max_alpha_param)
    position=(0,screen.size[1]/2),
    size = (screen.size[0],max(screen.size[0]/10,10)),
    anchor='left')

viewport = Viewport(screen=screen,
                    size=screen.size,
                    stimuli=[text])

# The main loop below is an alternative to using the
# VisionEgg.FlowControl.Presentation class.

frame_timer = FrameTimer()
quit_now = 0
while not quit_now:
    for event in pygame.event.get():
        if event.type in (QUIT,KEYDOWN,MOUSEBUTTONDOWN):
            quit_now = 1

    idx = int(VisionEgg.time_func()%len(language))
    text.parameters.text = "%s: %s"%(language[idx],phrase[idx])
    screen.clear()
    viewport.draw()
    swap_buffers()
    frame_timer.tick()
frame_timer.log_histogram()
开发者ID:Complex501,项目名称:visionegg,代码行数:32,代码来源:displayUnicode.py

示例13: run

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
	def run(self, ID = 0):
		self.ID = ID
		super(DetectTrial, self).run()
		sound_played = False
		# self.start_time = VisionEgg.time_func()
		while not self.stopped:
			self.run_time = VisionEgg.time_func() - self.start_time
			if self.phase == 0:
				self.prestimulation_time = VisionEgg.time_func()
				if self.ID % 15 != 0:
					if ( self.prestimulation_time  - self.start_time ) > self.phase_durations[0]:
						self.phase_forward()
				# this trial phase is ended with a space press on the first trial of a run, but timed on all other trials of a run.
			elif self.phase == 1:	# first delay
				self.delay_1_time = VisionEgg.time_func()
				# this trial phase is timed
				if ( self.delay_1_time - self.prestimulation_time ) > self.phase_durations[1] - 0.1 and sound_played == False:
					self.session.play_sound( sound_index = 1 )
					sound_played = True
				if ( self.delay_1_time - self.prestimulation_time ) > self.phase_durations[1]:
					self.phase_forward()
			elif self.phase == 2:	# stimulus presentation
				# this trial phase is timed
				self.test_time = VisionEgg.time_func()
				if ( self.test_time  - self.delay_1_time ) > self.phase_durations[2]:
					self.phase_forward()
			elif self.phase == 3:	# second delay
				# this trial phase is timed
				self.delay_2_time = VisionEgg.time_func()
				if ( self.delay_2_time  - self.test_time ) > self.phase_durations[3]:
					this_prob = np.random.rand()
					# print this_prob, self.ID
					if (this_prob < 0.1 or self.parameters['correct'] == -1) and not hasattr(self, 'has_been_extended'):
						self.phase_durations[3] = self.phase_durations[3] + 2.0
						self.has_been_extended = True
					else:
						self.stopped = True
						return
					if this_prob < 0.1:
						if self.version == 1:
							if self.parameters['correct'] == 1:
								self.session.play_sound( sound_index = 2 )
							elif self.parameters['correct'] == 0:
								self.session.play_sound( sound_index = 0 )
						if self.version == 2:
							if self.parameters['correct'] == 1:
								self.session.play_sound( sound_index = 0 )
							elif self.parameters['correct'] == 0:
								self.session.play_sound( sound_index = 2 )
					if self.parameters['correct'] == -1:
						self.session.play_sound( sound_index = 3 )
			
			
			
			
			
			# elif self.phase == 4:	# confidence
			# 	self.confidence_time = VisionEgg.time_func()
			# elif self.phase == 5:	# third delay
			# 	self.delay_3_time = VisionEgg.time_func()
			# 	if ( self.delay_3_time  - self.confidence_time ) > self.phase_durations[5]:
			# 		self.feedback_given = False
			# 		self.phase_forward()
			# elif self.phase == 6:	# feedback
			# 	self.feedback_time = VisionEgg.time_func()
			# 	if self.feedback_given == False and ( self.feedback_time  - self.delay_3_time ) > 0.1:
			# 		if self.version == 1:
			# 			if self.parameters['correct'] == 1:
			# 				self.session.play_sound( sound_index = 2 )
			# 			elif self.parameters['correct'] == 0:
			# 				self.session.play_sound( sound_index = 0 )
			# 		if self.version == 2:
			# 			if self.parameters['correct'] == 1:
			# 				self.session.play_sound( sound_index = 0 )
			# 			elif self.parameters['correct'] == 0:
			# 				self.session.play_sound( sound_index = 2 )
			# 		elif self.parameters['correct'] == -1:
			# 			self.session.play_sound( sound_index = 3 )
			# 		self.feedback_given = True
			# 	if ( self.feedback_time  - self.delay_3_time ) > self.phase_durations[6]:
			# 		self.phase_forward()
			# elif self.phase == 7:	# fourth delay
			# 	self.delay_4_time = VisionEgg.time_func()
			# 	if ( self.delay_4_time  - self.feedback_time ) > self.phase_durations[7]:
			# 		self.stopped = True

			# events and draw
			self.event()
			self.draw()

		# we have stopped. 
		self.stop()
开发者ID:jwdegee,项目名称:Pupil-dilation-2,代码行数:94,代码来源:EXP2+-+2a_yes_no.py

示例14: event

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
	def event(self):
		for event in pygame.event.get():
			if event.type == KEYDOWN:
				if event.key == pygame.locals.K_ESCAPE:
					self.events.append([-99,VisionEgg.time_func()-self.start_time])
					self.parameters.update({'correct': 0})
					self.stopped = True
					self.session.stopped = True
				# it handles both numeric and lettering modes 
				elif event.key == pygame.locals.K_SPACE:
					self.events.append([0,VisionEgg.time_func()-self.start_time])
					if self.phase in (0, 4):
						self.phase_forward()
					# else:
					# 	self.stopped = True	
				elif event.key == pygame.locals.K_LEFT:
					self.events.append([1,VisionEgg.time_func()-self.start_time])
					if self.version == 1:
						if self.phase == 2:
							self.parameters.update({'answer':1})
							if self.parameters['target_present_in_stimulus'] == 0:
								self.parameters['correct']= 1
							else:
								self.parameters['correct']= 0
							if self.phase == 2:
								self.phase_forward()
					if self.version == 2:
						if self.phase == 2:
							self.parameters.update({'answer':1})
							if self.parameters['target_present_in_stimulus'] == 1:
								self.parameters['correct']= 1
							else:
								self.parameters['correct']= 0
							if self.phase == 2:
								self.phase_forward()
				elif event.key == pygame.locals.K_RIGHT:
					self.events.append([-1,VisionEgg.time_func()-self.start_time])
					if self.version == 1:
						if self.phase == 2:
							self.parameters.update({'answer':-1})
							if self.parameters['target_present_in_stimulus'] == 1:
								self.parameters['correct']= 1
							else:
								self.parameters['correct']= 0
							if self.phase == 2:
								self.phase_forward()
					if self.version == 2:
						if self.phase == 2:
							self.parameters.update({'answer':-1})
							if self.parameters['target_present_in_stimulus'] == 0:
								self.parameters['correct']= 1
							else:
								self.parameters['correct']= 0
							if self.phase == 2:
								self.phase_forward()				
				elif event.key == pygame.locals.K_a:
					if self.phase > 3:
						self.parameters['confidence'] = 0
					if self.phase == 4:
						self.phase_forward()
				elif event.key == pygame.locals.K_s:
					if self.phase > 3:
						self.parameters['confidence'] = 1
					if self.phase == 4:
						self.phase_forward()
				elif event.key == pygame.locals.K_d:
					if self.phase > 3:
						self.parameters['confidence'] = 2
					if self.phase == 4:
						self.phase_forward()
				elif event.key == pygame.locals.K_f:
					if self.phase > 3:
						self.parameters['confidence'] = 3
					if self.phase == 4:
						self.phase_forward()

			super(DetectTrial, self).key_event( event )
开发者ID:jwdegee,项目名称:Pupil-dilation-2,代码行数:79,代码来源:EXP1+-+2a_yes_no.py

示例15: run

# 需要导入模块: import VisionEgg [as 别名]
# 或者: from VisionEgg import time_func [as 别名]
	def run(self, ID = 0):
		self.ID = ID
		super(DetectTrial, self).run()
		sound_played = False
		while not self.stopped:
			self.run_time = VisionEgg.time_func() - self.start_time
			if self.phase == 0:
				self.prestimulation_time = VisionEgg.time_func()
				# this trial phase is ended with a space press on the first trial of a run, but timed on all other trials of a run.
				self.start_time = VisionEgg.time_func()
			elif self.phase == 1:	# first delay
				self.delay_1_time = VisionEgg.time_func()
				# this trial phase is timed
				if ( self.delay_1_time - self.prestimulation_time ) > self.phase_durations[1] - 0.1 and sound_played == False:
					self.session.play_sound( sound_index = 1 )
					sound_played = True
				if ( self.delay_1_time - self.prestimulation_time ) > self.phase_durations[1]:
					self.phase_forward()
			elif self.phase == 2:	# stimulus presentation
				# this trial phase is timed
				self.test_time = VisionEgg.time_func()
				if ( self.test_time  - self.delay_1_time ) > self.phase_durations[2]:
					self.phase_forward()
			elif self.phase == 3:	# second delay
				# this trial phase is timed
				self.delay_2_time = VisionEgg.time_func()
				if ( self.delay_2_time  - self.test_time ) > self.phase_durations[3]:
					self.phase_forward()
			elif self.phase == 4:	# confidence
				self.confidence_time = VisionEgg.time_func()
			elif self.phase == 5:	# third delay
				self.delay_3_time = VisionEgg.time_func()
				if ( self.delay_3_time  - self.confidence_time ) > self.phase_durations[5]:
					self.feedback_given = False
					self.phase_forward()
			elif self.phase == 6:	# feedback
				self.feedback_time = VisionEgg.time_func()
				if self.feedback_given == False and ( self.feedback_time  - self.delay_3_time ) > 0.1:
					if self.version == 1:
						if self.parameters['correct'] == 1:
							self.session.play_sound( sound_index = 2 )
						elif self.parameters['correct'] == 0:
							self.session.play_sound( sound_index = 0 )
					if self.version == 2:
						if self.parameters['correct'] == 1:
							self.session.play_sound( sound_index = 0 )
						elif self.parameters['correct'] == 0:
							self.session.play_sound( sound_index = 2 )
					elif self.parameters['correct'] == -1:
						self.session.play_sound( sound_index = 3 )
					self.feedback_given = True
				if ( self.feedback_time  - self.delay_3_time ) > self.phase_durations[6]:
					self.phase_forward()
			elif self.phase == 7:	# fourth delay
				self.delay_4_time = VisionEgg.time_func()
				if ( self.delay_4_time  - self.feedback_time ) > self.phase_durations[7]:
					self.stopped = True

			# events and draw
			self.event()
			self.draw()

		# we have stopped. 
		self.stop()
开发者ID:jwdegee,项目名称:Pupil-dilation-2,代码行数:66,代码来源:EXP1+-+2a_yes_no.py


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