def __init__(self, tracker, win, settings): """ Initializes PsychopyCustomDisplay object. """ super().__init__() self.tracker = tracker self.win = win self.settings = settings # from session self.txtcol = -1 #self.__target_beep__ = sound.Sound(800, secs=.1) # THIS WILL GIVE A SEGFAULT! #self.__target_beep__done__ = sound.Sound(1200, secs=.1) # THIS WILL GIVE A SEGFAULT! #self.__target_beep__error__ = sound.Sound(400, secs=.1) # THIS WILL GIVE A SEGFAULT! self.backcolor = self.win.color dot_size_pix = misc.deg2pix( self.settings['eyetracker'].get('dot_size'), self.win.monitor) self.targetout = Circle(self.win, pos=(0, 0), radius=dot_size_pix, fillColor='black', units='pix', lineColor='black') self.targetin = Circle(self.win, pos=(0, 0), radius=3, fillColor=0, lineColor=0, units='pix', opacity=0) win.flip()
def draw_circle(self, colour=None, pos=None, r=50, pw=1, fill=False): """Draws a circle on the screen arguments None keyword arguments colour -- colour for the circle (a colour name (e.g. 'red') or a RGB(A) tuple (e.g. (255,0,0) or (255,0,0,255))) or None for the default foreground colour, self.fgc (default = None) pos -- circle center, an (x,y) position tuple or None for a central position (default = None) r -- circle radius (default = 50) pw -- penwidth: circle line thickness (default = 1) fill -- Boolean indicating whether circle should be filled or not (default = False) returns Nothing -- draws a circle on (PyGame) or adds a Circle stimulus to (PsychoPy) the self.screen property """ if colour == None: colour = self.fgc if pos == None: pos = (self.dispsize[0] / 2, self.dispsize[1] / 2) colour = rgb2psychorgb(colour) pos = pos2psychopos(pos, dispsize=self.dispsize) if fill: self.screen.append( Circle(pygaze.expdisplay, radius=r, edges=32, pos=pos, lineWidth=pw, lineColor=colour, lineColorSpace='rgb', fillColor=colour, fillColorSpace='rgb')) else: self.screen.append( Circle(pygaze.expdisplay, radius=r - pw, edges=32, pos=pos, lineWidth=pw, lineColor=colour, lineColorSpace='rgb'))
def ImageDiagnostic(self): """Draws colored dots onto the window. The dots' positions represent the respective location of where images will be placed throughout the course of the task. This function is to only be used as a diagnostic tool, so that one can get a general sense of where images might appear, without having to actually run through the task. To use this function properly: taskSpatial = mdts.MDTS(...) taskSpatial.ImageDiagnostic #taskSpatial.RunExp() """ win = self.window cRad = 50 tp = self.trialsPer ls = self.imageList shapes = [] leng = len(ls) for i in range(0, leng): color = "black" #print "{:<24}{:<15}{:<15}".format(img[0],img[1],img[2]) img = ls[i] if i < tp: color = "black" elif (i > tp) and (i < tp * 2): color = "blue" elif (i > tp * 2) and (i < tp * 3): color = "orange" elif i > tp * 3: color = "green" shapes.append(Circle(win, radius=cRad, pos=img[1], fillColor=color)) shapes.append(Circle(win, radius=cRad, pos=img[2], fillColor=color)) shapes.append( ShapeStim(win, units='pix', lineWidth=5, lineColor=color, vertices=(img[1], img[2]))) for shape in shapes: shape.draw(self.window) self.window.flip() waitKeys(keyList=['escape']) self.window.close()
def __init__(self, settings_file=None, eyetracker_on=False): """ Initializes base Session class. parameters ---------- settings_file : str Path to settings file. If None, default_settings.yml is used eyetracker_on : bool Whether to enable eyetracker """ self.settings_file = settings_file self.eyetracker_on=eyetracker_on self.clock = Clock() self.timer = Clock() self.start_exp = None self.current_trial = None self.log = [] self.logfile = logging.LogFile(f='log.txt', filemode='w', level=logging.EXP) # Initialize self.settings = self._load_settings() self.monitor = self._create_monitor() self.win = self._create_window() self.mouse = Mouse(**self.settings['mouse']) self.default_fix = Circle(self.win, radius=0.3, fillColor='white', edges=1000) self.mri_simulator = self._setup_mri_simulator() if self.settings['mri']['simulate'] else None self.tracker = None
def __init__(self, win, warper): self.win = win self.warper = warper self.stimT = TextStim(self.win, text='Null warper', units = 'pix', pos=(0, -140), alignHoriz='center', height=20) self.bl = -win.size / 2.0 self.tl = (self.bl[0], -self.bl[1]) self.tr = win.size / 2.0 self.stims = [] self.degrees = 120 nLines = 12 for x in range(-nLines, nLines+1): t = GratingStim(win,tex=None,units='deg',size=[2,win.size[1]],texRes=128,color=foregroundColor, pos=[float(x) / nLines * self.degrees,0]) self.stims.append (t) for y in range (-nLines, nLines+1): t = GratingStim(win,tex=None,units='deg',size=[win.size[0],2],texRes=128,color=foregroundColor,pos=[0,float(y)/nLines * self.degrees]) self.stims.append (t) for c in range (1, nLines+1): t = Circle (win, radius=c * 10, edges=128, units='deg', lineWidth=4) self.stims.append (t) self.updateInfo() self.keys = key.KeyStateHandler() win.winHandle.push_handlers(self.keys) self.mouse = event.Mouse(win=self.win)
def create_circle_fixation(win, radius=0.1, color=(1, 1, 1), edges=100, **kwargs): """ Creates a circle fixation dot with sensible defaults. """ return Circle(win, radius=radius, color=color, edges=edges, **kwargs)
def draw_ellipse(self, colour=None, x=None, y=None, w=50, h=50, pw=1, fill=False): """Draws an ellipse on the screen arguments None keyword arguments colour -- colour for the circle (a colour name (e.g. 'red') or a RGB(A) tuple (e.g. (255,0,0) or (255,0,0,255))) or None for the default foreground colour, self.fgc (default = None) x -- x coordinate of the rectangle in which the ellipse is drawn or None for a horizontal centrally drawn ellipse (default = None) y -- y coordinate of the rectangle in which the ellipse is drawn or None for a vertical centrally drawn ellipse (default = None) w -- width of the rectangle in which the ellipse is drawn (default = 50) h -- height of the rectangle in which the ellipse is drawn (default = 50) pw -- penwidth: circle line thickness (default = 1) fill -- Boolean indicating whether ellipse should be filled or not (default = False) returns Nothing -- draws an ellipse on (PyGame) or adds a GratinsStim stimulus to (PsychoPy) the self.screen property """ if colour == None: colour = self.fgc if x == None: x = 0 if y == None: y = 0 pos = x,y colour = rgb2psychorgb(colour) pos = pos2psychopos(pos,dispsize=self.dispsize) pos = pos[0] + w/2, pos[1] - h/2 if fill: self.screen.append(Circle(pygaze.expdisplay, lineWidth=pw, lineColor=colour, lineColorSpace='rgb', fillColor=colour, fillColorSpace='rgb', pos=pos, size=(w,h))) else: self.screen.append(Circle(pygaze.expdisplay, lineWidth=pw, lineColor=colour, lineColorSpace='rgb', fillColor=None, pos=pos, size=(w,h)))
def draw(self, location): y = 0 if location == "left": x = int(win_width * -0.25) left_targ = Circle(disp, pos=(x, y), radius=self.radius, edges=32, lineColor=self.color, fillColor=self.color) left_targ.draw() if location == "right": x = int(win_width * 0.25) right_targ = Circle(disp, pos=(x, y), radius=self.radius, edges=32, lineColor=self.color, fillColor=self.color) right_targ.draw()
def main(): groups = create_stim_sequence(BLOCK1, BLOCK2, BLOCK3, TRIALREPEATS) print groups disp = Window(size=SIZE, monitor=MON, units='deg', color=BACKCOL, screen=1, fullscr=True) mouse = Mouse() fixmark = Circle(disp, radius=0.05, edges=32, pos=CENTER, lineColor=FIXCOL) images = [] for item in CIRCLES.keys(): image = ImageStim(disp, image=CIRCLES[item][1], pos=CIRCLES[item][0], size=CIRCLES[item][3]) images.append(image) fixmark.draw() draw_group(images) disp.flip() while True: button = mouse.getPressed() if button[0]: break for item in groups: flashes = [] for i in item: flash = ImageStim(disp, image=CIRCLES[i][2], pos=CIRCLES[i][0], size=CIRCLES[i][3]) flashes.append(flash) fixmark.draw() draw_group(images) draw_group(flashes) disp.flip() wait(FLASH) fixmark.draw() draw_group(images) wait(PAUSE) disp.flip() disp.close()
def check_keys(self): """Checks key input""" for keys in event.getKeys(timeStamped=True): k = keys[0] if k in ['escape', 'q']: self.win.close() sys.exit() elif k in ['space']: for c in range (1,2): t = Circle(self.win, radius=c) self.stims.append (t) #for c in range (1,2): # t = RadialStim(self.win) # self.stims.append(t) # handle projections elif k in ['s']: self.warper.changeProjection ('spherical', None, (0.5,0.5)) elif k in ['c']: self.warper.changeProjection ('cylindrical', None, (0.5,0.5)) elif k in ['n']: self.warper.changeProjection (None, None, (0.5,0.5)) elif k in ['f']: self.warper.changeProjection ('warpfile', r'..\data\sample.meshwarp.data', (0.5,0.5)) # flip horizontal and vertical elif k in ['h']: self.warper.changeProjection(self.warper.warp, self.warper.warpfile, flipHorizontal = not self.warper.flipHorizontal) elif k in ['v']: self.warper.changeProjection(self.warper.warp, self.warper.warpfile, flipVertical = not self.warper.flipVertical) # move eyepoint elif k in ['down']: if (self.warper.dist_cm > 1): self.warper.dist_cm -= 1 self.warper.changeProjection (self.warper.warp, None, self.warper.eyepoint) elif k in ['up']: if (self.warper.dist_cm < 200): self.warper.dist_cm += 1 self.warper.changeProjection (self.warper.warp, None, self.warper.eyepoint) elif k in ['right']: if (self.warper.eyepoint[0] < 0.9): self.warper.eyepoint = (self.warper.eyepoint[0] + 0.1, self.warper.eyepoint[1]) self.warper.changeProjection (self.warper.warp, None, self.warper.eyepoint) elif k in ['left']: if (self.warper.eyepoint[0] > 0.1): self.warper.eyepoint = (self.warper.eyepoint[0] - 0.1, self.warper.eyepoint[1]) self.warper.changeProjection (self.warper.warp, None, self.warper.eyepoint) self.updateInfo()
def draw_overview_target(win, level, target_pos, text_pos, mouse_clicks_all_levels): target = ImageStim(win, 'target.png', size=420, pos=target_pos) level_text = TextStim(win, text=f'Level {level}', height=35, color=(0.2, 0.2, 0.8), pos=text_pos) target.draw() level_text.draw() target_x, target_y = target_pos curr_level_mouse_clicks = mouse_clicks_all_levels[level - 1] for target_hit_pos in curr_level_mouse_clicks: if target_hit_pos['mouse_in_target']: circle = Circle(win, radius=5, fillColor='yellow', lineColor='yellow') circle.setPos((target_hit_pos['mouse_x'] + target_x, target_hit_pos['mouse_y'] + target_y)) circle.draw()
from constants import * from psychopy.visual import Window, TextStim, shape, Circle, Rect from psychopy.event import waitKeys from psychopy.core import wait disp = Window(size=DISPSIZE, units='pix', color=BGC, fullscr=True) instructions = 'Willkommen! \n\nIn diesem Experiment werden die Buchstaben E und F auf dem ' \ 'Bildschirm erscheinen. Wenn du eine E siehst, drücke das E. Wenn du ein F siehst' \ ', drücke das F \n\n Versuche so genau und schnell wie möglich zu antworten. \n\n' \ 'Viel Glück!' inststim = TextStim(disp, units='pix', text=instructions, color=FGC, height=35) fixstim = Circle(disp, radius=6, edges = 32, lineColor = FGC, fillColor = FGC) lboxstim = Rect(disp, pos=BOXCORS['left'], width=BOXSIZE, height=BOXSIZE, lineColor = FGC, lineWidth=3) rboxstim = Rect(disp, pos=BOXCORS['right'], width=BOXSIZE, height=BOXSIZE, lineColor = FGC, lineWidth=3) cuestim = {} cuestim['left'] = Rect(disp, pos=BOXCORS['left'], width=BOXSIZE, height=BOXSIZE, lineColor = FGC, lineWidth=8) cuestim['right'] = Rect(disp, pos=BOXCORS['right'], width=BOXSIZE, height=BOXSIZE, lineColor = FGC, lineWidth=8) tarscr = {} tarscr['left'] = {} tarscr['right'] = {}
#time RT=core.Clock() #sound stimuli #highSound = sound.Sound('A',octave=4,sampleRate=44100,secs=0.120,stereo=True,name = "high") highSound = sound.Sound("/Users/peerchristensen/Desktop/PsPy/high_low_short/high_a4.wav",name = "high") #lowSound = sound.Sound('A',octave=2,sampleRate=44100,secs=0.120,stereo=True,name = "low") lowSound = sound.Sound("/Users/peerchristensen/Desktop/PsPy/high_low_short/low_a1.wav",name = "low") sounds=[highSound,lowSound] * (nTrials/2) # Visual stimuli #fixation cross fixCross = visual.TextStim(win, text="+",pos=center,units="deg", color=black,height=3) #HEIGHT circleHIGH = Circle(win=win,units="deg",radius= 3, fillColor=black,lineColor=black,pos=[-0.1,8],name="high") circleLOW = Circle(win=win,units="deg",radius= 3, fillColor=black,lineColor=black,pos=[-0.1,-8],name="low") #SIZE circleBIG = Circle(win=win,units="deg",radius= 6, fillColor=black,lineColor=black,pos=center,name="big") circleSMALL = Circle(win=win,units="deg",radius= 1.5, fillColor=black,lineColor=black,pos=center,name="small") stimsSize= [circleBIG,circleSMALL] * (nTrials/2) stimsHeight=[circleHIGH,circleLOW] * (nTrials/2) #warm up circles=[circleBIG,circleSMALL,circleHIGH,circleLOW] * 2 random.shuffle(circles) voices=[highSound,lowSound] * 4 random.shuffle(voices) msg.draw() win.flip()
def __init__(self, nstim, locs, oris, linewidth=3, \ stimtypes='gabor', showcolourwheel=False): """Initialises a new StimScreen instance. Arguments nstim - Integer that determines the number of stimuli on this screen. locs - List of (x,y) tuples that determine the positions of all stimuli. The list's length should be equal to the number of stimuli as defined by nstim. oris - List of integers that determine the orientations of all stimuli. The list's length should be equal to the number of stimuli as defined by nstim. Keyword Arguments linewidth - Integer or a list of integers that determines the width of the lines around stimuli (in pixels). Default value is 3. stimtypes - String or a list of strings that determines the type of stimulus. Options are 'gabor' and 'noise'. Default is 'gabor'. showcolourwheel- Boolean that determines whether a central colour wheel should be drawn of not. Default is False. """ # Settings from the constants. self._sf = float(STIMSF) / float(STIMSIZE) self._alpha = STIMALPHA self._contrast = STIMCONTRAST # Noise texture. self._noisetex = numpy.random.rand(STIMNOISERES, STIMNOISERES) # Convert the linewidth to a list (if necessary). if type(linewidth) in [int, float]: linewidth = nstim * [int(linewidth)] # Convert the stimulus types to a list (if necessary). if type(stimtypes) in [str, unicode]: stimtypes = nstim * [stimtypes] # Create a Screen to use its wonderful drawing functions. self.scr = Screen() # Draw the fixation cross. self.scr.draw_fixation(fixtype=FIXTYPE, diameter=FIXSIZE) # Draw the colouw wheel if showcolourwheel: # Load the image. self.scr.draw_image(CWIMG, scale=CWIMGSCALE) # Create an internal list of stimuli (=PsychoPy stimulus instances) by # copying it from the internal screen. self.screen = self.scr.screen # Keep a list of the index numbers of all stimuli. The indices refer # to positions within the self.scr.screen list of PsychoPy stimuli. self._stimindexnrs = [] self._outlineindexnrs = [] # Draw the stimuli. for i in range(nstim): # Add the stimulus' index number to the list of indices. self._stimindexnrs.append(len(self.screen)) # # Create a new Rect stimulus instance. # stim = Rect(pygaze.expdisplay, \ # pos=pos2psychopos(locs[i]), \ # fillColor=rgb2psychorgb(list(oris[i])), \ # lineColor=rgb2psychorgb(list(linecols[i])), \ # lineWidth=linewidth[i], \ # width=STIMSIZE, \ # height=STIMSIZE) # Create a Gabor-ish GratingStim. if stimtypes[i] == 'gabor': tex = 'sin' else: tex = self._noisetex stim = GratingStim(pygaze.expdisplay, \ pos=pos2psychopos(locs[i]), \ ori=oris[i], \ size=STIMSIZE, \ sf=self._sf, \ opacity=self._alpha, \ contrast=self._contrast, \ tex=tex, \ mask='circle', \ color=(1,1,1) ) # Add the new stimulus to our list of stimuli. self.screen.append(stim) # Add an outline for the stimulus. self._outlineindexnrs.append(len(self.screen)) stim = Circle(pygaze.expdisplay, \ pos=pos2psychopos(locs[i]), \ lineWidth=linewidth[i], \ radius=STIMSIZE//2, \ edges=32, \ closeShape=False, \ fillColor=None, \ lineColor=(0,0,0) ) # Add the new stimulus to our list of stimuli. self.screen.append(stim)
level=logging.CRITICAL) message = 'ID\tgender\torder\texperiment\tdifficulty\tfalseAlarm\ttrial\tcondition\ttrial.start.time\tsignal\thumanResp\thumanRT\tautoResp\tautoRT\tACC\tstimlength\tRTor\tRTand\n' logClicks.write(message) pracfilename = 'Mahoney_exp_practice_' + info['ID'] + '.txt' logClicksPrac = logging.LogFile(pracfilename, filemode='a', level=logging.CRITICAL) message2 = 'ID\tage\tgender\torder\texperiment\ttrial\ttrial.start.time\tsignal\thumanResp\thumanRT\tautoResp\tautoRT\ttrialACC\tstimlength\n' logClicksPrac.write(message2) # Object Setup positions = [0, 0] startButton = Circle(win, units="deg", radius=1, lineWidth=.5, lineColor=(1, 1, 1), fillColor=(0, 0, 0)) fixCross = Circle(win, units="deg", radius=1, lineColor=(1, 1, 1), fillColor=(0, 0, 0)) background = Rect(win, units="deg", width=13, height=13, fillColor=(0, 0, 0), lineColor=(0, 0, 0)) placeholder = Circle(win, radius=0.5,
units='pix', color=(0, 0, 0)) win.update() #n trials nTrials = 8 #Visual stimuli black = [-1, -1, -1] leftPos = -300 rightPos = 300 #HEIGHT circleHIGH = Circle(win=win, units="pix", radius=100, fillColor=black, lineColor=black, pos=[0, 300], name="high") circleLOW = Circle(win=win, units="pix", radius=100, fillColor=black, lineColor=black, pos=[0, -300], name="low") #SIZE circleBIG = Circle(win=win, units="pix", radius=200, fillColor=black,
pos=(0.5, 0), labels=(sliderLeftT, sliderRightT), ticks=(sliderLeftP, sliderRightP), granularity=0, style=['slider'], color='black', font='HelveticaBold', flip=True, units="height") # notice that the "size" of the slider controls whether the slider is verticle or horizontal # change to desired style, using the in-built visual stimulus from psychopy slider.marker = Circle( win, radius=slider.size[0] * 0.5, # The radius should be half the width edges=32, fillColor='black', lineColor='gray') slider.line = Rect( win, units=slider.units, pos=slider.pos, width=slider.size[0], height=slider.size[1] + 0.005, # +0.005 just to make the rectangule looks better lineColor='black', fillColor='gray', autoLog=False) text1 = visual.TextStim(win=win,
start=(-75, 300), end=(75, 300), lineWidth=30, lineColor=black, name="high") stimLOW = Line(win, start=(-75, -300), end=(75, -300), lineWidth=30, lineColor=black, name="low") #SIZE circleBIG = Circle(win=win, units="pix", radius=200, fillColor=black, lineColor=black, pos=[0, 0], name="big") circleSMALL = Circle(win=win, units="pix", radius=50, fillColor=black, lineColor=black, pos=[0, 0], name="small") #Visual stimulus lists completeList = [[circleSMALL, circleBIG], [stimLOW, stimHIGH], [stimHIGH, circleSMALL], [stimLOW, circleBIG]] * (nTrials / 4) random.shuffle(completeList)
def RunButtonDiagnostic(self): ''' Run a test to make sure that the buttons are being recorded correctly Creates a temporary window and accepts keypresses Shows the buttonpresses with a highlighting circle ''' if (self.screenType == 'Windowed'): screenSelect = False elif (self.screenType == 'Fullscreen'): screenSelect = True window = Window(fullscr=screenSelect, units='pix', color='White', allowGUI=False) indRadius = 100 tHeight = 2 * indRadius / 5 posC1 = (-window.size[0] / 4, 0) posC2 = (window.size[0] / 4, 0) #creating circle opjects circ1 = Circle(window, indRadius, lineColor='White', lineWidth=6, pos=posC1) #training and p1 circles circ2 = Circle(window, indRadius, lineColor='White', lineWidth=6, pos=posC2) #creating text objects for cicles trtext1 = TextStim(window, " Button 1", color='White', height=tHeight, pos=posC1) #training text trtext2 = TextStim(window, " Button 2", color='White', height=tHeight, pos=posC2) #List of final circle and text objects trCircs = [circ1, circ2] trTexts = [trtext1, trtext2] trTxt = TextStim( window, "This is a test to ensure that the buttons are being recorded correctly.\n Press each button to make sure it is being recorded correctly.\n Press escape to move on", pos=(0, window.size[1] / 4), color="Black", height=40, wrapWidth=0.8 * window.size[0]) for circ in trCircs: circ.fillColor = 'Gray' trTxt.draw(window) for circ in trCircs: circ.draw(window) for text in trTexts: text.draw(window) window.flip() while 1: key = waitKeys(keyList=self.inputButtons + [self.pauseButton, 'escape'])[0] for circ in trCircs: circ.fillColor = 'Gray' if key == 'escape' or key == self.pauseButton: #print "Press ecape one more time\n" break elif key == self.inputButtons[0]: trCircs[0].fillColor = 'Green' elif key == self.inputButtons[1]: trCircs[1].fillColor = 'Green' trTxt.draw(window) for circ in trCircs: circ.draw(window) for text in trTexts: text.draw(window) window.flip() window.flip() window.close()
lineColor = cue_Flash, lineWidth = 8) cue_Stim['right'] = Rect(disp, pos = Box_Coord['right'],\ width = Box_Dimen[0], height = Box_Dimen[1],\ lineColor = cue_Flash, lineWidth = 8) #create a fixation point/cross fix_Stim = ShapeStim(disp, lineWidth = 100, lineColor = [1, 1, 1], \ fillColor = [1, 1, 1], vertices = 'cross') #create a dictionary for target display, and nested dict for different targets targ_Stim = {} targ_Stim['left'] = {} targ_Stim['right'] = {} targ_Stim['left']['P'] = Circle(disp, radius = 15, edges = 32, lineColor = FGC,\ lineWidth = 5, fillColor = FGC, pos = Box_Coord['left']) targ_Stim['right']['P'] = Circle(disp, radius = 15, edges = 32, lineColor = FGC,\ lineWidth = 5, fillColor = FGC, pos = Box_Coord['right']) targ_Stim['left']['C'] = Circle(disp, radius = 50, edges = 32, lineColor = FGC,\ lineWidth = 5, fillColor = FGC, pos = Box_Coord['left']) targ_Stim['right']['C'] = Circle(disp, radius = 50, edges = 32, lineColor = FGC,\ lineWidth = 5, fillColor = FGC, pos = Box_Coord['right']) # define the feedback screens fb_scr = {} fb_scr['Incorrect'] = TextStim(disp, text = 'Incorrect', height = 24,\ color = (1, -1, -1)) fb_scr['Correct'] = TextStim(disp, text = 'Correct!', height = 24,\ color = (-1, 1, -1)) fb_scr['NoResp'] = TextStim(disp, text = 'Please make a choice',\
def __init__(self, win, rating_question=None, labels=None, coords=None, buttons=None, label_height=45, anchor_size=15, anchor_color='lightblue', anchor_color_chosen='orange', offset_label=50, time_until_disappear=0.3, fixation=None): """ Initializes ButtonBoxRating object. """ if rating_question is None: rating_question = '' if len(labels) == 2 and coords is None: labels = [labels[0], ' ', ' ', ' ', ' ', ' ', ' ', labels[1]] offset_label = -1 * offset_label if coords is None: coords = [(-600, -300), (-450, -200), (-300, -150), (-150, -100), (150, -100), (300, -150), (450, -200), (600, -300)] if buttons is None: # ONLY TEST VERSION (MRI should be 'b', 'y', 'g' etc) buttons = [str(i + 1) for i in range(8)] self.rating_question = rating_question self.labels = labels self.coords = coords self.buttons = buttons self.actual_buttons = [ b for i, b in enumerate(buttons) if self.labels[i] ] self.label_height = label_height self.anchor_size = anchor_size self.anchor_color = anchor_color self.anchor_color_chosen = anchor_color_chosen self.offset_label = offset_label self.time_until_disappear = time_until_disappear if fixation is None: self.fixation = GratingStim(win, tex='sin', mask='raisedCos', size=10, texRes=512, color='white', sf=0, maskParams={'fringeWidth': 0.4}) self.fixation = fixation self.rating_anchors = [] self.label_texts = [] self.resp = None self.time_resp = np.inf for i in range(len(self.coords)): if not self.labels[i]: continue # remove anchor for empty label rating_anchor = Circle( win=win, pos=coords[i], radius=self.anchor_size, edges=200, units='pix', fillColor=self.anchor_color, ) #rating_anchor.setColor(self.anchor_color) label_text = TextStim(win=win, pos=(self.coords[i][0], self.coords[i][1] + self.offset_label), height=self.label_height, units='pix', text=self.labels[i]) self.rating_anchors.append(rating_anchor) self.label_texts.append(label_text) self.rating_text = TextStim(win=win, pos=(0, max([c[1] for c in self.coords]) + 200), height=self.label_height * 1.5, units='pix', text=self.rating_question, wrapWidth=max([c[0] for c in self.coords]) - min([c[0] for c in self.coords]))
def create_circle_fixation(win, radius=0.1, color=(1, 1, 1), edges=100, **kwargs): return Circle(win, radius=radius, color=color, edges=edges, **kwargs)