% Pipeline including practice, MAT pre, checkerboard and MAT post assessment

%% enter subject info

subj = 'Sub01_v1';

%% add PTB

addpath(genpath('/Users/Shared/Psychtoolbox/'));

%% practice checkerboard task

experimentFolder = '/Volumes/MyPassport3TB/RDM_Distract/CheckerContrastComp_V11/';
addpath(genpath(experimentFolder));

cd(experimentFolder);

% set up experiment
Screen('Preference', 'SkipSyncTests', 1);
oldLevel = Screen('Preference', 'Verbosity', 4); % output debugging info
PsychDebugWindowConfiguration(0,0.3)

subjectsPath = [subj '_' datestr(now, 'dd-mm-yyyy_HH-MM-SS') '/']; mkdir(subjectsPath);

checkerInfo = [];
[checkerInfo] = checkerParameters_170213;

DEBUG = 1; opacity = 1;
checkerBoard_Practice_170328(subjectsPath, checkerInfo, DEBUG, opacity)

%% practice MAT task

pn.workingFolder = '/Volumes/MyPassport3TB/RDM_Distract/MAT_V2/';

addpath(genpath([pn.workingFolder, 'functions/']));
addpath(genpath([pn.workingFolder, 'dotsx/']));

Screen('Preference', 'SkipSyncTests', 1);

dotInfo = createDotInfo_JQK_170327;
dotInfo.dataDir = [pn.workingFolder, 'data/'];

cursubj = [subj, '_practice'];
DEBUG = 1; opacity = 1;
MAT_practice_170328(dotInfo, cursubj, 0, DEBUG, opacity)

%% run MAT Task (Pre-CB) 

% add dotsx functions

pn.workingFolder = '/Volumes/MyPassport3TB/RDM_Distract/MAT_V2/';

addpath(genpath([pn.workingFolder, 'functions/']));
addpath(genpath([pn.workingFolder, 'dotsx/']));

Screen('Preference', 'SkipSyncTests', 1);

dotInfo = createDotInfo_JQK_170327;
dotInfo.dataDir = [pn.workingFolder, 'data/']; mkdir(dotInfo.dataDir);

cursubj = [subj, '_PreMAT'];
DEBUG = 1; opacity = 1;
dotsExperiment_JQK_170327(dotInfo, cursubj, 0, DEBUG, opacity)

%% set up and run checkerboard

experimentFolder = '/Volumes/MyPassport3TB/RDM_Distract/CheckerContrastComp_V11/';
addpath(genpath(experimentFolder));

cd(experimentFolder);

% set up experiment
Screen('Preference', 'SkipSyncTests', 1);
oldLevel = Screen('Preference', 'Verbosity', 4); % output debugging info
PsychDebugWindowConfiguration(0,0.3)

subjectsPath = [subj '_' datestr(now, 'dd-mm-yyyy_HH-MM-SS') '/']; mkdir(subjectsPath);

checkerInfo = [];
[checkerInfo] = checkerParameters_170213;

DEBUG = 1; verbosity = 1;
checkerContrastComp_JQK_170213(checkerInfo, subjectsPath, DEBUG, verbosity)

%% run MAT Task (post-CB)

pn.workingFolder = '/Volumes/MyPassport3TB/RDM_Distract/MAT_V2/';
addpath(genpath([pn.workingFolder, 'functions/']));
addpath(genpath([pn.workingFolder, 'dotsx/']));
cd(pn.workingFolder);

Screen('Preference', 'SkipSyncTests', 1);

dotInfo = createDotInfo_JQK_170327;
dotInfo.dataDir = [pn.workingFolder, 'data/'];

cursubj = [subj, '_PostMAT'];
DEBUG = 1; opacity = 1;
dotsExperiment_JQK_170327(dotInfo, cursubj, 0, DEBUG, opacity)