%*****TESTING STIM SETUP**** % the number of trials of each stim pairing Btrials_perType = 4; % 4*12= 48 % build the trial list 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); % bind all the trial types to define the block's trials 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;]; % load the textures into an array mapping onto corresponding choice ids textures = []; textures(A) = B_textures{1}{6}; % {A,B,C,D} textures(B) = B_textures{2}{6}; textures(C) = B_textures{3}{6}; textures(D) = B_textures{4}{6}; %****BEGIN TEST***** BComplete = false; numBBlocks = 1; %*******Determines # of Blocks******* Bblock_index = 0; no_response = false; % loop through the Test phase while ~BComplete % track trial ids trial_ids = []; % track trial type trial_stimuli = []; %track response trial_response = []; % track which stim was choosen trial_selectedStim = []; % track the rt trial_RT = []; % track the accuracy trial_accuracy = []; % increment the block index 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 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'); % show the fixation for 1 sec WaitSecs(1); % get the current trial's info L = randomized_trialList_test(trial_index, 1); R = randomized_trialList_test(trial_index, 2); TRIALCODE=strcat(num2str(L),num2str(R)); TRIALTRIGGER=str2num(TRIALCODE); % define overall accuracy if L TSTDEADLINE, subject_choice = no_response; no_response = true; trlResponse = -1; trlAccuracy = -1; RESPTRIGGER = 5; break; end end %io64(ioObject,LTP1address,RESPTRIGGER); WaitSecs(.05); io64(ioObject,LTP1address,0); err=DaqDOut(DAQindx, 0, RESPTRIGGER); WaitSecs(0.05); clear TRIALCODE RESPTRIGGER; % stop the trial timer RT = GetSecs() - startTime; % determine which button they pressed trlselectedStim = subject_choice; % determine the reward feedback Screen('TextSize',wPtr,60); Screen('TextFont',wPtr,'Times'); Screen('TextStyle',wPtr,1); % Store the trial data % % update the trial number list trial_ids = [trial_ids; trial_index]; % store the trial stimuli trial_stimuli = [trial_stimuli; TRIALTRIGGER]; %store response trial_response = [trial_response; trlResponse]; % store the RT trial_RT = [trial_RT; RT]; % store the subject's choice trial_selectedStim = [trial_selectedStim; trlselectedStim]; % store accuracy independent of feedback trial_accuracy = [trial_accuracy; trlAccuracy]; % increment the trial index trial_index = trial_index + 1; end % mark each trial with the block number data_test = zeros(size(trial_ids, 1), 1) + Bblock_index; % collate all the data from the block data_test = [data_test, trial_ids, trial_stimuli, trial_response, trial_selectedStim, trial_RT, trial_accuracy]; % check to see if B is done if Bblock_index >= numBBlocks BComplete = true; end end % Save data save([datadir 'M' num2str(subject_number),'_B',num2str(Block),'_CC_test.mat'], 'data_test'); % *****END OF B1_test*****