def createList(self, trials=100): myColors = self.colors print myColors colorShuffler = shuffler.Shuffler(myColors, trials) print 'made shuffler' colorList = colorShuffler.shuffle() print colorList if self.useWords: wordList = self.createWordList(colorList) return colorList, wordList else: return colorList
def __init__(self, events, conditions, trials=40, duration=300, TR=2, hrf_dur=6, sample_res=3): self.TR = TR self.duration = duration self.pulses = numpy.arange(0, duration + TR, step=TR) self.events = events self.trials = trials self.hrf_dur = hrf_dur self.sample_res = sample_res self.conditions = conditions self.shuffler = shuffler.Shuffler(self.conditions, self.trials) self.shuffle() self.make()
n1 = p[0][0] n2 = p[0][1] allnums.append(n1) allnums.append(n2) trials = 400 #make magnitudes and whatnot ls = shuffler.ListShuffler(range(len(problems)), trials / 2, 5) add_problems = ls.shuffle() mag_problems = ls.shuffle() mag_angles = [15, 30, 345, 330] mag_sides = ["left", "right"] angle_shuffler = shuffler.Shuffler(mag_angles, trials / 2, 5) angles = angle_shuffler.shuffle() bs_shuffler = shuffler.Shuffler(["ll", "lr", "rl", "rr"], trials / 2, 5) bs_list = bs_shuffler.shuffle() """ side_shuffler = shuffler.Shuffler(mag_sides, trials/2, 4) sides = side_shuffler.shuffle() big_shuffler = shuffler.Shuffler(mag_sides, trials/2, 4) bigs = big_shuffler.shuffle() """ items = ["add", "mag"] #STIMULUS TYPE AND SIDE SHUFFLER
posts = db.getTable("training_sets").posts fontsize = 80 boxsize = 160 trials = 20 numbers = range(1, 41) random.shuffle(numbers) n1s = numbers[:trials] n2s = numbers[trials:] mag_angles = [15, 30, 345, 330] mag_sides = ["left", "right"] angle_shuffler = shuffler.Shuffler(mag_angles, trials, 5) angles = angle_shuffler.shuffle() side_shuffler = shuffler.Shuffler(mag_sides, trials, 4) sides = side_shuffler.shuffle() big_shuffler = shuffler.Shuffler(mag_sides, trials, 4) bigs = big_shuffler.shuffle() mag_problems = [] for n1, n2 in zip(n1s, n2s): mag_problems.append([n1, n2]) ###SET SCREEN screen = get_default_screen()
def create_stimuli(num_trials,trials,repeats): list1=['same1','same2','greater','less'] list2=[1,2,3,4,5,6,7,8,9] list3=['symbolic','nonsymbolic'] samedifflist = shuffler.Condition(list1, "condition", repeats) numlist = shuffler.Condition(list2, "num", repeats) numdotlist = shuffler.Condition(list3, "nd", repeats) stimList = shuffler.MultiShuffler([samedifflist,numlist,numdotlist], trials).shuffle() #DEBUGGING nd_list=[] num_sym = 0 num_nonsym = 0 for stim in stimList: nd = getattr(stim, "nd") if nd == 'symbolic': num_sym+=1 if nd == 'nonsymbolic': num_nonsym+=1 nd_list.append(nd) #generating jitter lists first_jitter = generate_jitter(1.5,5.5,num_trials, repeats) fixation_jitter = generate_jitter(1.9,8.4,num_trials,repeats) #stimuli is a list of tuples where (first stimulus, second stimulus) stimuli=[] #***** areaperimeter = shuffler.Shuffler(['area','perimeter'],(num_trials/2),repeats).shuffle() areaperimeter_counter = 0 #used stimli list used=[] #3 lists to store every png's for each condition imagelist= glob.glob("stimuli\*.png") stimuli_list=[] trial_no=1 for stim,jitter1,jitter2 in zip(stimList,first_jitter,fixation_jitter): #get attributes from stimList condition = getattr(stim, "condition") num = getattr(stim, "num") nd = getattr(stim, "nd") if num==9 and condition=='greater': num=random.randrange(1,9) if num==1 and condition=='less': num=random.randrange(2,10) #equal number of dots if (condition=='same1' or condition=='same2') and nd =='symbolic': contains = "_%s_%s_%s_S1" % (num,num,areaperimeter[areaperimeter_counter]) for image1 in imagelist: if contains and "S1" in image1 and image1 not in used: image2 = image1[:-5] + '2.png' stimuli.append([image1,image2]) areaperimeter_counter+=1 used.append(image1) temp = trial.Trial(trial_no, nd, num, num,image1,image2,condition,jitter1,jitter2, cresp=1) stimuli_list.append(temp) break #equal numbers if (condition=='same1' or condition=='same2') and nd =='nonsymbolic': stimuli.append(["%s" % num,"%s"% num]) temp = trial.Trial(trial_no, nd, num,num,condition=condition, first_jitter=jitter1,fixation_jitter=jitter2, cresp=1) stimuli_list.append(temp) #2nd stimulus greater than 1st #generating dot stim if condition=='greater' and nd =='symbolic': num2=num+1 contains = "%s_%s_%s" % (num,num2,areaperimeter[areaperimeter_counter]) for image1 in imagelist: if contains and "S1" in image1 and image1 not in used: image2 = image1[:-5] + '2.png' stimuli.append([image1,image2]) areaperimeter_counter+=1 used.append(image1) temp = trial.Trial(trial_no, nd, num, num2, image1, image2, condition, jitter1, jitter2,2) stimuli_list.append(temp) break #number stimulus if condition=='greater' and nd =='nonsymbolic': if num ==9: num = random.randrange(0,9) num2 = num+1 stimuli.append(["%s" % num, "%s" % num2]) temp = trial.Trial(trial_no, nd, num, num2, condition=condition,first_jitter=jitter1,fixation_jitter=jitter2, cresp=2) stimuli_list.append(temp) #2nd stimulus less than 1st #generating dot stim if condition=='less' and nd=='symbolic': num2=num-1 contains = "%s_%s_%s" % (num,num2,areaperimeter[areaperimeter_counter]) for image1 in imagelist: if contains and "S1" in image1 and image1 not in used: image2 = image1[:-5] + '2.png' stimuli.append([image1,image2]) areaperimeter_counter+=1 used.append(image1) temp = trial.Trial(trial_no, nd, num, num2, image1, image2, condition, jitter1, jitter2, 2) stimuli_list.append(temp) break #generating number stim if condition=='less' and nd =='nonsymbolic': if num==1: num = random.randrange(2,10) num2 = num-1 temp = trial.Trial(trial_no, nd, num, num2, condition=condition, first_jitter=jitter1, fixation_jitter=jitter2, cresp=2) stimuli_list.append(temp) trial_no+=1 return stimuli_list
ACC = 0 p.parameters.go_duration=(0, 'frames') elif key == 313: if correct == "right": ACC = 1 else: ACC = 0 p.parameters.go_duration=(0, 'frames') def pause_handler(event): if event.key == K_SPACE: print "BEGINNING EXPERIMENT" pause.parameters.go_duration = (0, 'frames') dShuffler = shuffler.Shuffler(distractors, len(verProbs), 3) dists = dShuffler.shuffle() sideShuffler = shuffler.Shuffler(lOrR, len(verProbs), 3) sides = sideShuffler.shuffle() sShuffler = shuffler.Shuffler(strats, len(verProbs), 3) strategies = sShuffler.shuffle() #generate texts strat2 = "\n\nPlease describe your strategy" stratText, stratPort = printText(screen, strat2, 60, (255, 255, 255)) strategy = "" RT = 0
n2 = p[0][1] allnums.append(n1) allnums.append(n2) #make magnitudes and whatnot ls = shuffler.ListShuffler(range(len(problems)), 200, 5) add_problems = ls.shuffle() mag_problems = ls.shuffle() items = ["add", "mag"] #STIMULUS TYPE AND SIDE SHUFFLER trials = 400 stim_shuffler = shuffler.Shuffler(items, trials, 5) stimList = stim_shuffler.shuffle() ###SET SCREEN screen = get_default_screen() screen.parameters.bgcolor = (0, 0, 0) pygame.font.init() framerate = 60 #helper functions def frame_to_time(f): t = float(f) / float(framerate) return t
seeds = shuffler.Condition([6, 7, 8, 9, 10, 11], "seed", 6) size = shuffler.Condition(["con", "incon"], "size", 6) exemplars = shuffler.Condition([1, 2, 3, 4, 5, 6], "exemplar", 20) shapes = shuffler.Condition(['square', 'triangle'], "shape", 7) order = ["large", "small"] print "loading ratio/seed/size/exemplar order..." myShuffler = shuffler.MultiShuffler([ratios, seeds, size, exemplars, shapes], trials) stimList = myShuffler.shuffle() sides = shuffler.Condition(order, "sides", 5) print "loading sides order..." csShuffler = shuffler.Shuffler(order, trials, 3) csList = csShuffler.shuffle() x = screen.size[0] / 4 y = screen.size[1] / 2 print "Beginning block now..." experiments.showInstructions(screen, instructionText, textcolor=color) if subtrials == -1: stimList = stimList csList = csList else: stimList = stimList[0:subtrials] csList = csList[0:subtrials]