|
|
|
|
|
|
|
|
|
|
|
B1trials_perType = 2;
|
|
|
|
|
|
|
|
|
AB_trials = repmat([ A,B ], B1trials_perType, 1);
|
|
|
BA_trials = repmat([ B,A ], B1trials_perType, 1);
|
|
|
|
|
|
|
|
|
B1_trialList = [AB_trials; BA_trials;];
|
|
|
|
|
|
|
|
|
B1_images = [];
|
|
|
B1_images{1} = imread('./images/1.bmp');
|
|
|
B1_images{2} = imread('./images/2.bmp');
|
|
|
|
|
|
|
|
|
B1_textures = [];
|
|
|
for B1Texture_index = 1 : size(B1_images, 2)
|
|
|
B1_textures{B1Texture_index}= Screen('MakeTexture', wPtr, B1_images{B1Texture_index});
|
|
|
end
|
|
|
|
|
|
|
|
|
textures = [];
|
|
|
textures(A) = B1_textures{1};
|
|
|
textures(B) = B1_textures{2};
|
|
|
|
|
|
|
|
|
|
|
|
B1Complete = false;
|
|
|
numB1Blocks = 1;
|
|
|
B1block_index = 0;
|
|
|
no_response = false;
|
|
|
|
|
|
|
|
|
while ~B1Complete
|
|
|
|
|
|
|
|
|
trial_ids = [];
|
|
|
|
|
|
trial_stimuli = [];
|
|
|
|
|
|
trial_response = [];
|
|
|
|
|
|
trial_selectedStim = [];
|
|
|
|
|
|
trial_RT = [];
|
|
|
|
|
|
trial_accuracy = [];
|
|
|
|
|
|
|
|
|
B1block_index = B1block_index + 1;
|
|
|
|
|
|
|
|
|
randomized_trialList = B1_trialList([1,3,2,4],:);
|
|
|
|
|
|
trial_index = 1;
|
|
|
while trial_index <= size(randomized_trialList, 1)
|
|
|
|
|
|
|
|
|
fixation_text = '+';
|
|
|
Screen('TextFont',wPtr,'Times');
|
|
|
Screen('TextStyle',wPtr,0);
|
|
|
Screen('TextColor',wPtr,[255 255 255]);
|
|
|
Screen('TextSize',wPtr,80);
|
|
|
DrawFormattedText(wPtr,fixation_text,'center','center');
|
|
|
Screen(wPtr, 'Flip');
|
|
|
|
|
|
WaitSecs(1);
|
|
|
|
|
|
|
|
|
L = randomized_trialList(trial_index, 1);
|
|
|
R = randomized_trialList(trial_index, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if L==1 || L==3
|
|
|
correct_choice = left_button;
|
|
|
|
|
|
elseif L==2 || L==4
|
|
|
correct_choice = right_button;
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Screen('DrawTexture', wPtr, textures(L), [], left_rect_test);
|
|
|
Screen('DrawTexture', wPtr, textures(R), [], right_rect_test);
|
|
|
Screen(wPtr, 'Flip');
|
|
|
|
|
|
|
|
|
startTime = GetSecs();
|
|
|
|
|
|
wait_stamp=GetSecs;
|
|
|
|
|
|
while 1
|
|
|
|
|
|
[ keyIsDown, seconds, keyCode ] = KbCheck(GPindx);
|
|
|
if keyIsDown
|
|
|
if keyCode(left_button) && left_button==correct_choice
|
|
|
subject_choice = left_button;
|
|
|
no_response = false;
|
|
|
trlResponse = 1;
|
|
|
trlAccuracy = 1;
|
|
|
break;
|
|
|
elseif keyCode(right_button) && right_button==correct_choice
|
|
|
subject_choice = right_button;
|
|
|
no_response = false;
|
|
|
trlResponse = 1;
|
|
|
trlAccuracy = 1;
|
|
|
break;
|
|
|
elseif keyCode(left_button) && left_button~=correct_choice
|
|
|
subject_choice = left_button;
|
|
|
no_response = false;
|
|
|
trlResponse = 1;
|
|
|
trlAccuracy = 0;
|
|
|
break;
|
|
|
elseif keyCode(right_button) && right_button~=correct_choice
|
|
|
subject_choice = right_button;
|
|
|
no_response = false;
|
|
|
trlResponse = 1;
|
|
|
trlAccuracy = 0;
|
|
|
break;
|
|
|
end
|
|
|
elseif(GetSecs-wait_stamp) > TSTDEADLINE,
|
|
|
subject_choice = 9999;
|
|
|
no_response = true;
|
|
|
trlResponse = -1;
|
|
|
trlAccuracy = -1;
|
|
|
break;
|
|
|
end
|
|
|
end
|
|
|
|
|
|
|
|
|
RT = GetSecs() - startTime;
|
|
|
|
|
|
|
|
|
if subject_choice == correct_choice
|
|
|
trlselectedStim = 1;
|
|
|
else
|
|
|
trlselectedStim = 0;
|
|
|
end
|
|
|
|
|
|
|
|
|
Screen('TextSize',wPtr,70);
|
|
|
Screen('TextFont',wPtr,'Times');
|
|
|
Screen('TextStyle',wPtr,1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trial_ids = [trial_ids; trial_index];
|
|
|
|
|
|
trial_stimuli = [trial_stimuli; randomized_trialList(trial_index,:)];
|
|
|
|
|
|
trial_response = [trial_response; trlResponse];
|
|
|
|
|
|
trial_RT = [trial_RT; RT];
|
|
|
|
|
|
trial_selectedStim = [trial_selectedStim; trlselectedStim];
|
|
|
|
|
|
trial_accuracy = [trial_accuracy; trlAccuracy];
|
|
|
|
|
|
|
|
|
trial_index = trial_index + 1;
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
if B1block_index >= numB1Blocks
|
|
|
B1Complete = true;
|
|
|
end
|
|
|
end
|
|
|
|
|
|
|
|
|
|