def trial_P2(posColor): """ Initiates part 2 of a trial, draws comparison stimuli :param colorPair: pair of random colors for stimuli base colors """ if not sampleStimVis: screen.refresh() global stimList currentLength = int(maxLength / 4) currentHeight = int(maxHeight * 0.4) for i in range(stimAmt): if i == posLocation: stimList.append( pg.draw.rect( screen.fg, posColor, ( currentLength, currentHeight, stimLength, stimHeight, ), )) PgTools.rand_pattern( screen.fg, (currentLength, currentHeight), (stimLength, stimHeight), patColor, randNums, ) if randShapes: PgTools.rand_shape(screen.fg, (currentLength, currentHeight), (stimLength, stimHeight), seed) else: stimList.append( pg.draw.rect( screen.fg, PgTools.rand_color(), ( currentLength, currentHeight, stimLength, stimHeight, ), )) PgTools.rand_pattern(screen.fg, (currentLength, currentHeight), (stimLength, stimHeight), PgTools.rand_color(), (randint(0, 2), randint(0, 2))) if randShapes: PgTools.rand_shape(screen.fg, (currentLength, currentHeight), (stimLength, stimHeight), randint(0, 99999)) currentLength += maxLength / 2 currentLength = int(currentLength) if i == 1: currentLength = int(maxLength / 4) currentHeight = int(maxHeight * 0.8)
"subject_name", "set", "trial", "total_trial", posStimName, negStimName, "input_coordinates", "accuracy", ], ) trialNum = 1 setNum = 1 passedTrials = 0 colorPair = PgTools.two_rand_color() color = PgTools.rand_color() totalTrial = 1 if randShapes: posSeed = randint(0, 99999) negSeed = randint(0, 99999) start_trial(stimLength, stimHeight, colorPair) # game loop running = True while running: for event in pg.event.get(): PgTools.quit_pg(event) if event.type == MOUSEBUTTONDOWN: xCoord, yCoord = event.pos if posStim.collidepoint(xCoord, yCoord) and screen.fg.get_at((xCoord, yCoord)) != (0,0,0):
def trial(length, height): """ Initiates a new trial, draws stimuli :param length: length of stimuli :param height: height of stimuli """ screen.refresh() global stimList global oddLength global oddHeight currentLength = int(maxLength / 4) currentHeight = int(maxHeight / 4) for i in range(stimAmt): if i == oddLocation: oddLength = currentLength oddHeight = currentHeight stimList.append( pg.draw.rect( screen.fg, PgTools.rand_color(), ( currentLength, currentHeight, length, height, ), )) PgTools.rand_pattern( screen.fg, ( currentLength, currentHeight, ), (length, height), i=(randint(0, 2), randint(0, 1)), ) if randShapes: PgTools.rand_shape(screen.fg, (currentLength, currentHeight), (length, height), oddSeed) else: stimList.append( pg.draw.rect( screen.fg, color, ( currentLength, currentHeight, length, height, ), )) PgTools.rand_pattern( screen.fg, ( currentLength, currentHeight, ), (length, height), patColor, randNums, ) if randShapes: PgTools.rand_shape(screen.fg, (currentLength, currentHeight), (length, height), regSeed) currentLength += maxLength / 4 currentLength = int(currentLength) if (i + 1) % 3 == 0: currentLength = maxLength / 4 currentLength = int(currentLength) currentHeight += maxHeight / 4 currentHeight = int(currentHeight) PgTools.set_cursor(screen, randCorner=True)
return True PgTools.write_ln( filename="Oddity_Testing/results.csv", data=[ "subject_name", "trial", "odd_stim_location", "accuracy", ], ) trialNum = 1 colorPair = PgTools.two_rand_color() patColor = PgTools.rand_color() randNums = [randint(0, 2), randint(0, 1)] color = PgTools.rand_color() patColor = PgTools.rand_color() oddLocation = randint(0, stimAmt - 1) stimList = [] maxLength = PgTools.SCREEN_SIZE[0] - stimLength maxHeight = PgTools.SCREEN_SIZE[1] - stimHeight oddLength = 0 oddHeight = 0 if randShapes: regSeed = randint(0, 99999) oddSeed = randint(0, 99999) trial(stimLength, stimHeight) on_bg = True