|
|
|
|
|
|
| practrials_perType = 2;
|
|
|
|
|
|
|
| Ayi_trials = repmat([ A,y,i ], practrials_perType, 1);
|
| Ayc_trials = repmat([ A,y,c ], practrials_perType, 1);
|
| Abi_trials = repmat([ A,b,i ], practrials_perType, 1);
|
| Abc_trials = repmat([ A,b,c ], practrials_perType, 1);
|
| Byi_trials = repmat([ B,y,i ], practrials_perType, 1);
|
| Byc_trials = repmat([ B,y,c ], practrials_perType, 1);
|
| Bbi_trials = repmat([ B,b,i ], practrials_perType, 1);
|
| Bbc_trials = repmat([ B,b,c ], practrials_perType, 1);
|
|
|
|
|
| practice_trialList = [Ayi_trials; Ayc_trials; Abi_trials; Abc_trials; Byi_trials; Byc_trials; Bbi_trials; Bbc_trials];
|
|
|
|
|
| prac_images = [];
|
| prac_images{1}{1} = imread('./images/1_Y.bmp');
|
| prac_images{1}{2} = imread('./images/1_B.bmp');
|
| prac_images{1}{3} = imread('./images/1_1.bmp');
|
| prac_images{1}{4} = imread('./images/1_0.bmp');
|
| prac_images{1}{5} = imread('./images/1.bmp');
|
| prac_images{2}{1} = imread('./images/2_Y.bmp');
|
| prac_images{2}{2} = imread('./images/2_B.bmp');
|
| prac_images{2}{3} = imread('./images/2_1.bmp');
|
| prac_images{2}{4} = imread('./images/2_0.bmp');
|
| prac_images{2}{5} = imread('./images/2.bmp');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| prac_textures = [];
|
| for pracTexture_index = 1 : size(prac_images, 2)
|
| for color_index = 1 : size(prac_images{pracTexture_index}, 2)
|
| prac_textures{pracTexture_index}{color_index} = Screen('MakeTexture', wPtr, prac_images{pracTexture_index}{color_index});
|
| end
|
| end
|
|
|
|
|
| textures = [];
|
| textures(A,y,i) = prac_textures{1}{1};
|
| textures(A,y,c) = prac_textures{1}{1};
|
| textures(A,b,i) = prac_textures{1}{2};
|
| textures(A,b,c) = prac_textures{1}{2};
|
| textures(B,y,i) = prac_textures{2}{1};
|
| textures(B,y,c) = prac_textures{2}{1};
|
| textures(B,b,i) = prac_textures{2}{2};
|
| textures(B,b,c) = prac_textures{2}{2};
|
|
|
| FBtextures(A,1) = prac_textures{1}{3};
|
| FBtextures(A,2) = prac_textures{1}{4};
|
| FBtextures(B,1) = prac_textures{2}{3};
|
| FBtextures(B,2) = prac_textures{2}{4};
|
|
|
|
|
| prac_contingencies = [];
|
| prac_contingencies(A,y,i) = 0.9;
|
| prac_contingencies(A,y,c) = 0.9;
|
| prac_contingencies(A,b,i) = 0.9;
|
| prac_contingencies(A,b,c) = 0.9;
|
| prac_contingencies(B,y,i) = 0.1;
|
| prac_contingencies(B,y,c) = 0.1;
|
| prac_contingencies(B,b,i) = 0.1;
|
| prac_contingencies(B,b,c) = 0.1;
|
|
|
|
|
|
|
| practiceComplete = false;
|
| numPracticeBlocks = 1;
|
| pracblock_index = 0;
|
| no_response = false;
|
|
|
|
|
| while ~practiceComplete
|
|
|
|
|
| trial_ids = [];
|
|
|
| trial_stimuli = [];
|
|
|
| trial_response = [];
|
|
|
| trial_selectedStim = [];
|
|
|
| trial_RT = [];
|
|
|
| trial_accuracy = [];
|
|
|
| trial_feedback = [];
|
|
|
|
|
| pracblock_index = pracblock_index + 1;
|
|
|
| random_index = randperm(size(practice_trialList, 1));
|
| randomized_trialList = practice_trialList(random_index,:);
|
|
|
| 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);
|
|
|
|
|
| type = randomized_trialList(trial_index, 1);
|
| color = randomized_trialList(trial_index, 2);
|
| congru = randomized_trialList(trial_index, 3);
|
|
|
|
|
|
|
|
|
|
|
| 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');
|
|
|
|
|
| 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) > PREPRACT_RESPDEADLINE,
|
| subject_choice = no_response;
|
| no_response = true;
|
| trlResponse = -1;
|
| trlAccuracy = -1;
|
| break;
|
| end
|
| end
|
|
|
|
|
| RT = GetSecs() - startTime;
|
|
|
|
|
| if subject_choice == correct_choice
|
| trlselectedStim = 1;
|
|
|
| reward_contingency = prac_contingencies(type,color,congru);
|
| else
|
| trlselectedStim = 0;
|
| end
|
|
|
|
|
| Screen('TextSize',wPtr,70);
|
| Screen('TextFont',wPtr,'Times');
|
| Screen('TextStyle',wPtr,1);
|
| if no_response == true
|
| Screen('TextColor',wPtr,[255 0 0]);
|
| reward_text = 'No Response. -3';
|
| trlFeedback = -3;
|
|
|
|
|
| elseif no_response == false
|
| if trlAccuracy == 0
|
| Screen('TextColor',wPtr,[255 0 0]);
|
| reward_text = 'ERROR! -3';
|
| trlFeedback = -3;
|
|
|
|
|
| else
|
| if rand(1) < reward_contingency
|
| Screen('TextColor',wPtr,[0 255 0]);
|
|
|
| FB=FBtextures(type,1);
|
| trlFeedback = 1;
|
|
|
|
|
| else
|
| reward = 0;
|
| Screen('TextColor',wPtr,[0 0 255]);
|
|
|
| FB=FBtextures(type,2);
|
| trlFeedback = 0;
|
|
|
|
|
| end
|
| end
|
| end
|
|
|
|
|
| if trlAccuracy ~= 1
|
| DrawFormattedText(wPtr,reward_text,'center','center');
|
| Screen(wPtr, 'Flip');
|
| elseif trlAccuracy == 1
|
| Screen('DrawTexture', wPtr, FB, [], rect);
|
| Screen(wPtr, 'Flip');
|
| end
|
|
|
|
|
| WaitSecs(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_feedback = [trial_feedback; trlFeedback];
|
|
|
|
|
| trial_index = trial_index + 1;
|
|
|
| end
|
|
|
|
|
| if pracblock_index >= numPracticeBlocks
|
| practiceComplete = true;
|
| end
|
| end
|
|
|
| |