|
|
|
|
|
|
|
|
|
|
|
Btrials_perType = 5;
|
|
|
TotalTrial = 16 * Btrials_perType;
|
|
|
|
|
|
|
|
|
Ayi_trials = repmat([ A,y,i ], Btrials_perType, 1);
|
|
|
Ayc_trials = repmat([ A,y,c ], Btrials_perType, 1);
|
|
|
Abi_trials = repmat([ A,b,i ], Btrials_perType, 1);
|
|
|
Abc_trials = repmat([ A,b,c ], Btrials_perType, 1);
|
|
|
Byi_trials = repmat([ B,y,i ], Btrials_perType, 1);
|
|
|
Byc_trials = repmat([ B,y,c ], Btrials_perType, 1);
|
|
|
Bbi_trials = repmat([ B,b,i ], Btrials_perType, 1);
|
|
|
Bbc_trials = repmat([ B,b,c ], Btrials_perType, 1);
|
|
|
Cyi_trials = repmat([ C,y,i ], Btrials_perType, 1);
|
|
|
Cyc_trials = repmat([ C,y,c ], Btrials_perType, 1);
|
|
|
Cbi_trials = repmat([ C,b,i ], Btrials_perType, 1);
|
|
|
Cbc_trials = repmat([ C,b,c ], Btrials_perType, 1);
|
|
|
Dyi_trials = repmat([ D,y,i ], Btrials_perType, 1);
|
|
|
Dyc_trials = repmat([ D,y,c ], Btrials_perType, 1);
|
|
|
Dbi_trials = repmat([ D,b,i ], Btrials_perType, 1);
|
|
|
Dbc_trials = repmat([ D,b,c ], Btrials_perType, 1);
|
|
|
|
|
|
|
|
|
|
|
|
Rich=[1;1;1;1;1];
|
|
|
Lean=[0;0;0;0;0];
|
|
|
Sparse=[0;0;0;0;0];
|
|
|
|
|
|
Ayc_trials=[Ayc_trials, Rich];
|
|
|
Abc_trials=[Abc_trials, Rich];
|
|
|
Ayi_trials=[Ayi_trials, Rich];
|
|
|
Abi_trials=[Abi_trials, Rich];
|
|
|
|
|
|
Byc_trials=[Byc_trials, Rich];
|
|
|
Bbc_trials=[Bbc_trials, Rich];
|
|
|
Byi_trials=[Byi_trials, Lean];
|
|
|
Bbi_trials=[Bbi_trials, Lean];
|
|
|
|
|
|
Cyc_trials=[Cyc_trials, Lean];
|
|
|
Cbc_trials=[Cbc_trials, Lean];
|
|
|
Cyi_trials=[Cyi_trials, Rich];
|
|
|
Cbi_trials=[Cbi_trials, Rich];
|
|
|
|
|
|
Dyc_trials=[Dyc_trials, Sparse];
|
|
|
Dbc_trials=[Dbc_trials, Sparse];
|
|
|
Dyi_trials=[Dyi_trials, Sparse];
|
|
|
Dbi_trials=[Dbi_trials, Sparse];
|
|
|
|
|
|
|
|
|
B_trialList = [Ayi_trials; Ayc_trials; Abi_trials; Abc_trials; Byi_trials; Byc_trials; Bbi_trials; Bbc_trials;...
|
|
|
Cyi_trials; Cyc_trials; Cbi_trials; Cbc_trials; Dyi_trials; Dyc_trials; Dbi_trials; Dbc_trials;];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
B_images = [];
|
|
|
B_images{1}{1} = imread(['./images/',S1,'_Y.bmp']);
|
|
|
B_images{1}{2} = imread(['./images/',S1,'_B.bmp']);
|
|
|
B_images{1}{3} = imread(['./images/',S1,'_1.bmp']);
|
|
|
B_images{1}{4} = imread(['./images/',S1,'_0.bmp']);
|
|
|
B_images{1}{5} = imread(['./images/',S1,'_m1.bmp']);
|
|
|
B_images{1}{6} = imread(['./images/',S1,'.bmp']);
|
|
|
B_images{2}{1} = imread(['./images/',S2,'_Y.bmp']);
|
|
|
B_images{2}{2} = imread(['./images/',S2,'_B.bmp']);
|
|
|
B_images{2}{3} = imread(['./images/',S2,'_1.bmp']);
|
|
|
B_images{2}{4} = imread(['./images/',S2,'_0.bmp']);
|
|
|
B_images{2}{5} = imread(['./images/',S2,'_m1.bmp']);
|
|
|
B_images{2}{6} = imread(['./images/',S2,'.bmp']);
|
|
|
B_images{3}{1} = imread(['./images/',S3,'_Y.bmp']);
|
|
|
B_images{3}{2} = imread(['./images/',S3,'_B.bmp']);
|
|
|
B_images{3}{3} = imread(['./images/',S3,'_1.bmp']);
|
|
|
B_images{3}{4} = imread(['./images/',S3,'_0.bmp']);
|
|
|
B_images{3}{5} = imread(['./images/',S3,'_m1.bmp']);
|
|
|
B_images{3}{6} = imread(['./images/',S3,'.bmp']);
|
|
|
B_images{4}{1} = imread(['./images/',S4,'_Y.bmp']);
|
|
|
B_images{4}{2} = imread(['./images/',S4,'_B.bmp']);
|
|
|
B_images{4}{3} = imread(['./images/',S4,'_1.bmp']);
|
|
|
B_images{4}{4} = imread(['./images/',S4,'_0.bmp']);
|
|
|
B_images{4}{5} = imread(['./images/',S4,'_m1.bmp']);
|
|
|
B_images{4}{6} = imread(['./images/',S4,'.bmp']);
|
|
|
|
|
|
|
|
|
B_images_rand=[];
|
|
|
randx_i=randperm(size(B_images,2));
|
|
|
count=1;
|
|
|
for randx=1:size(B_images,2)
|
|
|
B_images_rand{count}{1} = B_images{randx_i(randx)}{1};
|
|
|
B_images_rand{count}{2} = B_images{randx_i(randx)}{2};
|
|
|
B_images_rand{count}{3} = B_images{randx_i(randx)}{3};
|
|
|
B_images_rand{count}{4} = B_images{randx_i(randx)}{4};
|
|
|
B_images_rand{count}{5} = B_images{randx_i(randx)}{5};
|
|
|
B_images_rand{count}{6} = B_images{randx_i(randx)}{6};
|
|
|
count=count+1;
|
|
|
end
|
|
|
|
|
|
|
|
|
B_textures = [];
|
|
|
for BTexture_index = 1 : size(B_images_rand, 2)
|
|
|
for color_index = 1 : size(B_images_rand{BTexture_index}, 2)
|
|
|
B_textures{BTexture_index}{color_index} = Screen('MakeTexture', wPtr, B_images_rand{BTexture_index}{color_index});
|
|
|
end
|
|
|
end
|
|
|
global B_textures
|
|
|
|
|
|
|
|
|
textures = [];
|
|
|
textures(A,y,i) = B_textures{1}{1};
|
|
|
textures(A,y,c) = B_textures{1}{1};
|
|
|
textures(A,b,i) = B_textures{1}{2};
|
|
|
textures(A,b,c) = B_textures{1}{2};
|
|
|
textures(B,y,i) = B_textures{2}{1};
|
|
|
textures(B,y,c) = B_textures{2}{1};
|
|
|
textures(B,b,i) = B_textures{2}{2};
|
|
|
textures(B,b,c) = B_textures{2}{2};
|
|
|
textures(C,y,i) = B_textures{3}{1};
|
|
|
textures(C,y,c) = B_textures{3}{1};
|
|
|
textures(C,b,i) = B_textures{3}{2};
|
|
|
textures(C,b,c) = B_textures{3}{2};
|
|
|
textures(D,y,i) = B_textures{4}{1};
|
|
|
textures(D,y,c) = B_textures{4}{1};
|
|
|
textures(D,b,i) = B_textures{4}{2};
|
|
|
textures(D,b,c) = B_textures{4}{2};
|
|
|
|
|
|
|
|
|
FBtextures(A,1) = B_textures{1}{3};
|
|
|
FBtextures(A,2) = B_textures{1}{4};
|
|
|
FBtextures(B,1) = B_textures{2}{3};
|
|
|
FBtextures(B,2) = B_textures{2}{4};
|
|
|
FBtextures(C,1) = B_textures{3}{3};
|
|
|
FBtextures(C,2) = B_textures{3}{4};
|
|
|
FBtextures(D,1) = B_textures{4}{3};
|
|
|
FBtextures(D,2) = B_textures{4}{4};
|
|
|
|
|
|
|
|
|
|
|
|
BComplete = false;
|
|
|
numBBlocks = 1;
|
|
|
Bblock_index = 0;
|
|
|
no_response = false;
|
|
|
|
|
|
|
|
|
while ~BComplete
|
|
|
|
|
|
|
|
|
trial_ids = [];
|
|
|
|
|
|
trial_stimuli = [];
|
|
|
|
|
|
trial_response = [];
|
|
|
|
|
|
trial_selectedStim = [];
|
|
|
|
|
|
trial_RT = [];
|
|
|
|
|
|
trial_accuracy = [];
|
|
|
|
|
|
trial_feedback = [];
|
|
|
|
|
|
|
|
|
Bblock_index = Bblock_index + 1;
|
|
|
|
|
|
random_index = randperm(size(B_trialList, 1));
|
|
|
randomized_trialList = B_trialList(random_index,:);
|
|
|
|
|
|
trial_index = 1;
|
|
|
while trial_index <= TotalTrial
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
type = randomized_trialList(trial_index, 1);
|
|
|
color = randomized_trialList(trial_index, 2);
|
|
|
congru = randomized_trialList(trial_index, 3);
|
|
|
TRIALCODE=strcat(num2str(color),num2str(congru),num2str(type));
|
|
|
TRIALTRIGGER=str2double(TRIALCODE);
|
|
|
|
|
|
|
|
|
if color==1
|
|
|
correct_choice = left_button;
|
|
|
elseif color==2
|
|
|
correct_choice = right_button;
|
|
|
end
|
|
|
|
|
|
if color==1 && congru==1
|
|
|
rect = left_rect;
|
|
|
elseif color==1 && congru==2
|
|
|
rect = right_rect;
|
|
|
elseif color==2 && congru==1
|
|
|
rect = right_rect;
|
|
|
elseif color==2 && congru==2
|
|
|
rect = left_rect;
|
|
|
end
|
|
|
|
|
|
|
|
|
Screen('DrawTexture', wPtr, textures(type,color,congru), [], rect);
|
|
|
Screen(wPtr, 'Flip');
|
|
|
|
|
|
err=DaqDOut(DAQindx, 0, TRIALTRIGGER); WaitSecs(0.05);
|
|
|
|
|
|
|
|
|
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 = 101;
|
|
|
break;
|
|
|
elseif keyCode(right_button) && right_button==correct_choice
|
|
|
subject_choice = right_button;
|
|
|
no_response = false;
|
|
|
trlResponse = 1;
|
|
|
trlAccuracy = 1;
|
|
|
RESPTRIGGER = 102;
|
|
|
break;
|
|
|
elseif keyCode(left_button) && left_button~=correct_choice
|
|
|
subject_choice = left_button;
|
|
|
no_response = false;
|
|
|
trlResponse = 1;
|
|
|
trlAccuracy = 0;
|
|
|
RESPTRIGGER = 103;
|
|
|
break;
|
|
|
elseif keyCode(right_button) && right_button~=correct_choice
|
|
|
subject_choice = right_button;
|
|
|
no_response = false;
|
|
|
trlResponse = 1;
|
|
|
trlAccuracy = 0;
|
|
|
RESPTRIGGER = 104;
|
|
|
break;
|
|
|
end
|
|
|
elseif(GetSecs-wait_stamp) > RESPDEADLINE,
|
|
|
subject_choice = no_response;
|
|
|
no_response = true;
|
|
|
trlResponse = -1;
|
|
|
trlAccuracy = -1;
|
|
|
RESPTRIGGER = 105;
|
|
|
break;
|
|
|
else
|
|
|
RESPTRIGGER = 249;
|
|
|
end
|
|
|
end
|
|
|
|
|
|
|
|
|
err=DaqDOut(DAQindx, 0, RESPTRIGGER); WaitSecs(0.05)
|
|
|
RT = GetSecs() - startTime - 0.05;
|
|
|
WaitSecs(0.12 + rand/FUDGE);
|
|
|
err=DaqDOut(DAQindx, 0, 0);
|
|
|
|
|
|
|
|
|
if subject_choice == correct_choice
|
|
|
trlselectedStim = 1;
|
|
|
|
|
|
reward_contingency = randomized_trialList(trial_index, 4);
|
|
|
else
|
|
|
trlselectedStim = 0;
|
|
|
end
|
|
|
|
|
|
WaitSecs(0.005);
|
|
|
|
|
|
|
|
|
Screen('TextSize',wPtr,60);
|
|
|
Screen('TextFont',wPtr,'Times');
|
|
|
Screen('TextStyle',wPtr,1);
|
|
|
if no_response == true
|
|
|
Screen('TextColor',wPtr,[200 0 0]);
|
|
|
reward_text = 'No Response. -3';
|
|
|
trlFeedback = -3;
|
|
|
FixRewardProbs = 1;
|
|
|
reward = 0;
|
|
|
FBTRIGGER=7;
|
|
|
elseif no_response == false
|
|
|
if trlAccuracy == 0
|
|
|
Screen('TextColor',wPtr,[255 0 0]);
|
|
|
reward_text = 'ERROR! -3';
|
|
|
trlFeedback = -3;
|
|
|
FixRewardProbs = 1;
|
|
|
reward = 0;
|
|
|
FBTRIGGER=6;
|
|
|
else
|
|
|
if reward_contingency ==1
|
|
|
Screen('TextColor',wPtr,[0 255 0]);
|
|
|
FB=FBtextures(type,1);
|
|
|
trlFeedback = 1;
|
|
|
FixRewardProbs = 0;
|
|
|
reward=1;
|
|
|
FBTRIGGER=8;
|
|
|
elseif reward_contingency ==0
|
|
|
Screen('TextColor',wPtr,[0 0 255]);
|
|
|
FB=FBtextures(type,2);
|
|
|
trlFeedback = 0;
|
|
|
FixRewardProbs = 0;
|
|
|
reward = 0;
|
|
|
FBTRIGGER=9;
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
|
|
|
if FixRewardProbs == 1
|
|
|
|
|
|
randomized_trialList(end+1, :) = randomized_trialList(trial_index, :);
|
|
|
TotalTrial=TotalTrial+1;
|
|
|
FixRewardProbs=0;
|
|
|
end
|
|
|
|
|
|
|
|
|
if trlAccuracy ~= 1
|
|
|
DrawFormattedText(wPtr,reward_text,'center','center');
|
|
|
Screen(wPtr, 'Flip');
|
|
|
|
|
|
|
|
|
err=DaqDOut(DAQindx, 0, FBTRIGGER); WaitSecs(0.05);
|
|
|
elseif trlAccuracy == 1
|
|
|
Screen('DrawTexture', wPtr, FB, [], rect);
|
|
|
Screen(wPtr, 'Flip');
|
|
|
|
|
|
err=DaqDOut(DAQindx, 0, FBTRIGGER); WaitSecs(0.05);
|
|
|
end
|
|
|
clear FBTRIGGER TRIALTRIGGER RESPTRIGGER FB;
|
|
|
|
|
|
|
|
|
WaitSecs(0.95);
|
|
|
err=DaqDOut(DAQindx, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_feedback = [trial_feedback; trlFeedback];
|
|
|
|
|
|
|
|
|
trial_index = trial_index + 1;
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
data_block = zeros(size(trial_ids, 1), 1) + Bblock_index;
|
|
|
|
|
|
data_block = [data_block, trial_ids, trial_stimuli, trial_response, trial_selectedStim, trial_RT, trial_accuracy, trial_feedback];
|
|
|
|
|
|
|
|
|
if Bblock_index >= numBBlocks
|
|
|
BComplete = true;
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
save([datadir 'M' num2str(subject_number),'_B',num2str(Block),'_CC_train.mat'],'data_block','randx_i');
|
|
|
|