allowGUI=False, allowStencil=False, monitor='testMonitor', color=[0, 0, 0], colorSpace='rgb', blendMode='avg', useFBO=True) # store frame rate of monitor if we can measure it expInfo['frameRate'] = win.getActualFrameRate() if expInfo['frameRate'] != None: frameDur = 1.0 / round(expInfo['frameRate']) else: frameDur = 1.0 / 60.0 # could not measure, so guess # Initialize components for Routine "instruction" instructionClock = core.Clock() intr_1 = visual.TextStim(win=win, name='intr_1', text="Press 'up' if target is the same as original", font='Arial', pos=(0, 0.1), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, depth=0.0) instr_2 = visual.TextStim( win=win, name='instr_2',
def displayCircularStimuli(directions, colors, colors_wheel, thicknesses, speeds, duration): global mywin, plate, white mywin = visual.Window([1280, 1024], monitor="Dell Inc. 17", units="pix", fullscr=False, screen=1, color='white') plate = visual.Rect(win=mywin, size=(width_plate, height_plate), lineColor=[0, 0, 0], lineColorSpace="rgb255", lineWidth=4) white = visual.ImageStim(win=mywin, image="Solid_white.png", size=(1280, 1024), pos=[0, 0]) ops = [] for d in directions: if d == 'Clockwise': ops.append('+') else: ops.append('-') shape1 = visual.ShapeStim(mywin, units='', lineWidth=thicknesses[0], lineColor=colors_wheel[0], lineColorSpace='rgb', fillColor='red', fillColorSpace='rgb', vertices=np.multiply(wheel, scalingFactor), windingRule=None, closeShape=True, pos=(-width_plate / 6.4, height_plate / 8.2), size=1, ori=0.0, opacity=1.0, contrast=1.0, depth=0, interpolate=True, name=None, autoLog=None, autoDraw=False) shape1b = visual.Circle(mywin, radius=scalingFactor, fillColor=colors[0], pos=(-width_plate / 6.4, height_plate / 8.2)) shape2 = visual.ShapeStim(mywin, units='', lineWidth=thicknesses[1], lineColor=colors_wheel[1], lineColorSpace='rgb', fillColor='red', fillColorSpace='rgb', vertices=np.multiply(wheel, scalingFactor), windingRule=None, closeShape=True, pos=(0, height_plate / 8.2), size=1, ori=0.0, opacity=1.0, contrast=1.0, depth=0, interpolate=True, name=None, autoLog=None, autoDraw=False) shape2b = visual.Circle(mywin, radius=scalingFactor, fillColor=colors[1], pos=(0, height_plate / 8.2)) shape3 = visual.ShapeStim(mywin, units='', lineWidth=thicknesses[2], lineColor=colors_wheel[2], lineColorSpace='rgb', fillColor='red', fillColorSpace='rgb', vertices=np.multiply(wheel, scalingFactor), windingRule=None, closeShape=True, pos=(width_plate / 6.4, height_plate / 8.2), size=1, ori=0.0, opacity=1.0, contrast=1.0, depth=0, interpolate=True, name=None, autoLog=None, autoDraw=False) shape3b = visual.Circle(mywin, radius=scalingFactor, fillColor=colors[2], pos=(width_plate / 6.4, height_plate / 8.2)) shape4 = visual.ShapeStim(mywin, units='', lineWidth=thicknesses[3], lineColor=colors_wheel[3], lineColorSpace='rgb', fillColor='red', fillColorSpace='rgb', vertices=np.multiply(wheel, scalingFactor), windingRule=None, closeShape=True, pos=(-width_plate / 6.4, -height_plate / 8.2), size=1, ori=0.0, opacity=1.0, contrast=1.0, depth=0, interpolate=True, name=None, autoLog=None, autoDraw=False) shape4b = visual.Circle(mywin, radius=scalingFactor, fillColor=colors[3], pos=(-width_plate / 6.4, -height_plate / 8.2)) shape5 = visual.ShapeStim(mywin, units='', lineWidth=thicknesses[4], lineColor=colors_wheel[4], lineColorSpace='rgb', fillColor='red', fillColorSpace='rgb', vertices=np.multiply(wheel, scalingFactor), windingRule=None, closeShape=True, pos=(0, -height_plate / 8.2), size=1, ori=0.0, opacity=1.0, contrast=1.0, depth=0, interpolate=True, name=None, autoLog=None, autoDraw=False) shape5b = visual.Circle(mywin, radius=scalingFactor, fillColor=colors[4], pos=(0, -height_plate / 8.2)) shape6 = visual.ShapeStim(mywin, units='', lineWidth=thicknesses[5], lineColor=colors_wheel[5], lineColorSpace='rgb', fillColor='red', fillColorSpace='rgb', vertices=np.multiply(wheel, scalingFactor), windingRule=None, closeShape=True, pos=(width_plate / 6.4, -height_plate / 8.2), size=1, ori=0.0, opacity=1.0, contrast=1.0, depth=0, interpolate=True, name=None, autoLog=None, autoDraw=False) shape6b = visual.Circle(mywin, radius=scalingFactor, fillColor=colors[5], pos=(width_plate / 6.4, -height_plate / 8.2)) mywin.winHandle.maximize() mywin.winHandle.set_fullscreen(True) mywin.winHandle.activate() # display white while True: white.draw() plate.draw() mywin.flip() if event.waitKeys(0.5) == ["escape"]: break event.clearEvents() startCamera(duration) clock = core.Clock() for frameN in range(duration): white.draw() plate.draw() shape1.setOri(speeds[0], operation=ops[0]) shape1b.draw() shape1.draw() shape2.setOri(speeds[1], operation=ops[1]) shape2b.draw() shape2.draw() shape3.setOri(speeds[2], operation=ops[2]) shape3b.draw() shape3.draw() shape4.setOri(speeds[3], operation=ops[3]) shape4b.draw() shape4.draw() shape5.setOri(speeds[4], operation=ops[4]) shape5b.draw() shape5.draw() shape6.setOri(speeds[5], operation=ops[5]) shape6b.draw() shape6.draw() mywin.logOnFlip(level=logging.CRITICAL, msg='sent on actual flip') mywin.flip() for frameN in range(300): white.draw() plate.draw() mywin.flip() mywin.close() core.quit()
core.quit() core.wait(0.1) # Now, you can change modes using bits.mode = 'mono++' # 'color++', 'mono++', 'bits++', 'auto++' or 'status' # Create a stimulus and draw as normal stim = visual.GratingStim(win, tex='sin', units='pix', size=400, sf=0.01, mask='gauss', autoLog=False) globalClock = core.Clock() while globalClock.getTime() < 3: t = globalClock.getTime() stim.phase = t * 3 # drift at 3Hz stim.draw() win.flip() # You can test pixel values (going to the box) using getVideoLine(); # this requires 'status' mode and that takes a few moments to set up bits.mode = 'status' core.wait(3) pixels = bits.getVideoLine(lineN=1, nPixels=5) print(pixels) # Check that the set up is working # level=0 just checks that system is the same from previous config
oddBallStim3 = visual.Circle( myWin, radius=oddBallMinRadius, # Martini used circles with diameter of 12 deg lineColorSpace='rgb', lineColor=stimColor, lineWidth=2.0, # in pixels units='deg', fillColorSpace='rgb', fillColor=stimColor, # beware, with convex shapes fill colors don't work # the anchor (rotation and vertices are position with respect to this) pos=[5 * np.cos(330 * np.pi / 180), 5 * np.sin(330 * np.pi / 180)], interpolate=True, autoLog=False) # this stim changes too much for autologging to be useful oddBallClock = core.Clock() response = [] counter = -20 for ix, dur in enumerate(possibleOddballDurations): oddBallStim1.setAutoDraw(True) oddBallStim2.setAutoDraw(True) oddBallStim3.setAutoDraw(True) myWin.flip() oddBallClock.reset() if type[ix]: oddBallMaxRadius1 = 3.53 / 2 oddBallMaxRadius2 = 3.53 / 3 oddBallMaxRadius3 = 3.53 / 4 else: oddBallMaxRadius1 = 3.53 / 2
colorSpace='rgb', blendMode='avg', useFBO=True, units='norm') # store frame rate of monitor if we can measure it expInfo['frameRate'] = win.getActualFrameRate() if expInfo['frameRate'] != None: frameDur = 1.0 / round(expInfo['frameRate']) else: frameDur = 1.0 / 60.0 # could not measure, so guess # create a default keyboard (e.g. to check for escape) defaultKeyboard = keyboard.Keyboard() # Initialize components for Routine "instructPractice" instructPracticeClock = core.Clock() instr1 = visual.TextStim( win=win, name='instr1', text= '请按键:\n\n记住要忽略你看到的词汇本身,然后在键盘上按这些键:\n看到红色的字按向左键\n看到绿色的字按向下键\n看到蓝色的字按向右键\n(按Esc键退出)\n\n现在按任意键就可以开始了!', font='Arial', pos=[0, 0], height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0)
instructions_p2 = ( "Choose the left box by pressing the left button with your left index finger and choose the right box by pressing the right button with your right index finger. \n\nNote that if you choose too slowly or too quickly, you won't earn any coins. Finally, remember to make your choice based on the color of the box. \n\nPress the green button when you're ready to begin the hunt!" ) slow_trial = ("Too slow! \nChoose quickly.") fast_trial = ("Too fast! \nSlow down. \nYou can continue in 5 seconds.") break_inst = ( "Feel free to take a break! \nPress the green button when you're ready to continue." ) #initialize dependent variables rt_list = [] choice_list = [] accuracy_list = [] #instantiate psychopy object instances clock = core.Clock() expTime_clock = core.Clock() trialTime_clock = core.Clock() testing_monitor = monitors.Monitor('testing_computer') testing_monitor.setSizePix = [1920, 1080] testing_monitor.saveMon() screen_size = testing_monitor.setSizePix center = [0, 0] if screen_size != testing_monitor.setSizePix: center[0] = (testing_monitor.setSizePix[0] / 2) - (screen_size[0] / 2) center[1] = (testing_monitor.setSizePix[1] / 2) - (screen_size[1] / 2) window = visual.Window(size = screen_size, units='pix', monitor = testing_monitor, color = [-1,-1,-1], \
# get a set of the non-ambiguous plaids: # transparent left/right and coherent nAmb_plaids = set(plaid_stims.keys()) - set(['amb', 'fix']) # get the velocity parameter that will be useful later on parameters = io.getSessionMetaData()['user_variables']['parameters'] velocity = parameters['velocity'] # TODO: initialise the log-normal parameters to some sensible values mu, sigma = 3, 2 # set up some timers # a global timer is available at the experiment level # this clock should never be reset to have a unique time base global_timer = core.Clock() # time to wait until next flip in non-ambiguous stimulus condition flip_timer = clock.CountdownTimer(0) # time between different percepts, useful to estimate the parameters mu and sigma percept_duration = clock.Clock() # total duration of the trial trial_timer = clock.CountdownTimer(0) # markov renewal process, can be updated all throughout the experiment mrp = stats.MarkovRenewalProcess( list(percepts.Percept().percept_dict['perceptual_states'])) # logging experiment messages to file log_filename = io.getSessionMetaData()['user_variables']['logfile'] logFile = logging.LogFile(f=log_filename, level=logging.EXP) trigger_filename = io.getSessionMetaData()['user_variables']['triggerfile']
#!/usr/bin/env python2 from psychopy import visual, event, core #create a window to draw in myWin =visual.Window((600,600), allowGUI=False, bitsMode=None, units='norm', winType='pyglet') #INITIALISE SOME STIMULI dotPatch =visual.DotStim(myWin, color=(1.0,1.0,1.0), dir=270, nDots=500, fieldShape='circle', fieldPos=(0.0,0.0),fieldSize=1, dotLife=5, #number of frames for each dot to be drawn signalDots='same', #are the signal dots the 'same' on each frame? (see Scase et al) noiseDots='direction', #do the noise dots follow random- 'walk', 'direction', or 'position' speed=0.01, coherence=0.9) message =visual.TextStim(myWin,text='Hit Q to quit', pos=(0,-0.5)) trialClock =core.Clock() while True:#forever dotPatch.draw() message.draw() myWin.flip()#redraw the buffer #handle key presses each frame for key in event.getKeys(): if key in ['escape','q']: print myWin.fps() myWin.close() core.quit() event.clearEvents('mouse')#only really needed for pygame windows
def flickerTrial(win, experimentalInfo, flickerFreq, side, useOddBall): from psychopy import visual, event """ Start the tracking trial """ # Generate the 4 balls as list balls = [] edge = experimentalInfo['SquareEdge'] # First two balls are left, second two balls are right positions = [ np.array([-edge / 2, -edge / 2]), np.array([-edge / 2, edge / 2]), np.array([edge / 2, -edge / 2]), np.array([edge / 2, edge / 2]) ] for i in range(0, 4): balls.append( Ball(win, position=positions[i], direction=np.array([0, 0]), speed=0, radius=experimentalInfo['BallRadius'], color='Black')) fixationBall = Ball(win, position=np.array([0.0, 0.0]), direction=np.array([0.0, 0.0]), speed=0.0, radius=0.15, color='White') oddBallIndex = randrange(0, 4) oddBalls = [balls[oddBallIndex]] noiseMaskStimuli = [] for i in range(0, 4): noiseMaskStimuli.append( visual.GratingStim(win, pos=positions[i], units='cm', tex=np.random.rand(256, 256) * 2.0 - 1.0, mask='circle', size=[ experimentalInfo['BallRadius'] * 2, experimentalInfo['BallRadius'] * 2 ])) arrows = [ visual.TextStim(win, "-->", pos=[0, 0]), visual.TextStim(win, "<--", pos=[0, 0]) ] # Initialize a color for the balls for ball in balls: ball.setColor('Black') if useOddBall: for oddBall in oddBalls: oddBall.setColor('White') # Draw the arrow cue trialClock = core.Clock() trialClock.reset() sideIndex = (side == 'Left') while (trialClock.getTime() < 2.0): arrows[sideIndex].draw() if (experimentalInfo['SaveVideo']): win.getMovieFrame() win.flip() totalMaskTime = 0.350 # seconds totalMaskTimeInFrames = int(round(totalMaskTime * win.measuredFPS)) for t in range(0, totalMaskTimeInFrames): for i in range(0, 4): noiseMaskStimuli[i].draw() if (experimentalInfo['SaveVideo']): win.getMovieFrame() win.flip() # Here instead of using timers we precompute the number of frames to display for the stimuli, so # that the calls to timers are avoided and the program is faster between # two flips totStimFrames = int(round(experimentalInfo['BlinkTime'] * win.measuredFPS)) totBlinkFrames = int(round(1.0 / flickerFreq * win.measuredFPS)) blinkFrame, totBlinks = 0, 0 times = [None] * totStimFrames switchIndices = [] for t in range(0, totStimFrames): fixationBall.draw() blinkFrame = blinkFrame + 1 oldTotBlinks = totBlinks if (blinkFrame >= totBlinkFrames): blinkFrame = 0 totBlinks = totBlinks + 1 if (oldTotBlinks < totBlinks): switchIndices.append(t) if (totBlinks % 2): for ball in balls: ball.setColor('White') if useOddBall: for oddBall in oddBalls: oddBall.setColor('Black') else: for ball in balls: ball.setColor('Black') if useOddBall: for oddBall in oddBalls: oddBall.setColor('White') for ball in balls: ball.draw() if (experimentalInfo['SaveVideo']): win.getMovieFrame() times[t] = win.flip() totalMaskTimeInFrames = int(round(totalMaskTime * win.measuredFPS)) for t in range(0, totalMaskTimeInFrames): for i in range(0, 4): noiseMaskStimuli[i].draw() if (experimentalInfo['SaveVideo']): win.getMovieFrame() win.flip() times = np.array(times) # switchIndices=np.array(switchIndices) # switchTimes=np.diff(times[switchIndices]) # print "Average switch times",np.average(switchTimes),"corresponding to ",1.0/np.average(switchTimes)," [Hz]" # print "Average inversion times # error=",np.average(switchTimes-1.0/flickerFreq)*1000,"[ms]" # Get the subject response event.getKeys() trialClock = core.Clock() trialClock.reset() response = None while True: keys = event.getKeys() fixationBall.draw() if 's' in keys: response = (sideIndex == (oddBallIndex >= 2)) trialClock.reset() break if 'd' in keys: response = (sideIndex == (oddBallIndex < 2)) trialClock.reset() break if 'escape' in keys: win.close() core.quit() if (experimentalInfo['SaveVideo']): win.getMovieFrame() win.flip() print sideIndex, side, oddBallIndex, response if (experimentalInfo['SaveVideo']): import os currentpath = os.getcwd() savedatapath = currentpath + os.path.sep + 'data' outputVideo = savedatapath + os.path.sep + \ "frames" + os.path.sep + 'Flicker.png' print "Saving video to " + outputVideo win.saveMovieFrames(outputVideo) return response
if int( expInfo['session'] ) < 3: # For exps 1 and 2 set mask duration as .5 sec, otherwise set mask duration as 0 (meaning the mask doesn't appear ) mask_duration = to_frames(.5) else: mask_duration = 0 stim_delay_min = to_frames( 1.5) # Minimum delay between mask and stimlus (for randomization) stim_delay_max = to_frames( 2.5) # Maximum delay between mask and stimlus (for randomization) ##--------------------------------CREATE TIMERS-------------------------------## globalClock = core.MonotonicClock( ) # To track the time since experiment started trialClock = core.Clock() # Unlike globalclock, gets reset each trial ##---------------------------TRIAL MATRIX & RANDOMIZATION---------------------## SRmapping_full = [ 'z', 'num_3' ] # `num_3` corresponds to the 3 located only on the numeric keypad taskColorRGB = ["#0000ff", "#00ff00"] # blue, green ptrials = 12 # Number of practice trials maintrials = 250 # Number of main experimental trials switchfreq = .25 # Percent of trials that are switches switchtrials = int(np.floor(maintrials * switchfreq)) # Number of switch trials repeattrials = maintrials - switchtrials # Number of repeat trials posttrials = 30 # Number of trials at the end testing subliminal perception
from psychopy import core, visual, event import socket, pickle code = 'utf-8' c = socket.socket(socket.AF_INET, socket.SOCK_STREAM) c.connect(('hpc.psy.ntu.edu.tw', 1234)) c.sendall('b04207003'.encode(code)) # Change your ID here! print(c.recv(9).decode(code)) # Should show your ID! w = visual.Window(size=[800, 400], units='norm') for t in range(8): sz = int(c.recv(2).decode(code)) # size word = pickle.loads(c.recv(sz)) print(word) # Make your changes here (3 points for graphical displaying): word_vis = visual.TextStim(w, text=word['text'], color=word['color']) word_vis.draw() w.flip() r = event.waitKeys(keyList=['r', 'g', 'b', 'y'], timeStamped=core.Clock()) c.sendall(pickle.dumps(r[0])) print(c.recv(5).decode(code)) # 3 points for passing
def __init__(self, win, daq, parameters, file_save, signal_model, language_model, fake): super(RSVPCopyPhraseTask, self).__init__() self.window = win self.frame_rate = self.window.getActualFrameRate() self.parameters = parameters self.daq = daq self.static_clock = core.StaticPeriod(screenHz=self.frame_rate) self.experiment_clock = core.Clock() self.buffer_val = parameters['task_buffer_len'] self.alp = alphabet(parameters) self.rsvp = _init_copy_phrase_display(self.parameters, self.window, self.daq, self.static_clock, self.experiment_clock) self.file_save = file_save trigger_save_location = f"{self.file_save}/{parameters['trigger_file_name']}" self.trigger_file = open(trigger_save_location, 'w') self.session_save_location = f"{self.file_save}/{parameters['session_file_name']}" self.wait_screen_message = parameters['wait_screen_message'] self.wait_screen_message_color = parameters[ 'wait_screen_message_color'] self.stim_number = parameters['stim_number'] self.stim_length = parameters['stim_length'] self.time_cross = parameters['time_cross'] self.time_target = parameters['time_target'] self.time_flash = parameters['time_flash'] self.timing = [self.time_target, self.time_cross, self.time_flash] self.color = [ parameters['target_letter_color'], parameters['fixation_color'], parameters['stim_color'] ] self.task_info_color = parameters['task_color'] self.stimuli_height = parameters['stim_height'] self.is_txt_stim = parameters['is_txt_stim'] self.eeg_buffer = parameters['eeg_buffer_len'] self.copy_phrase = parameters['task_text'] self.spelled_letters_count = int(parameters['spelled_letters_count']) if self.spelled_letters_count > len(self.copy_phrase): self.logger.debug('Already spelled letters exceeds phrase length.') self.spelled_letters_count = 0 self.max_seq_length = parameters['max_seq_len'] self.max_seconds = parameters['max_minutes'] * 60 # convert to seconds self.max_seq_per_trial = parameters['max_seq_per_trial'] self.fake = fake self.language_model = language_model self.signal_model = signal_model self.down_sample_rate = parameters['down_sampling_rate'] self.filter_low = self.parameters['filter_low_pass'] self.filter_high = self.parameters['filter_high_pass'] self.fitler_order = self.parameters['filter_order'] self.notch_filter_frequency = self.parameters['notch_filter_frequency'] self.min_num_seq = parameters['min_seq_len'] self.collection_window_len = parameters[ 'collection_window_after_trial_length'] self.static_offset = parameters['static_trigger_offset'] self.show_feedback = parameters['show_feedback'] self.feedback_color = parameters['feedback_message_color'] if self.show_feedback: self.feedback = VisualFeedback(self.window, self.parameters, self.experiment_clock)
def realTrials(randomizedTrials, dataFile): # append data to file and prepare timer f = open(dataFile, "a") timer = core.Clock() # present real trial instructions testinstructions = images['test'][0] testinstructions.draw() win.flip() core.wait(ISI) event.waitKeys(keyList=['space']) # present real trial instructions trialNum = 0 for block in randomizedTrials: # block[('A''rc16', 'r', 'r16', 'z'), ('rc35', 'u', 'u35', 'n'), (... for trial in block: # trial, ('A', 'rc13', 's', 's13', 'n') b = trial[0] rc = trial[1] targetType = trial[2] target = trial[3] correctResp = trial[4] #increment trial number trialNum = trialNum + 1 #blank and ref cat win.flip() displayRC = images[rc][0] displayRC.pos = [0, 100] displayRC.draw() displayRC.setAutoDraw(True) core.wait(ISI) #0.5s win.flip() core.wait(rcWait1) #display rc frame1 for 1200ms #display fixation cross for .2s fixCross.draw() win.flip() core.wait(crossDur) #0.2s #display target for .2s displayTarget = images[target][0] displayTarget.draw() timer.reset() # collect rt before target appears win.flip() resp = event.waitKeys(maxWait=targetWait, keyList=['z', 'n']) RT = str(timer.getTime() * 1000) displayRC.setAutoDraw(False) if not resp: win.flip() resp = event.waitKeys(keyList=['z', 'n', 'q']) RT = str(timer.getTime() * 1000) win.flip() if resp[0] == 'q': core.quit() elif resp[0] == correctResp: correct = '1' else: correct = '0' # write in data file win.flip() realTrials = ('\t'.join([ str(trialNum), str(b), rc, targetType, target, correctResp, resp[0], correct, RT ]) + '\n') f.write(realTrials) core.wait(ITI) f.close()
if dlg.OK: #save params to file for next time #toFile('lastParams.pickle', expInfo) print('ok') else: core.quit() #the user hit cancel so exit expInfo['date'] = dateStr expInfo['expName'] = expName fixedExpInfo.update(expInfo) print(fixedExpInfo['group']) fileName = fixedExpInfo['group'] +' SubID-' + fixedExpInfo['Subject ID'] + '-' + dateStr globalClock = core.Clock() logging.setDefaultClock(globalClock) # --------------- LOGGING FILE --------------- # logFileName = 'MyFlanker-%s-%s' % (expInfo['date'], dateStr) logging.LogFile((logFileName + '.log'), level=logging.INFO) logging.log(level=logging.INFO, msg='---START PARAMS---') logging.log(level=logging.INFO, msg='date: %s' % expInfo['date']) logging.log(level=logging.INFO, msg='group: %s' % fixedExpInfo['group']) logging.log(level=logging.INFO, msg='date: %s' % dateStr) logging.log(level=logging.INFO, msg='respKeys: %s' % respKeys) endExpNow = False #flag for 'escape' from exp
def showdisplay(tasktype): global chosenColor global x global y global reactionTime if tasktype.lower() == 'p': if chosenColor == 'Green' and y <= 5: y = y + 1 #Adds to the counter taskstore.append('L/H') digitColor = colors[1] digitVal = random.choice(numbers) print(digitVal) numValue.append(digitVal) texttodisplay = str(digitVal) msg = visual.TextStim(win=mywin, text=texttodisplay, color=digitColor, height=72.0) msg.draw() mywin.flip() reactionTime = core.Clock() responseCheck(chosenColor, digitVal) if y == 5: y = 0 chosenColor = 'Red' reactionTime = 0.0 blankscreen() core.wait(intertrialTime) elif chosenColor == 'Red' and x <= 5: x = x + 1 #Adds to the counter taskstore.append('O/E') digitVal = random.choice(numbers) digitColor = colors[0] print(digitVal) numValue.append(digitVal) texttodisplay = str(digitVal) msg = visual.TextStim(win=mywin, text=texttodisplay, color=digitColor, height=72.0) msg.draw() mywin.flip() reactionTime = core.Clock() responseCheck(chosenColor, digitVal) if x == 5: x = 0 chosenColor = 'Green' reactionTime = 0.0 blankscreen() core.wait(intertrialTime) elif tasktype.lower() == 'u': digitVal = random.choice(numbers) digitColor = random.choice(colors) print(digitVal) numValue.append(digitVal) chosenColor = digitColor if chosenColor == "Green": taskstore.append('L/H') elif chosenColor == "Red": taskstore.append('O/E') texttodisplay = str(digitVal) msg = visual.TextStim(win=mywin, text=texttodisplay, color=digitColor, height=72.0) msg.draw() mywin.flip() reactionTime = core.Clock() responseCheck(chosenColor, digitVal) blankscreen() core.wait(intertrialTime)
fullscr=True, screen=0, allowGUI=False, allowStencil=False, monitor='testMonitor', color='black', colorSpace='rgb') # store frame rate of monitor if we can measure it successfully expInfo['frameRate'] = win.getActualFrameRate() if expInfo['frameRate'] != None: frameDur = 1.0 / round(expInfo['frameRate']) else: frameDur = 1.0 / 60.0 # couldn't get a reliable measure so guess # Initialize components for Routine "instructions" instructionsClock = core.Clock() instrText = visual.TextStim( win=win, ori=0, name='instrText', text=u'Ment\xe1ln\xed rotace prostorov\xfdch sc\xe9n', font='Arial', pos=[0, 0], height=0.1, wrapWidth=None, color='white', colorSpace='rgb', opacity=1, depth=0.0) # Initialize components for Routine "Prestavka"
def do_run(stimset): #instructions if version == 'A' or 'B': instruct_screen.draw() else: instruct_screen_practice.draw() win.flip() event.waitKeys(keyList=('space','2')) if stimset == 'face': instruct_screen1_face.draw() win.flip() else: instruct_screen1_image.draw() win.flip() event.waitKeys(keyList=('space','2')) instruct_screen2.draw() win.flip() event.waitKeys(keyList=('space','2')) if stimset == 'face': if version == 'A' or 'B': instruct_screen3_face.draw() else: instruct_screen3_face_practice.draw() else: if version == 'A' or 'B': instruct_screen3_image.draw() else: instruct_screen3_image_practice.draw() win.flip() event.waitKeys(keyList=('space','2')) #wait for scan trigger if version == 'A' or 'B': ready_screen.draw() else: ready_screen_practice.draw() win.flip() event.waitKeys(keyList=('equal')) run_start = time.time() #set Version ITI, Image orders, feedback order pic_path = os.path.join(os.getcwd(), 'pictureFolder', f'{version}_{stimset}') #lists to store logging clock = core.Clock() clock.reset() onset = [] duration = [] condition = [] resp_val = [] responsetime = [] b_1 = [] b_2 = [] b_3 = [] for trial in reference.iterrows(): trial_start = clock.getTime() row_counter = trial[0] pic_L = visual.ImageStim(win,os.path.join(pic_path, reference.loc[reference.index[row_counter], f'{version}_{stimset}_L']), pos =(-7,0),size=(11.2,17.14)) pic_R = visual.ImageStim(win,os.path.join(pic_path, reference.loc[reference.index[row_counter], f'{version}_{stimset}_R']), pos =(7,0),size=(11.2,17.14)) border = visual.ShapeStim(win, vertices=pic_L.verticesPix, units='pix', fillColor = 'grey', lineColor = 'grey') border2 = visual.ShapeStim(win, vertices=pic_R.verticesPix, units='pix', fillColor = 'grey', lineColor = 'grey') trial_timer = core.CountdownTimer(5.2) while trial_timer.getTime() > 0: #1st fixation if stimset == 'image': timer = core.CountdownTimer(fixation_time + 0.034) else: timer = core.CountdownTimer(fixation_time) while timer.getTime() > 0: fixation.draw() win.flip() fixationPre_dur = clock.getTime() - trial_start #decision_phase timer = core.CountdownTimer(decision_time) resp = event.getKeys(keyList = responseKeys) decision_onset = clock.getTime() while timer.getTime() > 0: pic_L.draw() pic_R.draw() win.flip() resp = event.getKeys(keyList = responseKeys) if len(resp)>0: if 'z' in resp: log.to_csv(os.path.join("data",subj_id, f"{subj_id}_{stimset}-{version}.tsv"), sep='\t', index = False) core.quit() if selected == 2 or 3: selected = int(resp[0]) resp_onset = clock.getTime() rt = resp_onset - decision_onset border.autoDraw=True border2.autoDraw=True pic_L.draw() pic_R.draw() win.flip() core.wait(decision_time - rt) break else: selected = '999' rt = '999' core.wait(.25) decision_dur = clock.getTime() - decision_onset border.autoDraw=False border2.autoDraw=False #2nd fixation timer = core.CountdownTimer(fixation_time) fixationPost_onset = clock.getTime() while timer.getTime() > 0: fixation.draw() win.flip() fixationPost_dur = clock.getTime() - fixationPost_onset #feedback timer = core.CountdownTimer(fb_dur) feedback_onset = clock.getTime() fb_type = reference.loc[reference.index[row_counter], f'{version}_feedback'] if fb_type == 'loss': while timer.getTime() > 0: down_arrow.draw() win.flip() elif fb_type == 'win': while timer.getTime() > 0: up_arrow.draw() win.flip() else: print('Feedback Error') feedback_dur = clock.getTime() - feedback_onset #ITI ITI_onset = clock.getTime() ITI = reference.loc[reference.index[row_counter], f'{version}_ITI'] timer = core.CountdownTimer(ITI) while timer.getTime() > 0: fixation.draw() win.flip() core.wait(ITI) ITI_dur = clock.getTime() - ITI_onset #logging condition.append('fixation_1') onset.append(trial_start) duration.append(fixationPre_dur) resp_val.append('999') responsetime.append('999') condition.append('face') onset.append(decision_onset) duration.append(decision_dur) resp_val.append(selected) responsetime.append(rt) condition.append('fixation_2') onset.append(fixationPost_onset) duration.append(fixationPre_dur) resp_val.append('999') responsetime.append('999') condition.append('feedback ' + fb_type) onset.append(feedback_onset) duration.append(feedback_dur) resp_val.append('999') responsetime.append('999') condition.append('ITI') onset.append(ITI_onset) duration.append(ITI_dur) resp_val.append('999') responsetime.append('999') #BIDS Log b_1.append(decision_onset) b_2.append(decision_dur) b_3.append(fb_type) #data to frame log = pd.DataFrame( {'onset':onset, 'duration':duration, 'trial_type':condition, 'rt':responsetime, 'resp':resp_val}) bidsEvents = pd.DataFrame( {'onset':b_1, 'duration':b_2, 'trial_type':b_3}) log.to_csv(os.path.join("data",subj_id, f"sub-{subj_id}_{stimset}-{version}.tsv"), sep='\t', index = False) bidsEvents.to_csv(os.path.join("data",subj_id, f"sub-{subj_id}_task-socialReward-{stimset}-{version}.tsv"), sep='\t', index = False) run_end = time.time() run_length = run_end -run_start print(run_length) event.clearEvents() return;
# Initialize components for Routine "pause" trial_stim = visual.TextStim(win=win, name='trial_stim', text='End of trial.\n\nEnd with space.\n', font='Arial', pos=[0, 0], height=30, wrapWidth=None, ori=0, color="white", colorSpace='rgb', opacity=1, depth=0.0) # 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 bl_instructionsClock = core.Clock() pauseClock = core.Clock() ###################################################################################################### ##################### Routine "iViewX_Connect" # routine_helper comps = [] iview_connect_clock = core.Clock() routine_helper = RoutineHelper(win, comps) routine_helper.reset_components()
total_degrees = 5 # Setup stimulus win = visual.Window( size=(500 , 500), fullscr=False, screen=0, winType='pyglet',useRetina=True, monitor=mon, color=[0,0,0], colorSpace='rgb') # grating = visual.GratingStim(win, tex='sin', sf=5, name='grating',size=(1,1)) velocity = 2.5 # dps spatial_wavelength = 2.5 sf = 1/spatial_wavelength grating = visual.GratingStim( win=win, name='grating',tex='sin', size=(total_degrees, total_degrees), sf=sf,units='degFlat') grating.autoDraw = True # Automatically draw every frame grating.autoLog = False # Or we'll get many messages about phase change # Let's draw a stimulus for 2s, drifting for middle 0.5s epoch_clock = core.Clock() epoch_duration = 10 while epoch_clock.getTime() < epoch_duration: # For moving the grating we will need to advance the phase # according to the desired velocity and screen refresh rate #| v (degree/s) / refresh rate (update/s) | grating.phase += (velocity/refresh_rate)/spatial_wavelength win.flip()
allowGUI=False, allowStencil=False, monitor='testMonitor', color='black', colorSpace='rgb', blendMode='avg', useFBO=True) # store frame rate of monitor if we can measure it expInfo['frameRate'] = win.getActualFrameRate() if expInfo['frameRate'] != None: frameDur = 1.0 / round(expInfo['frameRate']) else: frameDur = 1.0 / 60.0 # could not measure, so guess # Initialize components for Routine "wait_for_trig" wait_for_trigClock = core.Clock() initial_fix = visual.TextStim(win=win, name='initial_fix', text='+', font='Arial', pos=(0, 0), height=0.2, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, languageStyle='LTR', depth=0.0) # Initialize components for Routine "trials_2"
if my_dlg.OK == False: core.quit() date = data.getDateStr() id_participant = str(my_dlg.data[0]) session = str(my_dlg.data[1]) file_name = id_participant + '_box_upd_' + date + '_' + session + '.csv' win = visual.Window(color=(-1, -1, -1), fullscr=True, units='pix', size=(800, 600)) win.mouseVisible = False clock = core.Clock() txt_instr = visual.TextStim(win, color=(1, 1, 1), height=26, wrapWidth=900) txt_feedback = visual.TextStim(win, color=(1, 1, 1), height=40) txt_topinstr = visual.TextStim(win, color=(1, 1, 1), pos=(0, 280), wrapWidth=900) txt_input = visual.TextStim(win, color=(1, 1, 1), height=93) A1 = visual.TextStim(win, color=(1, 1, 1), height=93) A2 = visual.TextStim(win, color=(1, 1, 1), height=93) A3 = visual.TextStim(win, color=(1, 1, 1), height=93) B1 = visual.TextStim(win, color=(1, 1, 1), height=93) B2 = visual.TextStim(win, color=(1, 1, 1), height=93) B3 = visual.TextStim(win, color=(1, 1, 1), height=93)
allowStencil=False, monitor='testMonitor', color=[0, 0, 0], colorSpace='rgb', blendMode='avg', useFBO=True, units='height') # store frame rate of monitor if we can measure it expInfo['frameRate'] = win.getActualFrameRate() if expInfo['frameRate'] != None: frameDur = 1.0 / round(expInfo['frameRate']) else: frameDur = 1.0 / 60.0 # could not measure, so guess # Initialize components for Routine "trial" trialClock = core.Clock() sound_1 = sound.Sound('A', secs=1.0, stereo=True) sound_1.setVolume(1) # 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
def do_trial(filename, username, trial_num, trial_total): # file to load # username : unique id # trial_num : trial number # trial_total : total number of trials # parse the filename m = re.match(imgs_in + '/(.*).png', filename, re.M | re.I) g = m.groups() base = g[0] fout_img = imgs_out + '/' + username + '_' + base + '.png' fout_stk = stks_out + '/' + username + '_' + base + '.csv' # create a window, a mouse monitor and a clock w = visual.Window([width, height], pos=[window_offset, 0], winType='pyglet') m = event.Mouse(win=w) tick = core.Clock() # initialize variables drawlist = [] timelist = [] mousedown = False tick.reset() # Load canvas cwidth = 1 cheight = 0.5 cpos = (0, -0.5) canvas = visual.Rect(w, pos=cpos, width=cwidth, height=cheight, fillColor='white') # Load display image IMG = Image.open(filename) currwidth = float(max(IMG.size[0], IMG.size[1])) background_width = width / 2.0 # base size of target image basewidth = background_width * pfill # proportion of base that target image fills wpercent = (basewidth / currwidth) wsize = int((float(IMG.size[0]) * float(wpercent))) hsize = int((float(IMG.size[1]) * float(wpercent))) IMG = IMG.resize((wsize, hsize), Image.ANTIALIAS) sz = (int(background_width), int(background_width)) PADDING = Image.new('RGB', sz, 'white') PADDING.paste(IMG, ((sz[0] - IMG.size[0]) / 2, (sz[1] - IMG.size[1]) / 2)) im = visual.SimpleImageStim(w, PADDING, pos=(0, 0.5)) im.setAutoDraw(True) im.autoLog = False # For rescaling time series cverts = canvas.vertices # [top left, top right, bottom right, bottom left] v = [np.array(c) + np.array(cpos) for c in cverts] xscale = v[1][0] - v[0][0] yscale = v[1][1] - v[2][1] center = (v[0] + v[2]) / 2 txt = " Please draw this (" + str(trial_num) + ' of ' + str( trial_total ) + ').\nPress <space> when done.\nPress <backspace> to undo.' t1 = visual.TextStim(w, text=txt, pos=(0, 0), color='black', height=0.035) t1.setAutoDraw(True) t1.autoLog = False D = Drawing(w, canvas) while tick.getTime() < float('Inf'): D.draw() w.flip() # get mouse information pos = m.getPos().tolist() tt = int(tick.getTime() * 1000) # time in milliseconds # record if not canvas.contains(pos): # if we move off the canvas mousedown = False elif m.getPressed()[0] == 1: # if the mouse is down, determine if we started a new stroke if mousedown == False: D.new_stroke(pos, tt) mousedown = True else: D.append(pos, tt) elif m.getPressed()[0] == 0: # if the mouse is up, reset and wait for new drawing phase mousedown = False # special key events if event.getKeys(keyList=key_continue) == [key_continue]: # if space is pressed, the drawing is done break if event.getKeys(keyList=key_undo) == [key_undo]: # if undo key is pressed, delete the last stroke D.undo() mousedown = False # make image D.draw(from_scratch=True) IMG = w.getMovieFrame(buffer='back') IMG = IMG.crop(window_grab) IMG.save(fout_img) # print time course to text file traj = get_strokes(D, center, xscale, yscale) with open(fout_stk, "wb") as f: writer = csv.writer(f) writer.writerows(traj) w.close()
import pyxid #to use the Cedrus response box # Setup the Window win = visual.Window(size=(1280, 1024), fullscr=True, screen=0, allowGUI=False, allowStencil=False, monitor='testMonitor', color=[1.000,1.000,1.000], colorSpace='rgb', blendMode='avg', useFBO=True, ) # store frame rate of monitor if we can measure it successfully expInfo['frameRate']=win.getActualFrameRate() if expInfo['frameRate']!=None: frameDur = 1.0/round(expInfo['frameRate']) else: frameDur = 1.0/60.0 # couldn't get a reliable measure so guess # Initialize components for Routine "start" startClock = core.Clock() textStart = visual.TextStim(win=win, ori=0, name='textStart', text='Waiting to start...', font='Arial', pos=[0, 0], height=0.065, wrapWidth=None, color='black', colorSpace='rgb', opacity=1, depth=0.0) mouseStart = event.Mouse(win=win) x, y = [None, None] # Initialize components for Routine "countback" countbackClock = core.Clock() textFive = visual.TextStim(win=win, ori=0, name='textFive', text='5', font='Arial', pos=[0, 0], height=0.065, wrapWidth=None, color='black', colorSpace='rgb', opacity=1, depth=0.0)
[0, 0], [-1, 0]]) #mywin=visual.Window([1280,1024],monitor="Dell Inc. 17",units="pix",fullscr=True,screen=1) #plate=visual.Rect(win=mywin,size=(width_plate,height_plate),lineColor=[0,0,0],lineColorSpace="rgb255",lineWidth=4) #white=visual.ImageStim(win=mywin,image="Solid_white.png",size=(1280,1024),pos=[0,0]) mywin = None plate = None white = None #background=visual.Circle(win=mywin,radius=1, fillColor='red') #rad = visual.RadialStim(win=mywin,mask='circle',size=(20,20),pos=[20,20]) log_file = [] timer = core.Clock() def startCamera(nframes): ''' Link to (and initiate) capture from the camera and pause for a few (3) seconds before displaying the stimuli on the screen ''' # the duration is in frames -- need to convert it into seconds based on the screen's # refresh rate nSec = nframes / 60.0 # assuming 60 Hz emprically validated nSec = nSec + 10 args = ("/usr/src/flycapture/bin/SaveImageToAviEx", str(nSec)) p = subprocess.Popen(args) time.sleep(3)
def show(win, screen_res, experiment, config, part_id, port_eeg, trigger_no, triggers_list, frame_time=1 / 60.): beh = [] rt_sum = 0 rt_mean = 0 fixation = visual.TextStim(win, color='black', text='+', height=2 * config['Fix_size'], pos=(0, 10)) clock = core.Clock() for block in experiment: if block['type'] == 'break': show_info(win=win, file_name=block['file_name'], text_size=config['Text_size'], screen_width=screen_res['width'], part_id=part_id, beh=beh, triggers_list=triggers_list) continue if block['type'] == 'calibration': rt_mean = 0 rt_sum = 0 for trial in block['trials']: trigger_name = prepare_trigger_name(trial=trial, block_type=block['type']) reaction_time = None response = None acc = 'negative' # draw fixation fixation_show_time = random.uniform(config['Fixation_show_time'][0], config['Fixation_show_time'][1]) show_text(win, fixation, fixation_show_time, part_id, beh, triggers_list) # draw cue trigger_no, triggers_list = prepare_trigger(trigger_type=TriggerTypes.CUE, trigger_no=trigger_no, triggers_list=triggers_list, trigger_name=trigger_name) cue_show_time = random.uniform(config['Cue_show_time'][0], config['Cue_show_time'][1]) trial['cue']['stimulus'].setAutoDraw(True) win.callOnFlip(clock.reset) event.clearEvents() win.flip() send_trigger(port_eeg=port_eeg, trigger_no=trigger_no, send_eeg_triggers=config['Send_EEG_trigg']) while clock.getTime() < cue_show_time: check_exit(part_id=part_id, beh=beh, triggers_list=triggers_list) win.flip() # print (cue_show_time - clock.getTime())*1000 trial['cue']['stimulus'].setAutoDraw(False) win.flip() # draw target trigger_no, triggers_list = prepare_trigger(trigger_type=TriggerTypes.TARGET, trigger_no=trigger_no, triggers_list=triggers_list, trigger_name=trigger_name) target_show_time = random.uniform(config['Target_show_time'][0], config['Target_show_time'][1]) trial['target']['stimulus'].setAutoDraw(True) win.callOnFlip(clock.reset) event.clearEvents() win.flip() send_trigger(port_eeg=port_eeg, trigger_no=trigger_no, send_eeg_triggers=config['Send_EEG_trigg']) while clock.getTime() < target_show_time: key = event.getKeys(keyList=config['Keys']) if key: reaction_time = clock.getTime() trigger_no, triggers_list = prepare_trigger(trigger_type=TriggerTypes.RE, trigger_no=trigger_no, triggers_list=triggers_list, trigger_name=trigger_name[:-1]+key[0]) send_trigger(port_eeg=port_eeg, trigger_no=trigger_no, send_eeg_triggers=config['Send_EEG_trigg']) response = key[0] break check_exit(part_id=part_id, beh=beh, triggers_list=triggers_list) win.flip() # print (target_show_time-clock.getTime())*1000 trial['target']['stimulus'].setAutoDraw(False) win.flip() # empty screen empty_screen_show_time = random.uniform(config['Empty_screen_show_time'][0], config['Empty_screen_show_time'][1]) while clock.getTime() < empty_screen_show_time: check_exit(part_id=part_id, beh=beh, triggers_list=triggers_list) win.flip() # print (empty_screen_show_time-clock.getTime())*1000 # verify reaction if response and trial['type'] == 'go': if not (block['type'] == 'experiment' and reaction_time > rt_mean - rt_mean * block['cutoff']): acc = 'positive' elif not response and trial['type'] != 'go': acc = 'positive' # calibration if block['type'] == 'calibration' and trial['type'] == 'go' and reaction_time is not None: rt_sum += reaction_time # feedback if block['type'] == 'experiment': # choose feedback type feedback_type = 'Feedback_{}_{}_'.format(trial['type'], acc) # draw feedback if config[feedback_type + 'show']: feedback_text = config[feedback_type + 'text'] feedback_text = visual.TextStim(win, color='black', text=feedback_text, height=config['Feedback_size']) feedback_show_time = random.uniform(config['Feedback_show_time'][0], config['Feedback_show_time'][1]) if acc == 'positive': trigger_type = TriggerTypes.FEEDB_GOOD else: trigger_type = TriggerTypes.FEEDB_BAD trigger_no, triggers_list = prepare_trigger(trigger_type=trigger_type, trigger_no=trigger_no, triggers_list=triggers_list, trigger_name=trigger_name) feedback_text.setAutoDraw(True) win.flip() send_trigger(port_eeg=port_eeg, trigger_no=trigger_no, send_eeg_triggers=config['Send_EEG_trigg']) time.sleep(feedback_show_time - frame_time) feedback_text.setAutoDraw(False) check_exit(part_id=part_id, beh=beh, triggers_list=triggers_list) win.flip() # save beh beh.append({'block type': block['type'], 'trial type': trial['type'], 'cue name': trial['cue']['name'], 'target name': trial['target']['name'], 'response': response, 'rt': reaction_time, 'reaction': True if acc == 'positive' else False, 'cal mean rt': rt_mean, 'cutoff': block['cutoff'] if block['type'] == 'experiment' else None}) if block['type'] == 'calibration': rt_mean = rt_sum / len([trial for trial in block['trials'] if trial['type'] == 'go']) return beh, triggers_list
allowStencil=False, monitor='VIEWPixx', color=[-0.122, -0.122, -0.122], colorSpace='rgb', blendMode='avg', useFBO=True, units='pix') # store frame rate of monitor if we can measure it expInfo['frameRate'] = win.getActualFrameRate() if expInfo['frameRate'] != None: frameDur = 1.0 / round(expInfo['frameRate']) else: frameDur = 1.0 / 60.0 # could not measure, so guess # Initialize components for Routine "calibration" calibrationClock = core.Clock() # Initialize components for Routine "instructions" instructionsClock = core.Clock() instructions_text = visual.TextStim( win=win, name='instructions_text', text= 'Stay fixated on the central white dot and ignore the word itself. To respond press:\n - Left for red LETTERS\n - Down for green LETTERS\n - Right for blue LETTERS\n\nPress SPACE to continue.', font='Calibri', units='pix', pos=[0, 0], height=50, wrapWidth=800, ori=0, color=[1, 1, 1],
def create_stimuli(win, xpos): clock = core.Clock() voice = sound.Sound('A', secs=3) fixation_left = visual.Polygon(win=win, name='fixation_left', edges=120, size=FIX_SIZE, ori=0, pos=[-xpos, 0], lineWidth=1, lineColor=[-1, -1, -1], lineColorSpace='rgb', fillColor=[-1, 1, -1], fillColorSpace='rgb', opacity=OPACITY, interpolate=True) fixation_right = visual.Polygon(win=win, name='fixation_right', edges=120, size=FIX_SIZE, ori=0, pos=[xpos, 0], lineWidth=1, lineColor=[-1, -1, -1], lineColorSpace='rgb', fillColor=[-1, 1, -1], fillColorSpace='rgb', opacity=OPACITY, interpolate=True) line_left = visual.GratingStim(win=win, name='line_left', tex='sin', mask='gauss', ori=0, pos=[-xpos, 0], size=LINE_SIZE, sf=None, phase=0.0, color=[1, 1, 1], colorSpace='rgb', opacity=OPACITY, texRes=512, interpolate=True, depth=-1.0) line_right = visual.GratingStim(win=win, name='line_right', tex='sin', mask='gauss', ori=0, pos=[xpos, 0], size=LINE_SIZE, sf=None, phase=0.0, color=[1, 1, 1], colorSpace='rgb', opacity=OPACITY, texRes=512, interpolate=True, depth=-1.0) noise_left = visual.GratingStim(win=win, name='noise_left', tex=make_noise(), mask='gauss', ori=0, pos=[-xpos, 0], size=NOISE_SIZE, sf=None, phase=0.0, color=[1, 1, 1], colorSpace='rgb', opacity=0.6, texRes=512, interpolate=True, depth=-1.0) noise_right = visual.GratingStim(win=win, name='noise_right', # tex=np.random.random((512, 512))*2-1, tex=make_noise(), mask='gauss', ori=0, pos=[xpos, 0], size=NOISE_SIZE, sf=None, phase=0.0, color=[1, 1, 1], colorSpace='rgb', opacity=0.6, texRes=512, interpolate=True, depth=-1.0) return(clock, voice, fixation_left, fixation_right, line_left, line_right, noise_left, noise_right)
allowStencil=False, monitor='testMonitor', color=[-1.000, -1.000, -1.000], colorSpace='rgb', blendMode='avg', useFBO=True, ) # store frame rate of monitor if we can measure it successfully expInfo['frameRate'] = win.getActualFrameRate() if expInfo['frameRate'] != None: frameDur = 1.0 / round(expInfo['frameRate']) else: frameDur = 1.0 / 60.0 # couldn't get a reliable measure so guess # Initialize components for Routine "trial" trialClock = core.Clock() Welcome = visual.TextStim( win=win, ori=0, name='Welcome', text= 'Welcome to the Biomarker Imaging Study\n\nPress any button when ready to continue', font='Arial', pos=[0, 0], height=0.1, wrapWidth=None, color='white', colorSpace='rgb', opacity=1, depth=0.0)
dataFileName=filename) # Start Code - component code to be run before the window creation # Setup the Window win = visual.Window(size=(1440, 900), fullscr=True, screen=0, allowGUI=False, allowStencil=False, monitor='testMonitor', color='black', colorSpace='rgb') # store frame rate of monitor if we can measure it successfully expInfo['frameRate']=win.getActualFrameRate() if expInfo['frameRate']!=None: frameDur = 1.0/round(expInfo['frameRate']) else: frameDur = 1.0/60.0 # couldn't get a reliable measure so guess # Initialize components for Routine "instr1" instr1Clock = core.Clock() instructions1 = visual.TextStim(win=win, ori=0, name='instructions1', text='You will be watching a 15 minute film. Please watch very carefully and try to understand what each character is feeling or thinking.', font='Arial', pos=[0, 0], height=0.1, wrapWidth=1.3, color='white', colorSpace='rgb', opacity=1, depth=0.0) # Initialize components for Routine "instr2" instr2Clock = core.Clock() instructions2 = visual.TextStim(win=win, ori=0, name='instructions2', text='Now, you will meet each character.', font='Arial', pos=[0, 0], height=0.1, wrapWidth=None, color='white', colorSpace='rgb', opacity=1, depth=0.0) # Initialize components for Routine "char1"