def run_block(self, block_num, total_blocks, block_type): cur_block = self.create_block(block_num, self.combinations, block_type) for i in range(cur_block.shape[0]): self.display_trial(i, cur_block, block_type) if block_type == "main": # Add block data to all_data self.all_data = pd.concat([self.all_data, cur_block]) # End of block screen if block_num != total_blocks - 1: # If not the final block self.screen.blit(self.background, (0, 0)) display.text( self.screen, self.font, "End of current block. " "Start next block when you're ready...", 100, "center", ) display.text_space(self.screen, self.font, "center", (self.screen_y / 2) + 100) pygame.display.flip() display.wait_for_space()
def run_block(self, block_num, total_blocks, block_type): cur_block = self.create_block( block_num, self.combinations, block_type) for i in range(cur_block.shape[0]): self.display_trial(i, cur_block, block_type) if block_type == "main": # Add block data to all_data self.all_data = pd.concat([self.all_data, cur_block]) # End of block screen if block_num != total_blocks - 1: # If not the final block self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "End of current block. " "Start next block when you're ready...", 100, "center") display.text_space(self.screen, self.font, "center", (self.screen_y/2) + 100) pygame.display.flip() display.wait_for_space()
def run(self): # Instructions self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "Attentional Network Test", "center", self.screen_y / 2 - 300) display.text( self.screen, self.font, "Keep your eyes on the fixation cross at the " "start of each trial:", 100, self.screen_y / 2 - 200) display.image(self.screen, self.img_fixation, "center", self.screen_y / 2 - 150) display.text(self.screen, self.font, "A set of arrows will appear somewhere on the screen:", 100, self.screen_y / 2 - 100) display.image(self.screen, self.img_left_incongruent, "center", self.screen_y / 2 - 50) display.text( self.screen, self.font, "Use the Left / Right arrow keys to indicate " "the direction of the CENTER arrow.", 100, self.screen_y / 2 + 50) display.text(self.screen, self.font, "In example above, you should press the Left arrow.", 100, self.screen_y / 2 + 100) display.text_space(self.screen, self.font, "center", (self.screen_y / 2) + 300) pygame.display.flip() display.wait_for_space() # Instructions Practice self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "We'll begin with some practice trials...", "center", "center") display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 100) pygame.display.flip() display.wait_for_space() # Practice trials self.run_block(0, 1, "practice") # Instructions Practice End self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "We will now begin the main trials...", 100, self.screen_y / 2 - 50) display.text(self.screen, self.font, "You will not receive feedback after each trial.", 100, self.screen_y / 2 + 50) display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 200) pygame.display.flip() display.wait_for_space() # Main task for i in range(self.NUM_BLOCKS): self.run_block(i, self.NUM_BLOCKS, "main") # Create trial number column self.all_data["trial"] = list(range(1, len(self.all_data) + 1)) # Rearrange the dataframe columns = [ 'trial', 'block', 'congruency', 'cue', 'location', 'fixationTime', 'ITI', 'direction', 'response', 'correct', 'RT' ] self.all_data = self.all_data[columns] # End screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "End of task", "center", "center") display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 100) pygame.display.flip() display.wait_for_space() print("- ANT complete") return self.all_data
def run(self): # Instructions self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "SART", "center", self.screen_y / 2 - 250, (255, 255, 255)) display.text(self.screen, self.font, "Numbers will appear in the center of the screen.", 100, self.screen_y / 2 - 150, (255, 255, 255)) display.text(self.screen, self.font, "Press the spacebar after you see a number.", 100, self.screen_y / 2 - 50, (255, 255, 255)) display.text( self.screen, self.font, "However, if the number is a 3, " "do NOT press the spacebar.", 100, self.screen_y / 2 + 50, (255, 255, 255)) display.text( self.screen, self.font, "Please respond as quickly, " "and as accurately, as possible", 100, self.screen_y / 2 + 150, (255, 255, 255)) display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 300, (255, 255, 255)) pygame.display.flip() display.wait_for_space() # Instructions Practice self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "We will begin with a few practice trials...", "center", "center", (255, 255, 255)) display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 100, (255, 255, 255)) pygame.display.flip() display.wait_for_space() # Blank screen display.blank_screen(self.screen, self.background, self.BLANK_DURATION) # Show practice trials practice_trials = pd.DataFrame([5, 7, 7, 3, 9, 2, 1, 3, 8, 6], columns=['stimulus']) for i in range(practice_trials.shape[0]): self.display_trial(i, practice_trials) # Practice end screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "End of practice trials", 100, self.screen_y / 2 - 100, (255, 255, 255)) display.text(self.screen, self.font, "We will now begin the main trials...", 100, "center", (255, 255, 255)) display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 100, (255, 255, 255)) pygame.display.flip() display.wait_for_space() # Blank screen display.blank_screen(self.screen, self.background, self.BLANK_DURATION) # Show main trials for i in range(self.all_data.shape[0]): self.display_trial(i, self.all_data) # Rearrange dataframe columns = [ 'trial', 'stimulus', 'stimSize', 'RT', 'key press', 'accuracy' ] self.all_data = self.all_data[columns] # End screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "End of task", "center", "center", (255, 255, 255)) display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 100, (255, 255, 255)) pygame.display.flip() display.wait_for_space() print("- SART complete") return self.all_data
def run(self): # Instructions self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "Backwards Digit Span", "center", self.screen_y / 2 - 300) display.text( self.screen, self.font, "You will be shown a number sequence, " "one number at a time", 100, self.screen_y / 2 - 200) display.text(self.screen, self.font, "Memorize the number sequence", 100, self.screen_y / 2 - 100) display.text( self.screen, self.font, "You will then be asked to type the sequence " "in reverse/backwards order. For example...", 100, "center") display.text(self.screen, self.font, "Sequence: 1 2 3 4 5", "center", self.screen_y / 2 + 100) display.text(self.screen, self.font, "Correct: 5 4 3 2 1", "center", self.screen_y / 2 + 150) display.text( self.screen, self.font, "The sequences will get longer throughout the experiment", 100, self.screen_y / 2 + 250) display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 350) pygame.display.flip() display.wait_for_space() # Instructions Practice self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "We will begin with a practice trial...", 100, "center") display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 100) pygame.display.flip() display.wait_for_space() # Practice trial practice_data = pd.DataFrame(['13579'], columns=['sequence']) correct_sequence_p = self.display_numbers(0, practice_data) user_sequence_p = self.number_entry() # Practice feedback screen self.screen.blit(self.background, (0, 0)) # Check if reverse of user input matches the correct sequence if self.check_answer(user_sequence_p, correct_sequence_p): display.text(self.screen, self.font, "Correct", "center", "center", (0, 255, 0)) else: display.text(self.screen, self.font, "Incorrect", "center", "center", (255, 0, 0)) pygame.display.flip() display.wait(self.FEEDBACK_DURATION) # Practice end screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "We will now begin the main trials...", 100, "center") display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 100) pygame.display.flip() display.wait_for_space() # Main trials for i in range(len(self.all_data)): correct_sequence = self.display_numbers(i, self.all_data) user_sequence = self.number_entry() self.all_data.set_value(i, 'user_sequence', user_sequence) if self.check_answer(user_sequence, correct_sequence): self.all_data.set_value(i, 'correct', 1) else: self.all_data.set_value(i, 'correct', 0) # End screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "End of task", "center", "center") display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 100) pygame.display.flip() display.wait_for_space() print("- Digit span (backwards) complete") return self.all_data
def run(self): if self.BLOCK_ORDER == "choose": # If the order is "choose" but one of the block types has a 0, then dont show choose screen if self.BLOCKS_COMPAT == 0: self.BLOCK_ORDER = "incompatible" elif self.BLOCKS_INCOMPAT == 0: self.BLOCK_ORDER = "compatible" else: self.screen.blit(self.background, (0, 0)) display.text( self.screen, self.font, "Choose block order:", 100, self.screen_y / 2 - 300, self.colour_font, ) display.text( self.screen, self.font, "1 - Compatible first", 100, self.screen_y / 2 - 200, self.colour_font, ) display.text( self.screen, self.font, "2 - Incompatible first", 100, self.screen_y / 2 - 150, self.colour_font, ) pygame.display.flip() wait_response = True while wait_response: for event in pygame.event.get(): if event.type == KEYDOWN and event.key == K_1: self.BLOCK_ORDER = "compatible" wait_response = False elif event.type == KEYDOWN and event.key == K_2: self.BLOCK_ORDER = "incompatible" wait_response = False elif event.type == KEYDOWN and event.key == K_F12: sys.exit(0) # Set block order if self.BLOCK_ORDER == "compatible": self.block_type_list = (["compatible"] * self.BLOCKS_COMPAT) + ( ["incompatible"] * self.BLOCKS_INCOMPAT ) elif self.BLOCK_ORDER == "incompatible": self.block_type_list = (["incompatible"] * self.BLOCKS_INCOMPAT) + ( ["compatible"] * self.BLOCKS_COMPAT ) # Instructions self.screen.blit(self.background, (0, 0)) display.text( self.screen, self.font, "Eriksen Flanker Task", "center", self.screen_y / 2 - 300, self.colour_font, ) display.text( self.screen, self.font, "Keep your eyes on the fixation cross at the " "start of each trial:", 100, self.screen_y / 2 - 200, self.colour_font, ) display.text( self.screen, self.font, "+", "center", self.screen_y / 2 - 150, self.colour_font, ) display.text( self.screen, self.font, "A set of arrows will appear:", 100, self.screen_y / 2 - 100, self.colour_font, ) display.text( self.screen, self.font_stim, self.flanker_stim["left"]["incongruent"], "center", self.screen_y / 2 - 60, self.colour_font, ) if self.block_type_list[0] == "compatible": display.text( self.screen, self.font, "Use the Left / Right arrow keys to indicate " "the pointing direction of the CENTER arrow.", 100, self.screen_y / 2 + 70, self.colour_font, ) display.text( self.screen, self.font, "In example above, you should press the LEFT key.", 100, self.screen_y / 2 + 120, self.colour_font, ) elif self.block_type_list[0] == "incompatible": display.text( self.screen, self.font, "Use the Left / Right arrow keys to indicate " "the OPPOSITE pointing direction of the CENTER arrow.", 100, self.screen_y / 2 + 70, self.colour_font, ) display.text( self.screen, self.font, "In example above, you should press the RIGHT key.", 100, self.screen_y / 2 + 120, self.colour_font, ) display.text( self.screen, self.font, "Respond as quickly, and as accurately, as you can", 100, self.screen_y / 2 + 200, self.colour_font, ) display.text_space( self.screen, self.font, "center", (self.screen_y / 2) + 300, self.colour_font, ) pygame.display.flip() display.wait_for_space() # Instructions Practice self.screen.blit(self.background, (0, 0)) display.text( self.screen, self.font, "We'll begin with some practice trials...", "center", "center", self.colour_font, ) display.text_space( self.screen, self.font, "center", self.screen_y / 2 + 100, self.colour_font ) pygame.display.flip() display.wait_for_space() # Practice trials self.run_block(0, 1, "practice", self.block_type_list[0]) # Instructions Practice End self.screen.blit(self.background, (0, 0)) display.text( self.screen, self.font, "We will now begin the main trials...", 100, self.screen_y / 2, self.colour_font, ) display.text_space( self.screen, self.font, "center", self.screen_y / 2 + 200, self.colour_font ) pygame.display.flip() display.wait_for_space() # Main task second half if self.block_type_list[0] == "compatible": for i in range(self.BLOCKS_COMPAT): self.run_block(i, self.BLOCKS_COMPAT, "main", self.block_type_list[0]) elif self.block_type_list[0] == "incompatible": for i in range(self.BLOCKS_INCOMPAT): self.run_block(i, self.BLOCKS_INCOMPAT, "main", self.block_type_list[0]) # Second half (if more than one compatibility type) if self.block_type_list[0] != self.block_type_list[-1]: self.screen.blit(self.background, (0, 0)) display.text( self.screen, self.font, "End of first half. Please inform the experimenter.", 100, self.screen_y / 2, self.colour_font, ) display.text_space( self.screen, self.font, "center", self.screen_y / 2 + 200, self.colour_font, ) pygame.display.flip() display.wait_for_space() # Practice instructions self.screen.blit(self.background, (0, 0)) display.text( self.screen, self.font, "For the second half, the task will be slightly different:", 100, self.screen_y / 2 - 300, self.colour_font, ) display.text( self.screen, self.font_stim, self.flanker_stim["left"]["incongruent"], "center", self.screen_y / 2 - 250, self.colour_font, ) if self.block_type_list[-1] == "compatible": display.text( self.screen, self.font, "This time, indicate the pointing direction of the CENTER arrow", 100, self.screen_y / 2 - 100, self.colour_font, ) display.text( self.screen, self.font, "So in the example above, you would press LEFT", 100, self.screen_y / 2, self.colour_font, ) elif self.block_type_list[-1] == "incompatible": display.text( self.screen, self.font, "This time, indicate the OPPOSITE pointing direction of the CENTER arrow", 100, self.screen_y / 2 - 100, self.colour_font, ) display.text( self.screen, self.font, "So in the example above, you would press RIGHT", 100, self.screen_y / 2, self.colour_font, ) display.text( self.screen, self.font, "Respond as quickly, and as accurately, as you can", 100, self.screen_y / 2 + 100, self.colour_font, ) display.text_space( self.screen, self.font, "center", self.screen_y / 2 + 250, self.colour_font, ) pygame.display.flip() display.wait_for_space() # Instructions Practice self.screen.blit(self.background, (0, 0)) display.text( self.screen, self.font, "We'll begin with some practice trials...", "center", "center", self.colour_font, ) display.text_space( self.screen, self.font, "center", self.screen_y / 2 + 100, self.colour_font, ) pygame.display.flip() display.wait_for_space() # Practice trials self.run_block(0, 1, "practice", self.block_type_list[-1]) # Instructions Practice End self.screen.blit(self.background, (0, 0)) display.text( self.screen, self.font, "We will now begin the main trials...", 100, self.screen_y / 2, self.colour_font, ) display.text_space( self.screen, self.font, "center", self.screen_y / 2 + 200, self.colour_font, ) pygame.display.flip() display.wait_for_space() # Main task if self.block_type_list[-1] == "compatible": for i in range(self.BLOCKS_COMPAT): self.run_block( self.BLOCKS_INCOMPAT + i, self.BLOCKS_COMPAT, "main", self.block_type_list[-1], True, ) elif self.block_type_list[-1] == "incompatible": for i in range(self.BLOCKS_INCOMPAT): self.run_block( self.BLOCKS_COMPAT + i, self.BLOCKS_INCOMPAT, "main", self.block_type_list[-1], True, ) # Create trial number column self.all_data["trial"] = list(range(1, len(self.all_data) + 1)) # Rearrange the dataframe columns = [ "trial", "block", "compatibility", "congruency", "direction", "response", "correct", "RT", ] self.all_data = self.all_data[columns] # End screen self.screen.blit(self.background, (0, 0)) display.text( self.screen, self.font, "End of task", "center", "center", self.colour_font ) display.text_space( self.screen, self.font, "center", self.screen_y / 2 + 100, self.colour_font ) pygame.display.flip() display.wait_for_space() print("- Flanker complete") return self.all_data
def run(self): # Instructions self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "Attentional Network Test", "center", self.screen_y/2 - 300) display.text(self.screen, self.font, "Keep your eyes on the fixation cross at the " "start of each trial:", 100, self.screen_y/2 - 200) display.image(self.screen, self.img_fixation, "center", self.screen_y/2 - 150) display.text(self.screen, self.font, "A set of arrows will appear somewhere on the screen:", 100, self.screen_y/2 - 100) display.image(self.screen, self.img_left_incongruent, "center", self.screen_y/2 - 50) display.text(self.screen, self.font, "Use the Left / Right arrow keys to indicate " "the direction of the CENTER arrow.", 100, self.screen_y/2 + 50) display.text(self.screen, self.font, "In example above, you should press the Left arrow.", 100, self.screen_y/2 + 100) display.text_space(self.screen, self.font, "center", (self.screen_y/2) + 300) pygame.display.flip() display.wait_for_space() # Instructions Practice self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "We'll begin with a some practice trials...", "center", "center") display.text_space(self.screen, self.font, "center", self.screen_y/2 + 100) pygame.display.flip() display.wait_for_space() # Practice trials self.run_block(0, 1, "practice") # Instructions Practice End self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "We will now begin the main trials...", 100, self.screen_y/2 - 50) display.text(self.screen, self.font, "You will not receive feedback after each trial.", 100, self.screen_y/2 + 50) display.text_space(self.screen, self.font, "center", self.screen_y/2 + 200) pygame.display.flip() display.wait_for_space() # Main task for i in range(self.NUM_BLOCKS): self.run_block(i, self.NUM_BLOCKS, "main") # Create trial number column self.all_data["trial"] = range(1, len(self.all_data) + 1) # Rearrange the dataframe columns = ['trial', 'block', 'congruency', 'cue', 'location', 'fixationTime', 'ITI', 'direction', 'response', 'correct', 'RT'] self.all_data = self.all_data[columns] # End screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "End of task", "center", "center") display.text_space(self.screen, self.font, "center", self.screen_y/2 + 100) pygame.display.flip() display.wait_for_space() print "- ANT complete" return self.all_data
def run(self): # Instructions screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "Sternberg Task", "center", 100) display.text( self.screen, self.font, "You will see a sequence of numbers, one at a time. " "Try your best to memorize them", 100, 200) display.text(self.screen, self.stim_font, "8 - 5 - 4 - 1 - 0 - 9", "center", 300) display.text(self.screen, self.font, "You will then be shown a single test number in blue", 100, 400) display.text(self.screen, self.stim_font, "0", "center", 500, (0, 0, 255)) display.text( self.screen, self.font, "If this number was in the original sequence, " "press the LEFT arrow", 100, 600) display.text( self.screen, self.font, "If this number was NOT in the original sequence, " "press the RIGHT arrow", 100, 700) display.text( self.screen, self.font, "Try to do this as quickly, " "and as accurately, as possible", 100, 800) display.text_space(self.screen, self.font, "center", 900) pygame.display.flip() display.wait_for_space() # Practice ready screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "We will begin with some practice trials...", "center", "center") display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 100) pygame.display.flip() display.wait_for_space() # Practice trials for i, r in self.practice_trials.iterrows(): self.display_trial(self.practice_trials, i, r, "practice") # Main trials ready screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "End of practice trials.", 100, 100) display.text(self.screen, self.font, "You may move on to the main " "trials when you're ready", 100, 300) display.text( self.screen, self.font, "Remember to respond as quickly " "and as accurately as possible", 100, 500) display.text(self.screen, self.font, "Your reaction time and accuracy" " will be recorded", 100, 600) display.text_space(self.screen, self.font, "center", 800) pygame.display.flip() display.wait_for_space() # Main trials for i, block in enumerate(self.blocks): for j, r in block.iterrows(): self.display_trial(block, j, r, "main") # If this is not the final block, show instructions for next block if i != len(self.blocks) - 1: display.text(self.screen, self.font, "End of block.", 100, 200) display.text( self.screen, self.font, "Take a short break, and press space when you're " "ready to start the next block...", 100, 400) display.text_space(self.screen, self.font, "center", 700) pygame.display.flip() display.wait_for_space() # End screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "End of task", "center", "center") display.text_space(self.screen, self.font, "center", self.screen_y / 2 + 100) pygame.display.flip() display.wait_for_space() # Concatenate blocks and add trial numbers all_data = pd.concat(self.blocks) all_data['trialNum'] = list(range(1, len(all_data) + 1)) print("- Sternberg Task complete") return all_data
def run(self): # Instructions screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "Sternberg Task", "center", 100) display.text(self.screen, self.font, "You will see a sequence of numbers, one at a time. " "Try your best to memorize them", 100, 200) display.text(self.screen, self.stim_font, "8 - 5 - 4 - 1 - 0 - 9", "center", 300) display.text(self.screen, self.font, "You will then be shown a single test number in blue", 100, 400) display.text(self.screen, self.stim_font, "0", "center", 500, (0, 0, 255)) display.text(self.screen, self.font, "If this number was in the original sequence, " "press the LEFT arrow", 100, 600) display.text(self.screen, self.font, "If this number was NOT in the original sequence, " "press the RIGHT arrow", 100, 700) display.text(self.screen, self.font, "Try to do this as quickly, " "and as accurately, as possible", 100, 800) display.text_space(self.screen, self.font, "center", 900) pygame.display.flip() display.wait_for_space() # Practice ready screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "We will begin with some practice trials...", "center", "center") display.text_space(self.screen, self.font, "center", self.screen_y/2 + 100) pygame.display.flip() display.wait_for_space() # Practice trials for i, r in self.practice_trials.iterrows(): self.display_trial(self.practice_trials, i, r, "practice") # Main trials ready screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "End of practice trials.", 100, 100) display.text(self.screen, self.font, "You may move on to the main " "trials when you're ready", 100, 300) display.text(self.screen, self.font, "Remember to respond as quickly " "and as accurately as possible", 100, 500) display.text(self.screen, self.font, "Your reaction time and accuracy" " will be recorded", 100, 600) display.text_space(self.screen, self.font, "center", 800) pygame.display.flip() display.wait_for_space() # Main trials for i, block in enumerate(self.blocks): for j, r in block.iterrows(): self.display_trial(block, j, r, "main") # If this is not the final block, show instructions for next block if i != len(self.blocks)-1: display.text(self.screen, self.font, "End of block.", 100, 200) display.text(self.screen, self.font, "Take a short break, and press space when you're " "ready to start the next block...", 100, 400) display.text_space(self.screen, self.font, "center", 700) pygame.display.flip() display.wait_for_space() # End screen self.screen.blit(self.background, (0, 0)) display.text(self.screen, self.font, "End of task", "center", "center") display.text_space(self.screen, self.font, "center", self.screen_y/2 + 100) pygame.display.flip() display.wait_for_space() # Concatenate blocks and add trial numbers all_data = pd.concat(self.blocks) all_data['trialNum'] = range(1, len(all_data) + 1) print "- Sternberg Task complete" return all_data