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)
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 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)
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 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) s = pg.Surface((length, height)) s.blit(images[random.randint(0, len(images) - 1)], (0, 0)) # s.blit(test_image, (0, 0)) # use to debug clipart screen.fg.blit(s, (xCoord, yCoord)) stimulus = pg.draw.rect(screen.fg, Color('goldenrod'), (xCoord, yCoord, length, height), 15)
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 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 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 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)
import sys import os import pygame as pg from pygame.locals import * sys.path.append( os.path.join("/home", "pi", "Desktop", "ChimpPygames", "PygameTools")) import PgTools from random import randint # initialize pygame and screen pg.init() screen = PgTools.Screen() file = open("Sides_Task/parameters.dat") params = PgTools.get_params(file) file.close() subjectName = str(params["subject_name"]) sidesNum = stimAmt = int(params["sides_num"]) consecutiveAmt = int(params["number_of_correct_in_a_row"]) stimWidth = int(params["stimulus_width"]) passDelay = int(params["passed_inter_trial_interval"]) failDelay = int(params["failed_inter_trial_interval"]) def start_trial(width, sideBools): """ Initiates a new trial, draws stimuli :param width: width of stimuli """
import sys import os import pygame as pg from pygame.locals import * sys.path.append(os.path.join("/home", "pi", "Desktop", "ChimpPygames", "PygameTools")) import PgTools from random import randint # initialize pygame and screen pg.init() screen = PgTools.Screen() file = open("Two_Choice_Discrimination/parameters.dat") params = PgTools.get_params(file) file.close() subjectName = str(params["subject_name"]) posStimName = str(params["positive_stimulus_name"]) negStimName = str(params["negative_stimulus_name"]) consecutiveAmt = int(params["number_of_correct_in_a_row"]) setsAmt = int(params["number_of_stimulus_pairs"]) + 1 stimLength = int(params["stimulus_length"]) stimHeight = int(params["stimulus_height"]) passDelay = int(params["passed_inter_trial_interval"]) failDelay = int(params["failed_inter_trial_interval"]) if "y" in str(params["randomly_shaped_stimuli"]) or "Y" in str(params["randomly_shaped_stimuli"]): randShapes = True else: randShapes = False
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)
import sys import os from random import randint import pygame as pg from pygame.locals import * sys.path.append( os.path.join("/home", "pi", "Desktop", "ChimpPygames", "PygameTools")) import PgTools # initialize pygame and screen pg.init() screen = PgTools.Screen() file = open("Oddity_Testing/parameters.dat") params = PgTools.get_params(file) file.close() subjectName = str(params["subject_name"]) sampleStimName = str(params["sample_stimulus_name"]) oddStimName = str(params["odd_stimulus_name"]) trialsAmt = int(params["number_of_trials"]) + 1 stimAmt = int(params["number_of_stimuli"]) stimLength = int(params["stimulus_length"]) stimHeight = int(params["stimulus_height"]) passDelay = int(params["passed_inter_trial_interval"]) failDelay = int(params["failed_inter_trial_interval"]) if "y" in str(params["randomly_shaped_stimuli"]) or "Y" in str( params["randomly_shaped_stimuli"]): randShapes = True else:
import sys import os import random from random import randint import pygame as pg from pygame.locals import * sys.path.append( os.path.join("/home", "pi", "Desktop", "ChimpPygames", "PygameTools")) import PgTools # initialize pygame and screen pg.init() screen = PgTools.Screen() file = open("Delayed_Match_To_Sample/parameters.dat") params = PgTools.get_params(file) file.close() subjectName = str(params["subject_name"]) posStimName = str(params["sample/positive_stimulus_name"]) negStimName = str(params["negative_stimulus_name"]) trialsAmt = int(params["number_of_trials"]) + 1 stimAmt = int(params["number_of_comparison_stimuli"]) stimLength = int(params["stimulus_length"]) stimHeight = int(params["stimulus_height"]) strLengths = str(params["retention_interval_lengths"]).split(",") RILengths = [int(strLength) for strLength in strLengths] passDelay = int(params["passed_inter_trial_interval"]) failDelay = int(params["failed_inter_trial_interval"]) if ("y" in str(params["sample_stimulus_visible"])
import sys import os import random import pygame as pg from moviepy.editor import * from pygame.locals import * sys.path.append( os.path.join("/home", "pi", "Desktop", "ChimpPygames", "PygameTools")) import PgTools # initialize pygame and screen pg.init() screen = PgTools.Screen() file = open("Social_Stimuli_As_Rewards/parameters.dat") params = PgTools.get_params(file) file.close() subjectName = str(params["subject_name"]) trialsAmt = int(params["number_of_trials"]) + 1 stimRadius = int(params["stimulus_radius"]) stimTime = int(params["stimulus_duration"]) def start_trial(radius): """ Initiates a new trial, draws stimulus :param radius: radius of stimulus """ screen.refresh()
import sys import os import pygame as pg from pygame.locals import * sys.path.append( os.path.join("/home", "pi", "Desktop", "ChimpPygames", "PygameTools")) import PgTools import random import time import glob # initialize pygame and screen pg.init() screen = PgTools.Screen() # init font for trial counter font = pg.font.SysFont(None, 48) file = open("Training_Task/parametersP2.dat") params = PgTools.get_params(file) file.close() subjectName = str(params["subject_name"]) trialsAmt = int(params["number_of_trials"]) stimLength = int(params["stimulus_length"]) stimHeight = int(params["stimulus_height"]) passDelay = int(params["passed_inter_trial_interval"]) failDelay = int(params["failed_inter_trial_interval"]) if "y" in str(params["randomly_shaped_stimuli"]) or "Y" in str( params["randomly_shaped_stimuli"]): randShapes = True
import sys import os import pygame as pg from pygame.locals import * sys.path.append(os.path.join("/home", "pi", "Desktop", "ChimpPygames", "PygameTools")) import PgTools # initialize pygame and screen pg.init() screen = PgTools.Screen() file = open("Training_Task/parametersP1.dat") params = PgTools.get_params(file) file.close() subjectName = str(params["subject_name"]) trialsAmt = int(params["number_of_trials"]) + 1 stimLength = int(params["first_stimulus_length"]) stimHeight = int(params["first_stimulus_height"]) lastLength = int(params["last_stimulus_length"]) lastHeight = int(params["last_stimulus_height"]) passDelay = int(params["passed_inter_trial_interval"]) failDelay = int(params["failed_inter_trial_interval"]) if "y" in str(params["randomly_shaped_stimuli"]) or "Y" in str(params["randomly_shaped_stimuli"]): randShapes = True else: randShapes = False lengthDecrease = (stimLength - lastLength) / (trialsAmt - 1) heightDecrease = (stimHeight - lastHeight) / (trialsAmt - 1)
import sys import os import random import pygame as pg from pygame.locals import * sys.path.append( os.path.join("/home", "pi", "Desktop", "ChimpPygames", "PygameTools")) import PgTools # initialize pygame, screen, and clock pg.init() screen = PgTools.Screen() clock = pg.time.Clock() pg.time.get_ticks() file = open("Delayed_Response_Task/parameters.dat") params = PgTools.get_params(file) file.close() subjectName = str(params["subject_name"]) SCSStimName = str(params["spatially_cued_stimulus_name"]) otherStimName = str(params["other_stimuli_name"]) trialsAmt = int(params["number_of_trials"]) + 1 stimAmt = int(params["number_of_stimuli"]) locationsAmt = int(params["number_of_possible_SCS_locations"]) stimLength = int(params["stimulus_length"]) stimHeight = int(params["stimulus_height"]) strLengths = str(params["retention_interval_lengths"]).split(",") RILengths = [int(strLength) for strLength in strLengths] passDelay = int(params["passed_inter_trial_interval"])