def start_trial(width, sideBools): """ Initiates a new trial, draws stimuli :param width: width of stimuli """ screen.refresh() global stims coords = [(0, 0), (0, 0), (PgTools.SCREEN_SIZE[0] - width, 0), (0, PgTools.SCREEN_SIZE[1] - width)] sizes = [(PgTools.SCREEN_SIZE[0], width), (width, PgTools.SCREEN_SIZE[1]), (width, PgTools.SCREEN_SIZE[1]), (PgTools.SCREEN_SIZE[0], width)] for i in range(4): if not sideBools[i]: stims[i] = False continue stims[i] = pg.draw.rect( screen.fg, PgTools.GREEN, ( coords[i], sizes[i], ), ) PgTools.set_cursor(screen, mid=True)
def start_trial(length, height, cols): """ Initiates a new trial, draws stimuli :param length: length of stimuli :param height: height of stimuli :param cols: (color1, color2) of stimuli """ screen.refresh() while True: posX = PgTools.rand_x_coord(length) posY = PgTools.rand_y_coord(height) negX = PgTools.rand_x_coord(length) negY = PgTools.rand_y_coord(height) global posStim global negStim posStim = pg.draw.rect( screen.fg, cols[0], ( posX, posY, length, height, ), ) negStim = pg.draw.rect( screen.fg, cols[1], ( negX, negY, length, height, ), ) if posStim.colliderect(negStim): screen.refresh() continue else: if randShapes: PgTools.rand_shape(screen.fg, (posX, posY,),(length, height), posSeed) PgTools.rand_shape(screen.fg, (negX, negY,),(length, height), negSeed) break PgTools.set_cursor(screen, mid=True)
def trial_P1(length, height): """ Initiates part 1 of a new trial, draws stimuli :param length: length of stimuli :param height: height of stimuli """ screen.refresh() global stimList global trialStart global SCSLength global SCSHeight trialStart = True currentLength = int(maxLength / 4) currentHeight = int(maxHeight / 4) for i in range(stimAmt): stimList.append( pg.draw.rect( screen.fg, color, ( currentLength, currentHeight, length, height, ), )) if randShapes: PgTools.rand_shape(screen.fg, (currentLength, currentHeight), (length, height), seed) if i == SCSLocation: SCSLength = currentLength SCSHeight = currentHeight 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)
def start_trial(length, height): """ Initiates a new trial, draws stimulus :param length: length of new stimulus :param height: width of new stimulus """ screen.refresh() global stimulus xCoord = PgTools.rand_x_coord(stimLength) yCoord = PgTools.rand_y_coord(stimHeight) stimulus = pg.draw.rect( screen.fg, PgTools.GREEN, (xCoord, yCoord, length, height), ) if randShapes: PgTools.rand_shape(screen.fg, (xCoord, yCoord), (length, height), randInt) PgTools.set_cursor(screen, noPos=True)
def trial_P2(): """ Initiates part 2 of a trial, redraws stimuli """ screen.bg.fill(PgTools.BLACK) screen.refresh() global stimList global trialStart global SCSLength global SCSHeight trialStart = True currentLength = int(maxLength / 4) currentHeight = int(maxHeight / 4) for i in range(stimAmt): stimList.append( pg.draw.rect( screen.fg, color, ( currentLength, currentHeight, stimLength, stimHeight, ), )) if randShapes: PgTools.rand_shape(screen.fg, (currentLength, currentHeight), (stimLength, stimHeight), seed) if i == SCSLocation: SCSLength = currentLength SCSHeight = currentHeight currentLength += maxLength / 4 if (i + 1) % 3 == 0: currentLength = maxLength / 4 currentLength = int(currentLength) currentHeight += maxHeight / 4 currentHeight = int(currentHeight) PgTools.set_cursor(screen, randCorner=True)
def trial_P1(length, height): """ Initiates part 1 of a new trial, draws sample stimulus :param length: length of stimuli :param height: height of stimuli """ screen.refresh() global trialStart global sampleStim trialStart = True sampleStim = pg.draw.rect( screen.fg, posColor, ( int((PgTools.SCREEN_SIZE[0] - length) / 2), int((PgTools.SCREEN_SIZE[1] - height) / 5), length, height, ), ) PgTools.rand_pattern( screen.fg, ( int((PgTools.SCREEN_SIZE[0] - length) * 0.5), int((PgTools.SCREEN_SIZE[1] - height) * 0.2), ), (length, height), patColor, randNums, ) if randShapes: PgTools.rand_shape(screen.fg, ((PgTools.SCREEN_SIZE[0] - length) / 2, (PgTools.SCREEN_SIZE[1] - height) / 5), (stimLength, stimHeight), seed) PgTools.set_cursor(screen, mid=True)
def start_trial(length, height): """ Initiates a new trial, draws stimulus :param length: length of new stimulus :param height: width of new stimulus """ screen.refresh() global stimulus x_mid = int((PgTools.SCREEN_SIZE[0] - length) / 2) y_mid = int((PgTools.SCREEN_SIZE[1] - height) / 2) stimulus = pg.draw.rect( screen.fg, PgTools.GREEN, ( (x_mid, y_mid), (length, height), ), ) if randShapes: PgTools.rand_shape(screen.fg, (x_mid, y_mid), (length, height)) PgTools.set_cursor(screen, randCorner=True)
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)
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.bg.fill(PgTools.BLACK) 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) PgTools.set_cursor(screen, mid=True)