1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Add 4 second countdown timer for trials
h_timer = annotation('textbox',[.35 .05 .3 .2], 'FontSize', 20,...
'LineStyle', 'none','HorizontalAlignment', 'center');
targetstruct(6) = struct('item_num', 006, 'filename', 'a.wav');
targetstruct(5) = struct('item_num', 005, 'filename', 'b.wav');
targetstruct(4) = struct('item_num', 004, 'filename', 'c.wav');
targetstruct(3) = struct('item_num', 003, 'filename', 'd.wav');
targetstruct(2) = struct('item_num', 002, 'filename', 'e.wav');
targetstruct(1) = struct('item_num', 001, 'filename', 'f.wav');
%%% Enable pushbutton11 (Start_button)
set(hObject, 'visible', 'off');
set(handles.text9, 'visible', 'off');
%%% Enable button 1 and 2
set(handles.pushbutton1, 'Enable', 'on');
set(handles.pushbutton2, 'Enable', 'on');
global SUBJECT_RESPONSE
answer_code = [];
%%% Before the 1st stimulus, there is 4 sec countdown, after that the presentation start automatically
for t=3:-1:0 % Display countdown for 4 second window to respond
set(h_timer,'string',{'Début dans :' t 'secondes'});
pause(1); % Make a pause during 1 second
end
set(h_timer,'string',{''}); % Hide the countdown
%%% List Generation
%%%%%%%%%%%%%%%%%%%
x = [ones(1,10)*1,ones(1,10)*2,ones(1,10)*3,ones(1,10)*4,ones(1,10)*5,ones(1,10)*6];
targetlist = x(randperm(length(x)));
time_start = clock; % Begin the stopwatch to run until end of test
%%% Stimuli Presentation
%%%%%%%%%%%%%%%%%%%%%%%%
for ii = 1 : length(targetlist)
%%% Record reaction time (start)
time_begin_trial(ii,:) = clock; % Record timestamp after each stim presentation
tic; % tic will be used for reactiontime
%%% Stimuli presentation
y = targetlist(ii);
targetwav = wavread(targetstruct(y).filename);
sound(targetwav,44100);
waitforbuttonpress;
if SUBJECT_RESPONSE == 0
answer_code(ii) = 0;
else
answer_code(ii) = 1;
end
pause(0.5); % after the given answer
%%% Record reaction time (end)
toc; reaction_time(ii) = toc;
time_response(ii,:) = clock; % Record time when subject respond
time_trial_duration = etime(time_response(ii,:), time_begin_trial(ii,:));
end
time_end = clock; % End the stopwatch
test_duration = time_end - time_start; % it took this long to complete the test |
Partager