def setup_class(self): self.win = Window([128, 128], winType='pyglet', pos=[50, 50], autoLog=False) assert pygame.display.get_init() == 0
############################################################################################################################## """ ################## ################## # PRE-TEST # ################## ################## # ------------------------- # # Initial & Visual settings # # ------------------------- # feedback = True # can be set to True or False firstLetter = False # can be set to True or False disp = Window( size=DISPSIZE, units='pix', fullscr=True ) # créer une fenêtre pour montrer des choses à l'écran => unité est en Pixel #size = 24 # text size # 36 size = 36 # text size # 36 color = 'darkblue' # text color color2 = 'crimson' # text color color3 = 'green' # text color space = '\t\t\t\t' # space between the word and its translation when learning learnTime = 10 # time given to memorize one pair word loadTime = 0.01 # time for spychopy displaying X = int(DISPSIZE[0]) # axe des X pour l'écran Y = int(DISPSIZE[1]) # axe des Y pour l'écran # Linux qpos = (X * 0, Y * -0.2) # position de la question qpos2 = (X * -0.02, Y * -0.02) # position de la question
@author: Wenting Ye """ ###Constants DISPSIZE = (800, 800) colour={'black':[1,1,1],'white':[-1,-1,-1],\ 'grey':[0,0,0],'red':[1,-1,-1],'green':[-1,1,-1]} from psychopy import core from psychopy.visual import Window, TextStim, ImageStim from psychopy.event import waitKeys from psychopy.core import wait import random disp=Window(size=DISPSIZE,units='pix',color='white',\ fullscr=False) #####LOGFILE LOGFILENAME = raw_input('Participant name: ') LOGFILE = LOGFILENAME log = open(LOGFILE + '.tsv', 'w') header=['block','tarside','congr',\ 'response','correct','RT'] line = map(str, header) line = '\t'.join(line) line += '\n' log.write(line) TARSIDE = ['right', 'left'] CONGR = ['congr', 'incongr'] UPDOWN = ['H', 'L']
# instructions INSTRUCTIONS = """In this task you will see a '*' appear in a box on the left or right. You will be shown a cue prior. Your task is to respond as quickly as possible when you see the '*' appear. Press key 'N' for left and press 'M' for right. Press any key to continue.""" # box size BOXSIZE = 200 # define the boxes' centre coordinates BOX_LEFT = (DISPLAY_SIZE[0] * -0.25, 0) BOX_RIGHT = (DISPLAY_SIZE[0] * 0.25, 0) # define the window win = Window(size=DISPLAY_SIZE, monitor=MONITOR_NAME, units='pix', color=BACKGROUND, fullscr=False) # draw instructions instructionsStim = TextStim(win, text=INSTRUCTIONS, font="Arial", pos=(0.0, 0.0), color=FOREGROUND, height=24) # creating a fixation cross fixStim = ShapeStim(win, vertices=((0, -10), (0, 10), (0, 0), (-10, 0), (10, 0)), lineWidth=3,
def setup_class(self): self.win = Window([128, 128], pos=[50, 50], allowGUI=False, autoLog=False)
from psychopy.visual import Window, TextStim, Circle, ImageStim, Rect, ShapeStim from psychopy.core import wait, Clock from psychopy.event import getKeys, clearEvents, waitKeys, Mouse from numpy.random import shuffle import numpy as np import random #these are all just building blocks for now, not functioning code! it won't run yet #create window DISPSIZE = (1000, 700) BGC = 'white' FGC = (-1,-1,-1) #defining colour of text shown => black win = Window(size=DISPSIZE, units='pix', color = BGC, fullscr=False) #create objects and stimuli background_image = ImageStim(win, 'prisonwall.png', autoDraw=True) #maybe for works for using a background image? welcome_str = f'Imagine you are one of two people being questioned about the same crime.\n'\ 'They are each talking to the interrogator separately. The interrogator gives each'\ 'person the same deal: \n'\ 'they can choose to vouch for the other person’s innocence (COOPERATING) or rat them out (DEFECTING).\n '\ 'And of course, there’s a twist. If both people vouch for each other, they’ll each get 3 months '\ 'off their sentence, but if the first person vouches for the second person, and the second '\ 'person rats them out, the first person will get no time off their sentence\n'\ 'and the second person will get 5 months off their time. Lastly, if they both '\ 'rat each other out, they each get 1 month off their time.\n'\ 'You can exit early by pressing Q\nPress space to start'
from psychopy.visual import Window win = Window() win.flip()
def setup_class(self): self.win = Window([128, 128], winType='pyglet', pos=[50, 50], autoLog=False)
def convertRGB(RGB): """function to convert RGB guns from 255-range values to normalised values for PsychoPy""" normalised_color = [] for gun in RGB: normV = ((1 / 127.5) * gun) - 1 normalised_color.append(normV) return normalised_color # ===== Display window ===== disp = Window(size=win_dimension, pos=(0, 0), color=background_color, colorSpace="rgb255", fullscr=False, units="pix") # - Fixation cross in the center of display fixation_cross = ShapeStim(disp, lineWidth=7000, lineColor=convertRGB(BLACK), fillColor=convertRGB(BLACK), vertices='cross') class Box: """class to draw boxes, neutrally or to flash as cues""" def __init__(self): self.normal_color = convertRGB(BLACK)
#Version 1.1 #Goal: Create masking experiment to distill necessary elements from #Goal for Version 1.2: Bug fixing / have it running #Import modules from psychopy.visual import Window, ImageStim, TextStim from psychopy.core import wait from psychopy.event import getKeys, clearEvents, waitKeys #key inputs from random import shuffle '''Constants''' #variables that the end user does not interact with DISPSIZE = (1280, 720) grey= (0, 0, 0) #define color pigment values for grey win = Window(size = DISPSIZE, units = 'pix', fullscr = False, color = grey) #create window object example_mask = ImageStim(win, 'round_mask.png') #initialize default/example pictures for mask example_blank = ImageStim(win, 'blank.png') #blank screen example_target = ImageStim(win, 'target.png') #target stimulus example_foil = ImageStim(win, 'foil.png') #and foil stimulus log = open('exam_log.txt', 'w') #initialize the data log welcome_txt = TextStim(win, text="", pos = (200, -250), height = 60) #initializing the welcome text placeholder detec_instructions = TextStim(win, text="", pos = (200, -250), height = 60) #initialize placeholder for instruction text of the detection task local_instructions = TextStim(win, text="", pos = (200, -250), height = 60) # ...of the localization task disc_instructions = TextStim(win, text="", pos = (200, -250), height = 60) # ...of the discrimination task fix = TextStim(win, text = "+", pos = (0, 0), height = 60) #fixation cross center = (0, 0) #coordinates for the picture locations left = (-250, 0) right = (250, 0) N_types = [] #to-be appended list of trial types (different numbers indicating different types of trials)
directory = os.path.join(os.getcwd(), 'data') if not os.path.exists(directory): os.makedirs(directory) #create file name for storing data fileName = os.path.join( 'data', '%s_%s_%s' % (expName, expInfo['participant'], expInfo['date'])) #save a log file logFile = logging.LogFile(fileName + '.log', level=logging.DEBUG) logging.console.setLevel( logging.WARNING) # this outputs to the screen, not a file #create a window mywin = Window(screen_size, units='pix', color=background_color, fullscr=full_screen) #create some stimuli safe_gamble = TextStim(win=mywin, color=text_color, pos=(-options_x_offset, 0), height=text_height) risky_gamble = TextStim(win=mywin, text="10% chance of CHF 3000", color=text_color, pos=(options_x_offset, 0), height=text_height) n_trials = 50 # max number of trials... value_current = 1500
def setup_class(self): self.win = Window(monitor='LightCrafter4500', screen=2, fullscr=True, color='gray', useFBO = True) self.win.setRecordFrameIntervals() self.packer = ProjectorFramePacker (self.win)
def setup_class(self): self.win = Window(monitor='testMonitor', screen=1, fullscr=True, color='gray', useFBO = True, autoLog=False) self.warper = Warper (self.win, warp='spherical', warpfile = "", warpGridsize = 128, eyepoint = [0.5, 0.5], flipHorizontal = False, flipVertical = False) self.warper.dist_cm=15 self.g = ProjectionsLinesAndCircles(self.win, self.warper)
def setup_class(self): self.win = Window([128,128], pos=[50,50], allowGUI=False, autoLog=False) self.winpix = Window([128,128], pos=[50,50], allowGUI=False, units='pix', autoLog=False) self.r = RatingScale(self.win, autoLog=False)
def setup_class(self): self.win = Window([128, 256]) self.winpix = Window([128, 256], units='pix', autoLog=False)
def setup_class(self): self.win = Window([128, 128], pos=[50, 50], allowGUI=False, autoLog=False) self.error = _BaseErrorHandler()
## pandas version 0.22.0 import pandas as pd import os ## python-pygaze 0.6.0a25 from pygaze.sound import Sound ## calling directory; Change before running!!!! os.chdir('D:/Muy importante/resmas/ProgrammingTNS') ## participant number pp = 'test' ## Some initial settings DISPSIZE = [1536, 864] BGC = (-1, -1, -1) FGC = (1, 1, 1) ## creating a background win = Window(size=DISPSIZE, color=BGC, units='pix', fullscr=True) ## welcome text welcome = TextStim( win, text= "Hi There,\nwelcome to this wonderful experiment. In the upcoming trials you will hear a lot of beeps. In every trial you will hear an initial beep, shortly followed by a second beep. It is your task to identify whether the second beep is the same sound as the first. When you think that they are the same you press the z button, if you think they are different, you press /.", height=30, color=FGC, wrapWidth=1000) ## after stimulus text stim = TextStim( win, text= "Did you hear any difference? \nPress slash if you did or z if you didn't.", height=30,
# test for two monitors: import time from psychopy.visual import Window from psychopy.visual import TextStim from psychopy import event def waitmouse(mouse): while True: m1, m2, m3 = mouse.getPressed() if m1: return m1 # create a Window create_win = lambda s: Window(size=(1280,1024), fullscr=True, monitor="testMonitor", screen=s) win1 = create_win(0) win2 = create_win(1) mouse = event.Mouse(win=win2) # draw some text on the Window txt = list() txt.append(TextStim(win1, text="This is screen 1")) txt.append(TextStim(win2, text="This is screen 2")) while True: for t in txt: t.draw() win1.flip() win2.flip() waitmouse(mouse) pos = mouse.getPos() for t in txt:
from winsound import Beep from eyetracker import Eyetracker from psychopy.visual import Window, Rect from psychopy.event import Mouse from ctypes import * from iViewXAPI import * def trigger_signal(): Beep(750, 800) #frequency, HZ, duration, ms print 'SIGNAL WAS TRIGGERED' disp = Window(size=DISPSIZE, units='pix', color=(-1, -1, -1), fullscr=True, screen=0) mouse = Mouse() stim = Rect(disp, pos=RECPOS, width=RECSIZE[0], height=RECSIZE[1], lineColor=(0, 0, 0), fillColor=(0, 0, 0), lineWidth=3) def main(): tracker = Eyetracker(debug=True)
pass person.id = demographics[0] person.first = demographics[1].upper() person.last = demographics[2].upper() person.country = demographics[3].upper() person.adress = demographics[4].upper() person.birth = demographics[5].upper() person.animal = demographics[6].upper() person.age = demographics[7] expVersion = int(demographics[8]) #setup Window win = Window(windowSize, fullscr=fullScr, waitBlanking=True, color='grey') #-------------------------------- FRAMERATE CHECK ---------------------------------------- if win.getActualFrameRate() > 62: print( 'Warning!!! Actual FrameRate is above 60Hz, display times may be inaccurate!!!' ) print('Actual Framerate is: ', win.getActualFrameRate()) print( 'If you want to proceed anyway, delete or comment the corresponding lines of code' ) quit() #delete this line if you want to proceed anyway #----------------------------------------------------------------------------------------- fixationCross = TextStim(win, text='+', units='norm', height=fixationHeight)
def setup_class(self): self.win = Window([128,128], pos=[50,50], allowGUI=False, autoLog=False) self.error = _BaseErrorHandler() self.textbox = TextBox2(self.win, "", "Noto Sans", pos=(0, 0), size=(1, 1), units='height', letterHeight=0.1, colorSpace="rgb")