# Monitor parameters MON_DISTANCE = 16 # Distance between subject's eyes and monitor MON_WIDTH = 20 # Width of your monitor in cm #MON_SIZE = (2560,1440) MON_SIZE = [2048,1536] # Pixel-dimensions of your monitor #1. creates window in which the grating will be placed (background) monitor0 = monitors.Monitor('mon0', width=MON_WIDTH, distance=MON_DISTANCE) # Create monitor object from the variables above. This is needed to control size of stimuli in degrees. monitor0.setSizePix(MON_SIZE) # create stimulus window win0 = visual.Window( monitor=monitor0, screen = 2, size=MON_SIZE, color=[0.169,0.169, 0.169], #Color of background as [r,g,b].Each take values between -1.0 and 1.0. units="deg", fullscr=True ) # create stimulus window win1 = visual.Window( #monitor= my_monitor, monitor=monitor0, screen = 1, #size= MON_SIZE, # Put the value from the display. size of the window in pixels #color=[0.10,0.10, 0.10], #Color of background as [r,g,b].Each take values between -1.0 and 1.0. units="deg", fullscr=False )
else: sys.exit() run_data = { 'Participant ID': subj_id, 'Date': str(datetime.datetime.now()), 'Description': 'I/START Pilot - UGDG Task', 'Participant Gender': subj_gen, 'Participant Ethnicity': subj_eth, 'Participant Age': subj_age } #window setup win = visual.Window([1920, 1200], monitor="testMonitor", units="deg", fullscr=useFullScreen, allowGUI=False, screen=useDualScreen) #checkpoint print("got to check 1") #define fixation fixation = visual.TextStim(win, text="+", height=2) #waiting for trigger ready_screen = visual.TextStim( win, text="Please press button 2 to begin the practice trials.", height=1.5)
from psychopy import visual, core import time win = visual.Window() cumulativeTimer = core.Clock() width, height = [1, 0.15] refresh_rate = 0.05 length = 5 # seconds time_bar_frame = visual.Rect(win=win, pos=(0, 0), size=(width, height), lineColor='White') time_bar = visual.Rect(win=win, pos=(0, 0), size=(0, height), fillColor='White') cumulativeTimer.reset() while True: time_bar.width = cumulativeTimer.getTime() / length time_bar.pos[0] = time_bar_frame.pos[ 0] - time_bar_frame.width / 2 + time_bar.width / 2 time_bar_frame.draw() time_bar.draw() win.flip() time.sleep(refresh_rate)
try: badKeySound = sound.Sound('A', octave=5, sampleRate=22050, secs=0.03, bits=8) except: badKeySound = None print 'Could not create an invalid key sound for typing feedback' return clickSound, badKeySound if __name__ == '__main__': # Running this file directly, must want to test functions in this file from psychopy import monitors, visual, event, data, logging, core, sound, gui window = visual.Window() msg = visual.TextStim(window, text='press a key\n<esc> to quit') msg.draw() window.flip() autoLogging = False autopilot = False # create click sound for keyboard clickSound, badKeySound = setupSoundsForResponse() respPromptStim = visual.TextStim(window, pos=(0, -.7), colorSpace='rgb', color=(1, 1, 1), alignHoriz='center', alignVert='center', height=.1,
# save a log file for detail verbose info logFile = logging.LogFile(filename + '.log', level=logging.EXP) logging.console.setLevel( logging.WARNING) # this outputs to the screen, not a file endExpNow = False # flag for 'escape' or other condition => quit the exp # Start Code - component code to be run before the window creation # Setup the Window win = visual.Window(size=(1280, 800), fullscr=True, screen=0, allowGUI=False, allowStencil=False, monitor='testMonitor', color=[0, 0, 0], colorSpace='rgb', blendMode='avg', useFBO=True, units='deg') # 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 "BlankWait" BlankWaitClock = core.Clock() BlankPic = visual.ImageStim(win=win,
monitor_height = 1200 monitor_frame_rate = 60 # crucial! # Stimulus parameters (time) looming_time = 5 # time for looming, (one-way, in seconds) Nframes = monitor_frame_rate*looming_time # Stimulus parameters (initial and final radii) initial_radius = 50 final_radius = 500 # This enables the use of the keyboard during the stimuli presentation keys = event.BuilderKeyResponse() # This creates the windows where you draw your stimuli window_1 = visual.Window(size=(monitor_width, monitor_height), fullscr=True, screen=0, allowGUI=False, units='pix', monitor='testMonitor', colorSpace='rgb255', color=[0,0,0]) # This creates a shape with specific features (color, dimensions, ...) ball = visual.Circle(win=window_1, name='ball', units='pix', radius=50, edges=100, ori=0, pos=(0,0), lineWidth=1, lineColor='blue', lineColorSpace='rgb255', fillColor='red', fillColorSpace='rgb255', opacity=1,interpolate=True, autoDraw = True) # Compute the radii radius_new = np.linspace(initial_radius, final_radius, Nframes) # This loops over the frames (and this is the reason why using the true frame rate is crucial) and draws the shape with the correct radius while True: # use this to go on forever and be doomed for eternity #for aa in range(N_repetitions) # use this and substitute N_repetitions with the desired number
#!/usr/bin/env python2 from psychopy import core, visual, event #create a window to draw in myWin = visual.Window([400, 400.0], allowGUI=False) #INITIALISE SOME STIMULI gabor = visual.GratingStim(myWin, tex="sin", mask="gauss", texRes=256, size=[1.0, 1.0], sf=[4, 0], ori=0, name='gabor1') gabor.autoDraw = True message = visual.TextStim(myWin, pos=(0.0, -0.9), text='Hit Q to quit') trialClock = core.Clock() #repeat drawing for each frame while trialClock.getTime() < 20: gabor.phase += 0.01 message.draw() #handle key presses each frame if event.getKeys(keyList=['escape', 'q']): myWin.close() core.quit() myWin.flip()
def openMyStimWindow(): # make it a function because have to do it several times, want to be sure is identical each time myWin = visual.Window(monitor=mon, size=(widthPix, heightPix), allowGUI=allowGUI, units=units, color=bgColor,colorSpace='rgb', fullscr=fullscr, screen=scrn, waitBlanking=waitBlank) # Holcombe lab monitor return myWin
from training_session import TrainingSession from psychopy import visual, core win = visual.Window(monitor='testMonitor', fullscr=True) sess = TrainingSession(win, iterations=2, trials_per_iteration=30) sess.run() win.close() core.quit()
from psychopy import core, visual, event from psychopy.iohub import launchHubServer WINDOW_SIZE = 1024, 768 # Start iohub process. The iohub process can be accessed using `io`. io = launchHubServer() # A `keyboard` variable is used to access the iohub Keyboard device. keyboard = io.devices.keyboard dw = WINDOW_SIZE[0] / 2 dh = WINDOW_SIZE[1] / 2 unit_type = 'pix' win = visual.Window(WINDOW_SIZE, units=unit_type, color=[128, 128, 128], colorSpace='rgb255') # constants for text element spacing: ROW_COUNT = 10 TEXT_ROW_HEIGHT = (dh * 2) / ROW_COUNT TEXT_STIM_HEIGHT = int(TEXT_ROW_HEIGHT / 2) MARGIN = 25 LABEL_COLUMN_X = -dw + MARGIN VALUE_COLUMN_X = MARGIN LABEL_WRAP_LENGTH = dw - MARGIN / 2 VALUE_WRAP_LENGTH = dw - MARGIN / 2 TEXT_ROWS_START_Y = dh - MARGIN # Create some psychoPy stim to display the keyboard events received...
# define panda DF for logging columns = [ 'ID', 'age', 'gender', 'left', 'right', 'responseL', 'responseR', 'generationL', 'generationR', 'chainL', 'chainR', 'chainPair', 'reaction_time' ] index = np.arange(0) DATA = pd.DataFrame(columns=columns, index=index) # logfile directory if not os.path.exists('logfiles'): os.makedirs('logfiles') logfile_path = 'logfiles/' # define window win = visual.Window(fullscr=True, color='White', units='height') # define stopwatch stopwatch = core.Clock() #makes mouse invisible mouse = event.Mouse() win.mouseVisible = False ##define functions ## # Fixation cross def fixation(t): fixation = visual.TextStim(win, text='+', color='black', height=0.06) fixation.draw() win.flip()
elif key in (['space']): #spacebar, continue responsegiven=True return exparams={} #global variable stimschedule=[] #global variable #check the current directory location currentlocation=Tk() currentlocation.withdraw() #use it as the assumed script location (can be changed by user later) scriptlocation=os.getcwd() #create a window to pre-check stimuli prepwin = visual.Window(fullscr=False, monitor="surface",\ units="deg", color =[1,1,1]) loadingok=False while not loadingok: try: #ask the user for parameters using dialogue box exparams["scriptfilename"]=askopenfilename(initialdir=scriptlocation,\ title="Select the script you want to run",\ filetypes=(("CSV files","*.csv"),)) if not exparams["scriptfilename"]: #cancel button was pressed; quit everything loadingok=True core.quit() else:
imageObjectLeft.draw() myWin.flip() imageObjects = [imagesLeft, imagesRight] return imageObjects if __name__ == '__main__': #Running this file directly, must want to test functions in this file from psychopy import monitors monitorname = 'testmonitor' mon = monitors.Monitor(monitorname, width=40.5, distance=57) windowUnits = 'deg' #purely to make sure lineup array still works when windowUnits are something different from norm units bgColor = [-.7, -.7, -.7] myWin = visual.Window(monitor=mon, colorSpace='rgb', fullscr=True, color=bgColor, units=windowUnits) #myWin = visual.Window(monitor=mon,size=(widthPix,heightPix),allowGUI=allowGUI,units=units,color=bgColor,colorSpace='rgb',fullscr=fullscr,screen=scrn,waitBlanking=waitBlank) #Holcombe lab monitor logging.console.setLevel(logging.WARNING) autopilot = False clickSound, badClickSound = setupSoundsForResponse() imagesOrLetters = False if imagesOrLetters: alphabet = list(string.ascii_uppercase) possibleResps = alphabet else: numImages = 26 possibleResps = getImages(numImages)
# -*- coding: utf-8 -*- from psychopy import visual, core import numpy #刺激セットの繰り返し数 M = 2 try: # 画面の準備(灰色の画面、マウスはallowGUI=Falseで表示されないようにしている) myWin = visual.Window(fullscr=True, monitor='Default', allowGUI=False, units='norm', color=(0, 0, 0)) # 色の辞書の作成 colorDic = { u'赤': { 'rgb': (1, -1, -1), 'type': '0' }, u'黄': { 'rgb': (1, 1, -1), 'type': '1' }, u'青': { 'rgb': (-1, -1, 1), 'type': '2' } } # 文字と文字の色の辞書の作成
if dlg.OK == False: core.quit() # user pressed cancel expInfo['expName'] = expName subject_id = expInfo['id'] friend = expInfo['friend'] friend = friend.upper() cb = expInfo['counterbalance'] cb = int(cb) wordlist = pd.read_csv('wordlist.csv', sep=',', header=None) words = wordlist.reindex(np.random.permutation(wordlist.index)) words = words.reset_index(drop=True) #win = visual.Window(fullscr=True) win = visual.Window((800, 600)) #def qs(win, subject_id): file_name = "q_" + str(subject_id) + ".csv" questions = pd.read_csv('self_surveys.csv') win.flip() message = visual.TextStim(win, text='Press spacebar to begin questionnaires.') message.setAutoDraw(True) win.flip() event.waitKeys() message.setText('') win.flip() ntrials = len(questions) clicks = []
thisExp = data.ExperimentHandler(name=expName, version='', extraInfo=expInfo, runtimeInfo=None, originPath=None, savePickle=True, saveWideText=True, dataFileName=filename) # Start Code - component code to be run before the window creation # Setup the Window win = visual.Window(size=screenSize, fullscr=True, screen=screenMonitor, 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,
#!/usr/bin/env python3 # # Filename: demo_callOnFlip.py # Author: Zhiguo Wang # Date: 2/7/2021 # # Description: # Check the timing accuracy of the .callonFlip() function from psychopy import visual, core win = visual.Window(size=[1200, 800], units="pix", fullscr=True) # A function to print out the current time def print_time(): current_t = core.getTime() print(f'print_time() was executed at time: {current_t:.3f}') # In a for-loop, check if print_time() is executed at the same time as # the window flip for i in range(10): win.callOnFlip(print_time) flip_t = win.flip() print(f'Actual window flipping time was: {flip_t:.3f}') core.wait(0.5) # Close the window and quit PsychoPy win.close() core.quit()
core.quit() # user pressed cancel expInfo['date'] = data.getDateStr() # add a simple timestamp expInfo['expName'] = expName expInfo['psychopyVersion'] = psychopyVersion """ 3. Setup the Window fullscr = False for testing, True for running participants """ if debug == 1: win = visual.Window( size=[1280, 720], fullscr=False, screen=0, # Change this to the appropriate display winType='pyglet', allowGUI=True, allowStencil=False, monitor='testMonitor', color=[-1.000, -1.000, -1.000], colorSpace='rgb', blendMode='avg', useFBO=True, units='height') else: win = visual.Window( size=[1920, 1080], fullscr=True, screen=-1, # Change this to the appropriate fMRI projector winType='pyglet', allowGUI=True, allowStencil=False, monitor='testMonitor',
from psychopy import visual, event mywin = visual.Window([400, 400], monitor="testMonitor", units="deg", color=[1, .58, -1]) mywin.mouseVisible = False mouse = event.Mouse(win=mywin, newPos=[0, 0], visible=False) black = [-1, -1, -1] lineWidth = 5 #pixels squareSize = 3 #edge size (deg) #create square that stays in middle square = visual.ShapeStim(win=mywin, units="deg", vertices=[[0 - squareSize, 0 - squareSize], [0 - squareSize, 0 + squareSize], [0 + squareSize, 0 + squareSize], [0 + squareSize, 0 - squareSize]], fillColor=None, lineColor=black, lineWidth=lineWidth) square.pos = (0, 0) #create square that moves in same place mid_square = visual.ShapeStim(win=mywin, units="deg", vertices=[[0 - squareSize, 0 - squareSize], [0 - squareSize, 0 + squareSize],
# save a log file for detail verbose info logFile = logging.LogFile(filename + '.log', level=logging.EXP) logging.console.setLevel( logging.WARNING) # this outputs to the screen, not a file endExpNow = False # flag for 'escape' or other condition => quit the exp # Start Code - component code to be run before the window creation # Setup the Window win = visual.Window(size=[1920, 1200], fullscr=True, screen=0, allowGUI=False, allowStencil=False, monitor='testMonitor', color='black', 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 # Initialize components for Routine "instructions" instructionsClock = core.Clock() text = visual.TextStim(
IN_SCANNER = False TR = 2 # seconds MIN_LOG_LEVEL = 'INFO' QUIT_BUTTON = 'q' if __name__ == '__main__': # Query participant details gui = tS.ParticipantGUI() participant = gui.participant # Create the window we'll display the experiment in win = visual.Window(size=[1000, 1000], units="pix", fullscr=False, color=[0, 0, 0], winType='pyglet', gammaErrorPolicy="warn") text = visual.TextStim(text="Scanner synch... preparing", win=win, font='monospace', color=[1, 1, 1]) text.draw() text.win.flip() # Create interface for scanner pulse and response box SSO = scannersynch.scanner_synch(config=Config.SYNCH_CONFIG.value, emul_synch=not Config.IN_SCANNER.value, emul_buttons=not Config.IN_SCANNER.value) SSO.set_synch_readout_time(0.5)
#save a log file for detail verbose info logFile = logging.LogFile(filename + '.log', level=logging.EXP) logging.console.setLevel( logging.WARNING) # this outputs to the screen, not a file endExpNow = False # flag for 'escape' or other condition => quit the exp # Start Code - component code to be run before the window creation # Setup the Window win = visual.Window(size=[800, 600], fullscr=False, screen=0, allowGUI=True, allowStencil=False, monitor=u'testMonitor', color=[-1, -1, -1], colorSpace=u'rgb', blendMode=u'add', useFBO=True, units=u'use preferences') # 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() ISI = core.StaticPeriod(win=win, screenHz=expInfo['frameRate'], name='ISI')
##### INITIALIZE THE EXPERIMENT ############################################### # Calculate current list based on subject number. current_list = current_subject_number % number_lists + \ ((not current_subject_number % number_lists) * number_lists) # Get experimental items and randomize. experimental_items = latin_square(current_list, item_file) with open(practice_file) as csvFile: practiceFile = csv.reader(csvFile) practiceList = [item for item in practiceFile] # Set up stimulus window. stim_window = visual.Window(fullscr=True) # Feedback screen. timeout_feedback = visual.TextStim(stim_window, text=timeout_text, pos=(0.0, 0.0), bold=True, height=.15, color=[1, -1, -1]) # Break screen. breakText = visual.TextStim( stim_window, text="Please take a short break. Press any key to continue", pos=(0.0, 0.0), height=.075)
outlet = [] elif EEGdevice == 8: print('Enobio selected') # Make sure names are set in NIC2 settings # Outlet for Lab Streaming Layer: LSLoutlet # Markers Lab Streaming Layer 1: LSLmarkers1 info = StreamInfo('LSLmarkers1', 'Markers', 1, 0, 'int32', 'LSLoutlet') outlet = StreamOutlet(info) else: raise ValueError('Invalid EEG device number') # Ensure EEG is connected [clock, initial_timestamp] = connectEEG(EEGdevice, outlet) # Create the window to display win = visual.Window(color=[-1, -1, -1], fullscr=True) # Initialize message here message = visual.TextStim( win, text='Watch the box move and imagine you are moving it') message.setAutoDraw(True) # automatically draw every frame win.flip() core.wait(4) message.setText( 'If it moves left, imagine you are moving it with your left hand') win.flip() core.wait(4) message.setText( 'If it moves right, imagine you are moving it with your right hand') win.flip() core.wait(3)
from psychopy import core, visual, sound, event import os import random import sys import decimal import numpy as np from numpy import cumsum SCRIPT_DIR=os.environ.get('SCRIPT_DIR') sys.path.append(SCRIPT_DIR) ##################### # Experiment Settings ##################### window=visual.Window(units= "pix", size =(1280,640), rgb = "black", fullscr = False,) timer = core.Clock() seed = random.randrange(1e6) rng = random.Random(seed) __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__))) ####################### # Trial Global Settings c0 = visual.ImageStim(window, image=os.path.join(__location__, 'set1-1.png'), pos=[-500,0], opacity=0.0) c0.autoDraw=True c1 = visual.ImageStim(window,
def present( save_fn: str, duration=120, eeg=None, iti=0.5, soa=3.0, jitter=0.2, n_trials=150, cf1=1000, amf1=40, ): # Create markers stream outlet info = StreamInfo("Markers", "Markers", 1, 0, "int32", "myuidw43536") outlet = StreamOutlet(info) markernames = [1] start = time() # Set up trial parameters record_duration = np.float32(duration) # Set up trial list stim_freq = np.zeros((n_trials,), dtype=int) trials = DataFrame(dict(stim_freq=stim_freq, timestamp=np.zeros(n_trials))) # Setup graphics mywin = visual.Window( [1920, 1080], monitor="testMonitor", units="deg", fullscr=True ) fixation = visual.GratingStim(win=mywin, size=0.2, pos=[0, 0], sf=0, rgb=[1, 0, 0]) fixation.setAutoDraw(True) def generate_am_waveform( carrier_freq, am_freq, secs=1, sample_rate=44100, am_type="sine" ): """Generate an amplitude-modulated waveform. Generate a sine wave amplitude-modulated by a second sine wave or a Gaussian envelope with standard deviation = period_AM/8. Args: carrier_freq (float): carrier wave frequency, in Hz am_freq (float): amplitude modulation frequency, in Hz Keyword Args: secs (float): duration of the stimulus, in seconds sample_rate (float): sampling rate of the sound, in Hz am_type (str): amplitude-modulation type 'gaussian' -> Gaussian with std defined by `gaussian_std` 'sine' -> sine wave gaussian_std_ratio (float): only used if `am_type` is 'gaussian'. Ratio between AM period and std of the Gaussian envelope. E.g., gaussian_std = 8 means the Gaussian window has 8 standard deviations around its mean inside one AM period. Returns: (numpy.ndarray): sound samples """ t = np.arange(0, secs, 1.0 / sample_rate) if am_type == "gaussian": period = int(sample_rate / am_freq) std = period / gaussian_std_ratio norm_window = stats.norm.pdf(np.arange(period), period / 2, std) norm_window /= np.max(norm_window) n_windows = int(np.ceil(secs * am_freq)) am = np.tile(norm_window, n_windows) am = am[: len(t)] elif am_type == "sine": am = np.sin(2 * np.pi * am_freq * t) carrier = 0.5 * np.sin(2 * np.pi * carrier_freq * t) + 0.5 am_out = carrier * am return am_out # Generate stimuli am1 = generate_am_waveform(cf1, amf1, secs=soa, sample_rate=44100) aud1 = sound.Sound(am1) aud1.setVolume(0.8) auds = [aud1] mywin.flip() # start the EEG stream= if eeg: eeg.start(save_fn, duration=record_duration) for ii, trial in trials.iterrows(): # Intertrial interval core.wait(iti + np.random.rand() * jitter) # Select stimulus frequency ind = trials["stim_freq"].iloc[ii] auds[ind].stop() auds[ind].play() # Push sample if eeg: timestamp = time() if eeg.backend == "muselsl": marker = [markernames[ind]] marker = list(map(int, marker)) else: marker = markernames[ind] eeg.push_sample(marker=marker, timestamp=timestamp) # offset core.wait(soa) mywin.flip() if len(event.getKeys()) > 0: break if (time() - start) > record_duration: break event.clearEvents() # Cleanup if eeg: eeg.stop() mywin.close()
logging.WARNING) # this outputs to the screen, not a file endExpNow = False # flag for 'escape' or other condition => quit the exp # Start Code - component code to be run before the window creation # connect to ioLabs bbox, turn lights off from psychopy.hardware import iolab iolab.ButtonBox().standby() # Setup the Window win = visual.Window(size=(1024, 768), fullscr=True, screen=0, winType='pyglet', allowGUI=False, 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() bbox = iolab.ButtonBox()
# import psychopy modules from psychopy import visual, core, event, sound, gui, data, logging # import math (for rounding function) import math #set parent directory parent_dir = "./" # info about the screen win = visual.Window(size=[1920, 1080], color="white", fullscr=False, units="pix") # Set up text displays ScannerWait_txt = visual.TextStim(win, text="Waiting for scanner....", pos=[0, 0], color="black", height=50, font="Arial") Rhand_txt = visual.TextStim(win, text="Curl your right hand.", pos=[0, 0], color="black", height=50, font="Arial") Lhand_txt = visual.TextStim(win, text="Curl your left hand.",
subID = subgui.data[0] subAge = subgui.data[1] subGender = subgui.data[2] subHand = subgui.data[3] if subgui.OK == False: core.quit() # user pressed cancel outputFileName = 'subID' + '.csv' outVars = [ 'trial', 'cond', 'target_side', 'RT', 'MT', 'landing_position', 'accuracy' ] # open a white full screen window win = visual.Window(fullscr=True, allowGUI=False, color='grey', unit='height') # set up mouse mouse = event.Mouse(visible=False) # uncomment if you use a clock. Optional because we didn't cover timing this week, # but you can find examples in the tutorial code #trialClock = core.Clock() #%% your loop here # start by copying your one trial here, then identify what needs to be # changed on every trial. Likely your stimuli, but you might want to change a few things # Setting up instructions welcome_text = visual.TextStim( win=win,
logFile = logging.LogFile(filename + '.log', level=logging.EXP) logging.console.setLevel( logging.WARNING) # this outputs to the screen, not a file endExpNow = False # flag for 'escape' or other condition => quit the exp frameTolerance = 0.001 # how close to onset before 'same' frame # Start Code - component code to be run before the window creation # Setup the Window win = visual.Window(size=[1680, 1050], fullscr=True, screen=0, winType='pyglet', allowGUI=False, allowStencil=False, monitor='testMonitor', color=[-1, -1, -1], 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 # create a default keyboard (e.g. to check for escape) defaultKeyboard = keyboard.Keyboard()