|
|
|
|
|
|
|
|
|
|
|
|
|
|
clc; |
|
|
|
|
|
clear all; |
|
|
close all; |
|
|
|
|
|
|
|
|
|
|
|
disp_struct = struct(); |
|
|
|
|
|
task_struct = struct(); |
|
|
|
|
|
|
|
|
allTrainTrials = []; |
|
|
allTestTrials = []; |
|
|
|
|
|
task_struct.startTime = GetSecs(); |
|
|
|
|
|
|
|
|
RandStream.setGlobalStream(RandStream('mt19937ar','seed',sum(100*clock))); |
|
|
|
|
|
|
|
|
experiemtn_start = GetSecs(); |
|
|
|
|
|
|
|
|
subject_number = input('Enter the subject number :\n','s'); |
|
|
session = input('Is this the first or second visit? (enter 1 or 2):\n','s'); session=str2num(session); |
|
|
|
|
|
SCREENS=2; |
|
|
|
|
|
file_name = [num2str(subject_number) '_S' num2str(session) '_' datestr(now, 'mm-dd-yyyy_HH-MM-SS')]; |
|
|
|
|
|
|
|
|
|
|
|
addpath(genpath('C:\Users\GA217B\Desktop\PDDys Suite\JoyMEX')); |
|
|
JoyMEX('init',0); |
|
|
|
|
|
LEFTKEY=5; |
|
|
RIGHTKEY=6; |
|
|
|
|
|
ioObject = io64; |
|
|
LTP1address = hex2dec('C050'); |
|
|
status = io64(ioObject); |
|
|
|
|
|
|
|
|
|
|
|
HideCursor(); |
|
|
|
|
|
|
|
|
Screen('Preference', 'SkipSyncTests', 1); |
|
|
|
|
|
ListenChar(2); |
|
|
|
|
|
KbName('UnifyKeyNames'); |
|
|
|
|
|
|
|
|
[disp_struct, task_struct] = taskInit(disp_struct, task_struct, SCREENS, session, LEFTKEY, RIGHTKEY); |
|
|
|
|
|
|
|
|
|
|
|
train_Inst1(disp_struct); |
|
|
train_Inst2(disp_struct); |
|
|
|
|
|
instruct_slide = Screen('MakeTexture', disp_struct.wPtr, imread(['../images/Slide1.jpg'])); |
|
|
Screen('DrawTexture', disp_struct.wPtr, instruct_slide); |
|
|
Screen(disp_struct.wPtr, 'Flip');KbWait([],3); |
|
|
|
|
|
train_Inst3(disp_struct); |
|
|
|
|
|
instruct_slide = Screen('MakeTexture', disp_struct.wPtr, imread(['../images/Slide2.jpg'])); |
|
|
Screen('DrawTexture', disp_struct.wPtr, instruct_slide); |
|
|
Screen(disp_struct.wPtr, 'Flip');KbWait([],3); |
|
|
instruct_slide = Screen('MakeTexture', disp_struct.wPtr, imread(['../images/Slide3.jpg'])); |
|
|
Screen('DrawTexture', disp_struct.wPtr, instruct_slide); |
|
|
Screen(disp_struct.wPtr, 'Flip');KbWait([],3); |
|
|
|
|
|
train_Inst4(disp_struct); |
|
|
|
|
|
instruct_slide = Screen('MakeTexture', disp_struct.wPtr, imread(['../images/Slide4.jpg'])); |
|
|
Screen('DrawTexture', disp_struct.wPtr, instruct_slide); |
|
|
Screen(disp_struct.wPtr, 'Flip');KbWait([],3); |
|
|
|
|
|
train_Inst5(disp_struct); |
|
|
runPractice(disp_struct, task_struct, ioObject, LTP1address); |
|
|
train_Inst_Xtra(disp_struct); |
|
|
train_Inst_Xtra2(disp_struct); |
|
|
train_Inst6(disp_struct); |
|
|
|
|
|
|
|
|
|
|
|
trainDone = false; |
|
|
trainBlock = 0; |
|
|
while ~trainDone |
|
|
trainBlock = trainBlock + 1; |
|
|
|
|
|
|
|
|
trainTrials = buildTrainTrials(disp_struct, task_struct); |
|
|
trainTrials(:, task_struct.cBlock) = trainBlock; |
|
|
trainTrials(:, task_struct.cTrialType) = task_struct.TRAIN; |
|
|
|
|
|
|
|
|
tI = 1; |
|
|
while tI <= size(trainTrials,1) |
|
|
trainTrials(tI,:) = runTrainTrial(disp_struct, task_struct, trainTrials(tI,:), ioObject, LTP1address); |
|
|
|
|
|
|
|
|
if trainTrials(tI, task_struct.cTrialCond) == task_struct.FC |
|
|
|
|
|
ncI = find( trainTrials(:, task_struct.cTrialID) == trainTrials(tI, task_struct.cTrialID) & trainTrials(:, task_struct.cTrialCond) == task_struct.NC ); |
|
|
trainTrials(ncI, task_struct.cRespAct) = trainTrials(tI, task_struct.cRespAct) + task_struct.ncAdjust; |
|
|
trainTrials(ncI, task_struct.cRespRew) = trainTrials(tI, task_struct.cRespRew); |
|
|
end |
|
|
|
|
|
|
|
|
if trainTrials(tI, task_struct.cRespAct) ~= disp_struct.RESP_SLOW && (trainTrials(tI, task_struct.cTrialCond) == task_struct.FC || trainTrials(tI, task_struct.cMatch)) |
|
|
tI = tI + 1; |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
allTrainTrials = [allTrainTrials; trainTrials]; |
|
|
|
|
|
|
|
|
if trainBlock >= task_struct.maxTrain |
|
|
trainDone = true; |
|
|
elseif trainBlock >= task_struct.minTrain |
|
|
|
|
|
perfAB = mean(trainTrials(trainTrials(:, task_struct.cS1) == task_struct.sCodes.Afc, task_struct.cRespAct) == task_struct.sCodes.Afc); |
|
|
perfCD = mean(trainTrials(trainTrials(:, task_struct.cS1) == task_struct.sCodes.Cfc, task_struct.cRespAct) == task_struct.sCodes.Cfc); |
|
|
|
|
|
|
|
|
trainDone = perfAB >= task_struct.minPerf(1) && perfCD >= task_struct.minPerf(2); |
|
|
end |
|
|
|
|
|
|
|
|
if ~trainDone |
|
|
trainBreak(disp_struct); |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_Inst1(disp_struct); |
|
|
testTrials = buildTestTrials(disp_struct, task_struct); |
|
|
tI = 1; |
|
|
|
|
|
while tI <= size(testTrials,1) |
|
|
testTrials(tI,:) = runTestTrial(disp_struct, task_struct, testTrials(tI,:), ioObject, LTP1address); |
|
|
|
|
|
|
|
|
if testTrials(tI, task_struct.cRespAct) ~= disp_struct.RESP_SLOW |
|
|
tI = tI + 1; |
|
|
end |
|
|
end |
|
|
|
|
|
allTestTrials = testTrials; |
|
|
|
|
|
|
|
|
taskDone(disp_struct); |
|
|
|
|
|
|
|
|
task_struct.endTime = GetSecs(); |
|
|
task_struct.expTime = task_struct.endTime - task_struct.startTime; |
|
|
task_struct.trainTrials = allTrainTrials; |
|
|
task_struct.testTrials = allTestTrials; |
|
|
|
|
|
save( fullfile('..', 'Data', file_name), 'task_struct', 'disp_struct'); |
|
|
|
|
|
|
|
|
|
|
|
sca; |
|
|
ListenChar(); |
|
|
ShowCursor(); |
|
|
|