-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBAT.m
100 lines (79 loc) · 3.21 KB
/
BAT.m
1
function BAT(subject_id)% Wrapper function for the adaptive BAT test.% - Initializes PsychToolbox via bat_initialize_ptb.m% - If both phase and tempo tests are desired, implements both in random% order% - Calls function adaptive_bat.m, which implements IBI or phase% preturbation tasks based on parameter input, estimates subject's% threshold on each test, and outputs a csv data file to file path location% specified in bat_params.% - User should specify file paths and other preferences in bat_params.m%% REQUIRED INPUT:% * subject_id - subject name/ID (string)%% written 14 Sept 2016 by Brian K. Hurley% set experiment parametersparams = bat_params;% initialize PsychToolbox graphics and audio% (passing IBI params, as PTB params are the same for both versions of task)ptb = bat_initialize_ptb(params.ibi);% start timer to measure task lengthtic%% Task% if test versions to perform not specified, assume both versionsif isfield(params, 'perform') versions = params.perform;else versions = {'ibi', 'phase'};endn_versions = length(versions);% randomize task ordertask_order = randperm(n_versions);% iterate over each task versionfor i_order = 1:length(task_order) curr_task = versions{task_order(i_order)}; % if testing both versions and we are on the second pass, give % instructions again if (n_versions > 1) && (i_order > 1) textString = ['You will now perform a similar task on the same music. Again, '... 'please listen to each musical excerpt and judge whether ' ... 'the click track is on-beat or off-beat. \n\n\n Respond at the end of ' ... 'each musical excerpt by pressing Q if the tone is off-beat or P if ' ... 'the tone is on-beat.']; DrawFormattedText(ptb.window, textString, 'center', 'center', ptb.white, 60); Screen('TextSize',ptb.window, 15); textString = '< Press any key to continue >'; DrawFormattedText(ptb.window, textString, 'center', 1000, ptb.white); Screen('Flip', ptb.window); KbStrokeWait; % return subject to abbreviated on-screen instructions Screen('TextSize',ptb.window, 30); trial_textString = 'When music ends\n\n\nPress Q for off-beat, P for on-beat'; DrawFormattedText(ptb.window, trial_textString, 'center', 'center', ptb.white); Screen('Flip', ptb.window); WaitSecs(2) tic end % If the current task is tempo, implement ibi (tempo) test. Otherwise, % implement phase test if strcmp(curr_task, 'ibi') adaptive_bat(subject_id, 'B', ptb, params.ibi); elseif strcmp(curr_task, 'phase') adaptive_bat(subject_id, 'P', ptb, params.phase); end % show elapsed time (s) for each version time_elapsed = toc; disp(time_elapsed); end% tell subject that they have finishedScreen('TextSize',ptb.window, 30);end_textString = 'You have completed the BAT test.\n\nPlease wait for further instructions.';DrawFormattedText(ptb.window, end_textString, 'center', 'center', ptb.white);Screen('Flip', ptb.window);WaitSecs(5)% close PsychPortAudioPsychPortAudio('Close', ptb.pahandle);% close subject interface screenscaend