|
|
|
|
|
|
| Btrials_perType = 4;
|
|
|
|
|
| AB_trials = repmat([ A,B ], Btrials_perType, 1);
|
| BA_trials = repmat([ B,A ], Btrials_perType, 1);
|
| AC_trials = repmat([ A,C ], Btrials_perType, 1);
|
| CA_trials = repmat([ C,A ], Btrials_perType, 1);
|
| AD_trials = repmat([ A,D ], Btrials_perType, 1);
|
| DA_trials = repmat([ D,A ], Btrials_perType, 1);
|
| BC_trials = repmat([ B,C ], Btrials_perType, 1);
|
| CB_trials = repmat([ C,B ], Btrials_perType, 1);
|
| BD_trials = repmat([ B,D ], Btrials_perType, 1);
|
| DB_trials = repmat([ D,B ], Btrials_perType, 1);
|
| CD_trials = repmat([ C,D ], Btrials_perType, 1);
|
| DC_trials = repmat([ D,C ], Btrials_perType, 1);
|
|
|
|
|
| B_trialList_test = [AB_trials; BA_trials; AC_trials; CA_trials; AD_trials; DA_trials; BC_trials; CB_trials;...
|
| BD_trials; DB_trials; CD_trials; DC_trials;];
|
|
|
|
|
| textures = [];
|
| textures(A) = B_textures{1}{6};
|
| textures(B) = B_textures{2}{6};
|
| textures(C) = B_textures{3}{6};
|
| textures(D) = B_textures{4}{6};
|
|
|
|
|
|
|
| BComplete = false;
|
| numBBlocks = 1;
|
| Bblock_index = 0;
|
| no_response = false;
|
|
|
|
|
| while ~BComplete
|
|
|
|
|
| trial_ids = [];
|
|
|
| trial_stimuli = [];
|
|
|
| trial_response = [];
|
|
|
| trial_selectedStim = [];
|
|
|
| trial_RT = [];
|
|
|
| trial_accuracy = [];
|
|
|
|
|
| Bblock_index = Bblock_index + 1;
|
|
|
| random_index = randperm(size(B_trialList_test, 1));
|
| randomized_trialList_test = B_trialList_test(random_index,:);
|
|
|
| trial_index = 1;
|
| while trial_index <= size(randomized_trialList_test, 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_test(trial_index, 1);
|
| R = randomized_trialList_test(trial_index, 2);
|
| TRIALCODE=strcat(num2str(L),num2str(R));
|
| TRIALTRIGGER=str2num(TRIALCODE);
|
|
|
|
|
| if L<R
|
| correct_choice = left_button;
|
| elseif R<L
|
| correct_choice = right_button;
|
| end
|
|
|
|
|
| Screen('DrawTexture', wPtr, textures(L), [], left_rect_test);
|
| Screen('DrawTexture', wPtr, textures(R), [], right_rect_test);
|
|
|
| err=DaqDOut(DAQindx, 0, TRIALTRIGGER); WaitSecs(0.05);
|
| 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;
|
| RESPTRIGGER = 1;
|
| break;
|
| elseif keyCode(right_button) && right_button==correct_choice
|
| subject_choice = right_button;
|
| no_response = false;
|
| trlResponse = 1;
|
| trlAccuracy = 1;
|
| RESPTRIGGER = 2;
|
| break;
|
| elseif keyCode(left_button) && left_button~=correct_choice
|
| subject_choice = left_button;
|
| no_response = false;
|
| trlResponse = 1;
|
| trlAccuracy = 0;
|
| RESPTRIGGER = 3;
|
| break;
|
| elseif keyCode(right_button) && right_button~=correct_choice
|
| subject_choice = right_button;
|
| no_response = false;
|
| trlResponse = 1;
|
| trlAccuracy = 0;
|
| RESPTRIGGER = 4;
|
| break;
|
| end
|
| elseif(GetSecs-wait_stamp) > TSTDEADLINE,
|
| subject_choice = no_response;
|
| no_response = true;
|
| trlResponse = -1;
|
| trlAccuracy = -1;
|
| RESPTRIGGER = 5;
|
| break;
|
| end
|
| end
|
|
|
| err=DaqDOut(DAQindx, 0, RESPTRIGGER); WaitSecs(0.05);
|
| clear TRIALCODE RESPTRIGGER;
|
|
|
| RT = GetSecs() - startTime;
|
|
|
|
|
| trlselectedStim = subject_choice;
|
|
|
|
|
| Screen('TextSize',wPtr,60);
|
| Screen('TextFont',wPtr,'Times');
|
| Screen('TextStyle',wPtr,1);
|
|
|
|
|
|
|
|
|
| trial_ids = [trial_ids; trial_index];
|
|
|
| trial_stimuli = [trial_stimuli; TRIALTRIGGER];
|
|
|
| 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
|
|
|
|
|
| data_test = zeros(size(trial_ids, 1), 1) + Bblock_index;
|
|
|
| data_test = [data_test, trial_ids, trial_stimuli, trial_response, trial_selectedStim, trial_RT, trial_accuracy];
|
|
|
|
|
| if Bblock_index >= numBBlocks
|
| BComplete = true;
|
| end
|
| end
|
|
|
|
|
| save([datadir 'M' num2str(subject_number),'_B',num2str(Block),'_CC_test.mat'], 'data_test');
|
|
|
| |