# Initialize components for Routine "trial" trialClock = core.Clock() text = visual.TextStim(win=win, name='text', text='Any text\n\nincluding line breaks', font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0) ISI = clock.StaticPeriod(win=win, screenHz=expInfo['frameRate'], name='ISI') # Create some handy timers globalClock = core.Clock() # to track the time since experiment started routineTimer = core.CountdownTimer( ) # to track time remaining of each (non-slip) routine # ------Prepare to start Routine "trial"------- t = 0 trialClock.reset() # clock frameN = -1 continueRoutine = True routineTimer.add(1.000000) # update component parameters for each repeat # keep track of which components have finished trialComponents = [text, ISI]
#### GET SCREEN RESOLUTION root = tk.Tk() w = root.winfo_screenwidth() h = root.winfo_screenheight() #### STIMULUS PREPARATION stims = ['yes_LI.jpg', 'rm5.png'] stims_number = random.randint(int(config[2]), int(config[3])) total_stims_number = stims_number * 2 # a=random.sample(stims2, 40) txt_1 = u'В эксперименте вибрационная стимуляция будет чередоваться с картинками, на которых Вам будет необходимо сконцентрироваться и просчитывать элементы картинок про себя.' txt_2 = u'Эксперимент завершен. Для выхода нажмите "пробел"' win = visual.Window([w, h], color=(config[4])) ISI = clock.StaticPeriod(win=win, screenHz=59, name='ISI') ####OPENING txt = visual.TextStim( win, text=u'Сейчас будет эксперимент по исследованию тактильной стимуляции.', font='Helvetica', pos=[0.5, 0]) txt.draw() win.flip() event.waitKeys(keyList=['space']) ####OBSERVATION BEFORE #movs = [visual.ImageStim(win, i, size=[w, h]) for i in stims] movs = [ visual.ImageStim(win, image=i,
depth=0.0) fix2 = visual.TextStim(win=win, name='fix2', text='+', font='Open Sans', pos=(0, 0), height=0.1, wrapWidth=None, ori=0.0, color='white', colorSpace='rgb', opacity=None, languageStyle='LTR', depth=-2.0) preloadfVid = clock.StaticPeriod(win=win, screenHz=expInfo['frameRate'], name='preloadfVid') mouse = event.Mouse(win=win) x, y = [None, None] mouse.mouseClock = core.Clock() correct = visual.ImageStim(win=win, name='correct', image='true.png', mask=None, ori=0.0, pos=(0.4, 0), size=(0.1, 0.1), color=[1, 1, 1], colorSpace='rgb', opacity=None, flipHoriz=False,
def __init__( self, no_demographics = False, task = 'test'): if task=='main': self.sub = self.solicit_subid() demographics = self.solicit_demographics(no_demographics) iohub_config = { 'experiment_code': 'color', 'datastore_name': node(), 'session_code': task, 'experiment_info': { 'version': str(git.repo.fun.rev_parse(git.Repo(), 'HEAD'))[0:6]}, 'session_info': { 'user_variables': { 'date': datetime.now().strftime("%d-%m-%Y_%H-%M-%S"), 'sub': self.sub, 'sex': demographics[0], 'ethnicity': demographics[1], 'race': demographics[2], 'age': demographics[3]}}} else: iohub_config = {} self.sub = 0 self.trialdf = self.__prep_df(os.path.join('stimuli','design.csv')) self.io = iohub_config # Inform the ioHub server about the TrialHandler # randomization already done (hence 'sequential') self.io.createTrialHandlerRecordTable(data.TrialHandler( [x for x in (self.trialdf.T.to_dict()).values()], nReps=1, method='sequential')) self.mon = monitors.Monitor("default", distance=60.96) # create a window to draw in self.win = visual.Window( size=(1920, 1080), fullscr=True, allowGUI=False, winType='pyglet', blendMode='avg', useFBO=True, units="deg", monitor=self.mon, # gamma = [r.gamma, g.gamma, b.gamma], color='black') if task == 'main': runinfo = RunTimeInfo(verbose=True, userProcsDetailed=True, win=self.win, refreshTest=True) with open(os.path.join('data-raw', f'sub-{self.sub}_task-{task}_runinfo.pkl'), 'xb') as f:pickle.dump(runinfo, f) self.fix = visual.Circle(win=self.win, radius=self.fix_radius, size=1, fillColor="white") # cues for color self.triangle = visual.Polygon(win=self.win, radius=self.radius, lineColor="gray", lineWidth=self.linewidth) self.circle = visual.Circle(win=self.win, radius=self.radius, lineColor="gray", lineWidth=self.linewidth) # cues for direction self.line1 = visual.Line(win=self.win, lineWidth=self.linewidth, start=(-math.sqrt(3)/2, math.sqrt(3)/2), end=(math.sqrt(3)/2, -math.sqrt(3)/2), lineColor="gray", size=self.radius) self.line2 = visual.Line(win=self.win, lineWidth=self.linewidth, start=(-math.sqrt(3)/2, -math.sqrt(3)/2), end=(math.sqrt(3)/2, math.sqrt(3)/2), lineColor="gray", size=self.radius) self.fleur = visual.ShapeStim(win=self.win, size=self.radius, lineColor="gray", lineWidth=self.linewidth, vertices=self.__make_vertices()) self.dots = WrappedDot( win=self.win, units='deg', fieldShape="circle", dotSize=deg2pix(self.dotsize_deg, self.mon), dotLife=-1, coherence=self.dot_coherence, nDots=self.ndots, fieldSize=self.dotfield_diameter_deg, speed=self.dot_speed_deg_per_sec / self.refresh_rate) self.correct = TextStim(self.win, text = "CORRECT", color="green") self.incorrect = TextStim(self.win, text = "INCORRECT", color="red") self.welcome = TextStim(self.win, text= ''' welcome to the experiment Press "c" to continue ''', wrapWidth=50, alignText="left") self.rest = TextStim( self.win, pos=(0, 6), alignText="left", wrapWidth=50) self.waiter = clock.StaticPeriod(screenHz=self.refresh_rate)
tex = visual.TextStim(win=myWin, text=instrText, font='SimHei', wrapWidth=25) tex.draw() myWin.flip() kb.start() kb.waitKeys(keyList=['space'], waitRelease=True) kb.stop() myWin.flip() # do it!!! # =========== main experiment loop ======== for trial in trials: # show fixation showFixation() # add 1000ms delay while calculating stim ISI = clock.StaticPeriod(screenHz=fps) ISI.start(delayDur) # start a period of 0.5s if trial['dirRange'] == 0: # coherent dots showFun = partial(showCohDots, dir=trial['direction']) elif trial['dirRange'] == 320: # chaos dots showFun = partial(showChaosDots, XYpos=computeChaosPos(dir=trial['direction'])) ISI.complete() # finish the delay period # show the motion stimulus and get RT and choice rt, cho = showFun() # save data for this trial trials.addData('RT', rt) trials.addData('choice', cho) trials.addData(