def run_experiment(): participant_data = get_subj_info( 'gui.yaml', # check_exists is a simple function to determine if the data file # exists, provided subj_info data. Here the calculation of the data # file path is provided through the participant class. check_exists=lambda subj_info: Participant(**subj_info).data_file.exists() ) participant = Participant(**participant_data) trials = Trials.make(**participant) # Start of experiment experiment = create_experiment() experiment.show_text('instructions') participant.write_header(trials.COLUMNS) for block in trials.iter_blocks(): block_type = block[0]['block_type'] for trial in block: trial_data = experiment.run_trial(trial) participant.write_trial(trial_data) if block_type == 'practice': experiment.show_text('end_of_practice') else: experiment.show_text('break') experiment.show_text('end_of_experiment') webbrowser.open(experiment.survey_url.format(**participant))
def main(): participant_data = get_subj_info( 'gui.yaml', # check_exists is a simple function to determine if the data file # exists, provided subj_info data. Here it's used to check for # uniqueness in subj_ids when getting info from gui. check_exists=lambda subj_info: Participant(**subj_info).data_file.exists() ) participant = Participant(**participant_data) trials = Trials.make(**participant) # Start of experiment experiment = Experiment('settings.yaml', 'texts.yaml') experiment.show_instructions() participant.write_header(trials.COLUMNS) for block in trials.iter_blocks(): block_type = block[0]['block_type'] for trial in block: trial_data = experiment.run_trial(trial) participant.write_trial(trial_data) if block_type == 'practice': experiment.show_end_of_practice_screen() else: experiment.show_break_screen() experiment.show_end_of_experiment_screen() import webbrowser webbrowser.open(experiment.survey_url.format(**participant))
def main(): participant_data = get_subj_info( 'gui.yaml', # check_exists is a simple function to determine if the data file # exists, provided subj_info data. Here it's used to check for # uniqueness in subj_ids when getting info from gui. check_exists=lambda subj_info: Participant(**subj_info).data_file. exists()) participant = Participant(**participant_data) trials = Trials.make(**participant) # Start of experiment experiment = Experiment('settings.yaml', 'texts.yaml') experiment.show_instructions() participant.write_header(trials.COLUMNS) for block in trials.iter_blocks(): block_type = block[0]['block_type'] for trial in block: trial_data = experiment.run_trial(trial) participant.write_trial(trial_data) if block_type == 'practice': experiment.show_end_of_practice_screen() else: experiment.show_break_screen() experiment.show_end_of_experiment_screen() import webbrowser webbrowser.open(experiment.survey_url.format(**participant))
def main(): participant_data = get_subj_info( 'gui.yaml', # check_exists is a simple function to determine if the data file # exists, provided subj_info data. It's used to validate the data # entered in the gui. check_exists=lambda subj_info: Participant(**subj_info).data_file.exists() ) participant = Participant(**participant_data) trials = Trials.make(**participant) last_block_num = trials[-1]['block'] # Start of experiment experiment = Experiment('settings.yaml', 'texts.yaml') experiment.show_screen('instructions') participant.write_header(trials.COLUMNS) for block in trials.iter_blocks(): block_num = block[0]['block'] block_type = block[0]['block_type'] for trial in block: trial_data = experiment.run_trial(trial) participant.write_trial(trial_data) if block_type == 'practice': experiment.show_screen('end_of_practice') elif block_num != last_block_num: experiment.show_screen('break') experiment.show_screen('end_of_experiment') import webbrowser webbrowser.open(experiment.survey_url.format(**participant))