%RegistrationWrapper

first_position =0;
last_position =3;

% datasets = [6,7,8,9,10,11,12];
datasets = [2];

% strain_number_directory: 1 is initial strain (PI); 2 is second strain (NG)
last_strain_number = 1;
% strain_number = 2;

% prefixes = {'mov__ ', 'mov starts 318__ ', 'mov2__ ','mov2__ ','mov__ ','mov__ ','mov2__ '};
prefixes = {'mov__ '};

dataset_directories = {'seventh set (late night 9-3 to morning 9-4)',...
    'eighth set (daytime 9-4-14)','ninth set (9-5-14)','tenth set','eleventh set','twelfth set'};

last_dataset = datasets(end);
num_positions = last_position - first_position + 1;

bounds = cell(last_strain_number,last_dataset,num_positions,2);
stacks = cell(last_strain_number,last_dataset,num_positions);

% second positions are offset by one from the usual numbering (i.e.
% position 0 becomes 1 here) to fit with matlab array indexing scheme.

bounds{1,2,1,1} = 60:410;
bounds{1,2,1,2} = 110:360;
bounds{1,2,2,1} = 50:400;
bounds{1,2,2,2} = 100:350;
bounds{1,2,3,1} = 50:400;
bounds{1,2,3,2} = 50:300;
bounds{1,2,4,1} = 50:400;
bounds{1,2,4,2} = 110:360;
bounds{1,2,5,1} = 40:390;
bounds{1,2,5,2} = 110:360;
bounds{1,2,6,1}  = 50:400;
bounds{1,2,6,2} = 110:360;

bounds{1,3,1,1} = 100:450;
bounds{1,3,1,2} = 75:325;
bounds{1,3,2,1} = 110:460;
bounds{1,3,2,2} = 70:320;
bounds{1,3,3,1} = 100:450;
bounds{1,3,3,2} = 60:310;
bounds{1,3,4,1} = 90:440;
bounds{1,3,4,2} = 60:310;
bounds{1,3,5,1} = 85:435;
bounds{1,3,5,2} = 70:320;

bounds{1,4,1,1} = 85:435;
bounds{1,4,1,2} = 185:435;
bounds{1,4,2,1} = 85:435;
bounds{1,4,2,2} = 185:435;
bounds{1,4,3,1} = 80:430;
bounds{1,4,3,2} = 190:440;
bounds{1,4,4,1}  = 40:390;
bounds{1,4,4,2} = 190:440;
bounds{1,4,5,1} = 80:430;
bounds{1,4,5,2} = 192:442;
bounds{1,4,6,1} = 86:436;
bounds{1,4,6,2} = 190:440;

bounds{1,5,1,1} = 75:425;
bounds{1,5,1,2} = 189:439;
bounds{1,5,2,1} = 75:425;
bounds{1,5,2,2} = 189:439;
bounds{1,5,3,1} = 75:425;
bounds{1,5,3,2} = 210:460;
bounds{1,5,4,1} = 75:425;
bounds{1,5,4,2} = 189:439;

bounds{1,6,1,1} = 70:420;
bounds{1,6,1,2} = 175:425;
bounds{1,6,2,1} = 60:410;
bounds{1,6,2,2} = 175:425;
bounds{1,6,3,1} = 55:405;
bounds{1,6,3,2} = 175:425;
bounds{1,6,4,1} = 25:375;
bounds{1,6,4,2} = 180:430;
bounds{1,6,5,1} = 50:400;
bounds{1,6,5,2} = 180:430;
bounds{1,6,6,1} = 50:400;
bounds{1,6,6,2} = 175:425;

bounds{1,7,1,1} = 25:375;
bounds{1,7,1,2} = 45:295;
bounds{1,7,2,1} = 35:385;
bounds{1,7,2,2} = 40:290;
bounds{1,7,3,1} = 40:390;
bounds{1,7,3,2} = 50:300;
bounds{1,7,4,1} = 35:385;
bounds{1,7,4,2} = 40:290;
bounds{1,7,5,1} = 40:390;
bounds{1,7,5,2} = 45:295;
bounds{1,7,6,1} = 35:385;
bounds{1,7,6,2} = 50:300;

bounds{1,8,1,1} = 90:440;
bounds{1,8,1,2} = 90:340;
bounds{1,8,2,1} = 100:450;
bounds{1,8,2,2} = 100:350;
bounds{1,8,3,1} = 90:440;
bounds{1,8,3,2} = 100:350;
bounds{1,8,4,1} = 90:440;
bounds{1,8,4,2} = 95:345;
bounds{1,8,5,1} = 90:440;
bounds{1,8,5,2} = 100:350;
bounds{1,8,6,1} = 90:440;
bounds{1,8,6,2} = 95:345;

bounds{1,9,1,1} = 50:400;
bounds{1,9,1,2} = 110:360;
bounds{1,9,2,1} = 50:400;
bounds{1,9,2,2} = 120:370;
bounds{1,9,3,1} = 50:400;
bounds{1,9,3,2} = 110:360;
bounds{1,9,4,1} = 50:400;
bounds{1,9,4,2} = 110:360;
bounds{1,9,5,1} = 50:400;
bounds{1,9,5,2} = 110:360;
bounds{1,9,6,1} = 50:400;
bounds{1,9,6,2} = 110:360;

bounds{1,10,1,1} = 100:450;
bounds{1,10,1,2} = 100:350;
bounds{1,10,2,1} = 100:450;
bounds{1,10,2,2} = 100:350;
bounds{1,10,3,1} = 75:425;
bounds{1,10,3,2} = 95:345;
bounds{1,10,4,1} = 100:450;
bounds{1,10,4,2} = 110:360;
bounds{1,10,5,1} = 100:450;
bounds{1,10,5,2} = 110:360;
bounds{1,10,6,1} = 100:450;
bounds{1,10,6,2} = 100:350;

bounds{1,11,1,1} = 100:450;
bounds{1,11,1,2} = 100:350;
bounds{1,11,2,1} = 'nought';
bounds{1,11,2,2} = 'nought';
bounds{1,11,3,1} = 90:440;
bounds{1,11,3,2} = 90:340;
bounds{1,11,4,1} = 100:450;
bounds{1,11,4,2} = 90:340;
bounds{1,11,5,1} = 95:445;
bounds{1,11,5,2} = 90:340;
bounds{1,11,6,1} = 95:445;
bounds{1,11,6,2} = 90:340;

bounds{1,12,1,1} = 130:480;
bounds{1,12,1,2} = 85:335;
bounds{1,12,2,1} = 130:480;
bounds{1,12,2,2} = 75:325;
bounds{1,12,3,1} = 130:480;
bounds{1,12,3,2} = 75:325;
bounds{1,12,4,1} = 149:499;
bounds{1,12,4,2} = 75:325;
bounds{1,12,5,1} = 140:490;
bounds{1,12,5,2} = 75:325;
bounds{1,12,6,1} = 149:499;
bounds{1,12,6,2} = 75:325;

% bounds{2,1,4,1} = 102:452;
% bounds{2,1,4,2} = 139:389;
% bounds{2,3,3,1} = 1:350;
% bounds{2,3,3,2} = 1:250;

% bounds{2,4,1,1} = 70:420;
% bounds{2,4,1,2} = 120:370;
% 
% bounds{2,4,2,1} = 70:420;
% bounds{2,4,2,2} = 120:370;
% 
% bounds{2,4,3,1} = 70:420;
% bounds{2,4,3,2} = 120:370;
% 
% bounds{2,4,4,1} = 70:420;
% bounds{2,4,4,2} = 120:370;
% 
% bounds{2,4,5,1} = 70:420;
% bounds{2,4,5,2} = 120:370;





stacks{1,2,1} = [20,88];
stacks{1,2,2} = [20,92];
stacks{1,2,3} = [20,87];
stacks{1,2,4} = [20,91];
stacks{1,2,5} = [20,89];
stacks{1,2,6} = [20,92];

stacks{1,3,1} = [20,89];
stacks{1,3,2} = [20,98];
stacks{1,3,3} = [20,83];
stacks{1,3,4} = [20,93];
stacks{1,3,5} = [20,94];

stacks{1,4,1} = [20,99];
stacks{1,4,2} = [20,109];
stacks{1,4,3} = [20,92];
stacks{1,4,4} = [20,91];
stacks{1,4,5} = [20,97];
stacks{1,4,6} = [20,93];

stacks{1,5,1} = [20,93];
stacks{1,5,2} = [20,97];
stacks{1,5,3} = [20,95];
stacks{1,5,4} = [20,100];

stacks{1,6,1} = [20,83];
stacks{1,6,2} = [20,72];
stacks{1,6,3} = [20,72];
stacks{1,6,4} = [20,81];
stacks{1,6,5} = [20,74];
stacks{1,6,6} = [20,81];

stacks{1,7,1} = [20,91];
stacks{1,7,2} = [20,80];
stacks{1,7,3} = [20,90];
stacks{1,7,4} = [20,92];
stacks{1,7,5} = [20,89];
stacks{1,7,6} = [20,91];

stacks{1,8,1} = [20,83];
stacks{1,8,2} = [20,97];
stacks{1,8,3} = [20,84];
stacks{1,8,4} = [20,80];
stacks{1,8,5} = [20,85];
stacks{1,8,6} = [20,80];

stacks{1,9,1} = [20,82];
stacks{1,9,2} = [20,66];
stacks{1,9,3} = [20,76];
stacks{1,9,4} = [20,63];
stacks{1,9,5} = [20,70];
stacks{1,9,6} = [20,73];

stacks{1,10,1} = [20,94];
stacks{1,10,2} = [20,108];
stacks{1,10,3} = [20,84];
stacks{1,10,4} = [20,111];
stacks{1,10,5} = [20,104];
stacks{1,10,6} = [20,95];

stacks{1,11,1} = [20,95];
stacks{1,11,2} = [20,92];
stacks{1,11,3} = [20,94];
stacks{1,11,4} = [20,107];
stacks{1,11,5} = [20,90];
stacks{1,11,6} = [20,96];

stacks{1,12,1} = [20,95];
stacks{1,12,2} = [20,99];
stacks{1,12,3} = [20,87];
stacks{1,12,4} = [20,91];
stacks{1,12,5} = [20,100];
stacks{1,12,6} = [20,100];


% stacks{2,1,4} = [20,80];
% stacks{2,3,3} = [20 91];

stacks{2,4,1} = [20 20];
stacks{2,4,2} = [20 110];
stacks{2,4,3} = [20 115];
stacks{2,4,4} = [20 119];
stacks{2,4,5} = [20 20];


stacks{2,5,1} = [20 91];
stacks{2,5,2} = [20 20];
stacks{2,5,3} = [20 70];
stacks{2,5,4} = [20 78];
stacks{2,5,5} = [20 80];


stacks{2,6,1} = [20 20];
stacks{2,6,2} = [20 69];
stacks{2,6,3} = [20 71];
stacks{2,6,4} = [20 71];
stacks{2,6,5} = [20 20];
stacks{2,6,6} = [20 72];


stacks{2,7,1} = [20 118];
stacks{2,7,2} = [20 20];
stacks{2,7,3} = [20 115];
stacks{2,7,4} = [20 117];
stacks{2,7,5} = [20 108];
stacks{2,7,6} = [20 20];


stacks{2,8,1} = [20 115];
stacks{2,8,2} = [20 93];
stacks{2,8,3} = [20 101];
stacks{2,8,4} = [20 106];

stacks{2,9,1} = [20 93];
stacks{2,9,2} = [20 77];
stacks{2,9,3} =  [20 82];

stacks{2,11,1} = [20 101];
stacks{2,11,2} = [20 94];
stacks{2,11,3} = [20 89];

stacks{2,12,1} = [20 90];
stacks{2,12,2} = [20 96];
stacks{2,12,3} = [20 83];
stacks{2,12,4} = [20 102];
stacks{2,12,5} = [20 95];


bounds{2,4,1,1} = 1:351;
bounds{2,4,1,2} = 1:251;
bounds{2,4,2,1} = 1:351;
bounds{2,4,2,2} = 1:251;
bounds{2,4,3,1} = 1:351;
bounds{2,4,3,2} = 1:251;
bounds{2,4,4,1} = 1:351;
bounds{2,4,4,2} = 1:251;
bounds{2,4,5,1} = 1:351;
bounds{2,4,5,2} = 1:251;


bounds{2,5,1,1} = 1:351;
bounds{2,5,1,2} = 1:251;
bounds{2,5,2,1} = 1:351;
bounds{2,5,2,2} = 1:251;
bounds{2,5,3,1} = 1:351;
bounds{2,5,3,2} = 1:251;
bounds{2,5,4,1} = 1:351;
bounds{2,5,4,2} = 1:251;
bounds{2,5,5,1} = 1:351;
bounds{2,5,5,2} = 1:251;
bounds{2,5,6,1} = 1:351;
bounds{2,5,6,2} = 1:251;


bounds{2,6,1,1} = 1:351;
bounds{2,6,1,2} = 1:251;
bounds{2,6,2,1} = 1:351;
bounds{2,6,2,2} = 1:251;
bounds{2,6,3,1} = 1:351;
bounds{2,6,3,2} = 1:251;
bounds{2,6,4,1} = 1:351;
bounds{2,6,4,2} = 1:251;
bounds{2,6,5,1} = 1:351;
bounds{2,6,5,2} = 1:251;
bounds{2,6,6,1} = 1:351;
bounds{2,6,6,2} = 1:251;


bounds{2,7,1,1} = 1:351;
bounds{2,7,1,2} = 1:251;
bounds{2,7,2,1} = 1:351;
bounds{2,7,2,2} = 1:251;
bounds{2,7,3,1} = 1:351;
bounds{2,7,3,2} = 1:251;
bounds{2,7,4,1} = 1:351;
bounds{2,7,4,2} = 1:251;
bounds{2,7,5,1} = 1:351;
bounds{2,7,5,2} = 1:251;
bounds{2,7,6,1} = 1:351;
bounds{2,7,6,2} = 1:251;


bounds{2,8,1,1} = 1:351;
bounds{2,8,1,2} = 1:251;
bounds{2,8,2,1} = 1:351;
bounds{2,8,2,2} = 1:251;
bounds{2,8,3,1} = 1:351;
bounds{2,8,3,2} = 1:251;
bounds{2,8,4,1} = 1:351;
bounds{2,8,4,2} = 1:251;
bounds{2,8,5,1} = 1:351;
bounds{2,8,5,2} = 1:251;
bounds{2,8,6,1} = 1:351;
bounds{2,8,6,2} = 1:251;


bounds{2,9,1,1} = 1:351;
bounds{2,9,1,2} = 1:251;
bounds{2,9,2,1} = 1:351;
bounds{2,9,2,2} = 1:251;
bounds{2,9,3,1} = 1:351;
bounds{2,9,3,2} = 1:251;


bounds{2,11,1,1} = 1:351;
bounds{2,11,1,2} = 1:251;
bounds{2,11,2,1} = 1:351;
bounds{2,11,2,2} = 1:251;
bounds{2,11,3,1} = 1:351;
bounds{2,11,3,2} = 1:251;


bounds{2,12,1,1} = 1:351;
bounds{2,12,1,2} = 1:251;
bounds{2,12,2,1} = 1:351;
bounds{2,12,2,2} = 1:251;
bounds{2,12,3,1} = 1:351;
bounds{2,12,3,2} = 1:251;
bounds{2,12,4,1} = 1:351;
bounds{2,12,4,2} = 1:251;
bounds{2,12,5,1} = 1:351;
bounds{2,12,5,2} = 1:251;
bounds{2,12,6,1} = 1:351;
bounds{2,12,6,2} = 1:251;


% moving_start_times{5,1} = '22-Sep-2015 03.53.23';

% moments_times{2,5,3} = '27-Nov-2015 03.11.17';
% moments_times{2,5,4} = '27-Nov-2015 02.11.57';
% moments_times{2,5,5} = '27-Nov-2015 02.33.31';

moments_times{2,4,2} = '05-Apr-2016 16.39.36';
moments_times{2,4,3} = '05-Apr-2016 18.40.19';
moments_times{2,4,4} = '14-Apr-2016 21.39.01';


moments_times{2,7,1} = '27-Feb-2016 16.37.04';

moments_times{2,11,3} = '18-Mar-2016 06.03.20';



moments_times{2,6,1} = ''
moments_times{2,6,2} = '28-Nov-2015 14.53.45';
moments_times{2,6,3} = '28-Nov-2015 15.25.08';
% moments_times{2,6,4} = '28-Nov-2015 18.38.51';
moments_times{2,6,5} = '';
moments_times{2,6,6} = '28-Nov-2015 19.48.56';


moments_times{2,7,1} = '28-Mar-2016 17.05.04';
moments_times{2,7,3} = '29-Mar-2016 19.37.17';
moments_times{2,7,4} = '29-Mar-2016 21.05.49';
moments_times{2,7,5} = '30-Mar-2016 18.52.39';

moments_times{2,9,1} = '15-Mar-2016 02.28.36';
moments_times{2,9,2} = '15-Mar-2016 03.40.34';
moments_times{2,9,3} = '15-Mar-2016 04.43.28';

moments_times{2,11,1} = '17-Mar-2016 03.15.47';
moments_times{2,11,2} = '18-Mar-2016 05.21.11';
moments_times{2,11,3} = '18-Mar-2016 08.41.14';

moments_times{2,12,1} = '13-Mar-2016 06.16.30';
moments_times{2,12,2} = '13-Mar-2016 18.21.38';
moments_times{2,12,3} = '13-Mar-2016 07.32.53';
moments_times{2,12,4} = '13-Mar-2016 08.47.34';
moments_times{2,12,5} = '13-Mar-2016 10.02.32';





% old moving start times, old run
% moving_start_times{2,5,3} = '27-Nov-2015 03.11.17';
% moving_start_times{2,5,4} = '27-Nov-2015 02.11.57';
% moving_start_times{2,5,5} = '27-Nov-2015 02.33.31';

moving_start_times{2,4,2} = '05-Apr-2016 16.39.36';
moving_start_times{2,4,3} = '05-Apr-2016 18.40.19';
moving_start_times{2,4,4} = '14-Apr-2016 21.39.01';

moving_start_times{2,5,1} = '06-Apr-2016 17.31.35';
moving_start_times{2,5,3} = '06-Apr-2016 18.56.45';
moving_start_times{2,5,5} = '07-Apr-2016 15.35.27';

moving_start_times{2,6,3} = '15-Apr-2016 00.15.46';
moving_start_times{2,6,6} = '06-Apr-2016 18.56.45';





moving_start_times{2,6,1} = ''
moving_start_times{2,6,2} = '28-Nov-2015 14.53.45';
moving_start_times{2,6,3} = '28-Nov-2015 15.25.08';
% moving_start_times{2,6,4} = '28-Nov-2015 18.38.51';
moving_start_times{2,6,5} = '';
moving_start_times{2,6,6} = '28-Nov-2015 19.48.56';

moving_start_times{2,7,1} = '28-Mar-2016 17.05.04';
moving_start_times{2,7,3} = '29-Mar-2016 19.37.17';
moving_start_times{2,7,4} = '29-Mar-2016 21.05.49';
moving_start_times{2,7,5} = '30-Mar-2016 18.52.39';

moving_start_times{2,9,1} = '15-Mar-2016 02.28.36';
moving_start_times{2,9,2} = '15-Mar-2016 03.40.34';
moving_start_times{2,9,3} = '15-Mar-2016 04.43.28';

moving_start_times{2,11,1} = '17-Mar-2016 03.15.47';
moving_start_times{2,11,2} = '18-Mar-2016 05.21.11';
moving_start_times{2,11,3} = '18-Mar-2016 08.41.14';

moving_start_times{2,12,1} = '13-Mar-2016 06.16.30';
moving_start_times{2,12,2} = '13-Mar-2016 18.21.38';
moving_start_times{2,12,3} = '13-Mar-2016 07.32.53';
moving_start_times{2,12,4} = '13-Mar-2016 08.47.34';
moving_start_times{2,12,5} = '13-Mar-2016 10.02.32';



do_registration = true;
extract_neurites = false;

num_datasets = size(datasets,2);
for dataset_number = 1:num_datasets
    external_specified_dataset = datasets(dataset_number);
    for external_specified_position = first_position:last_position
        external_specified_dataset_directory = ['K:\Laptop F drive copy\new reg 4-8 classifier 6-13-15\' num2str(external_specified_dataset) '-' num2str(external_specified_position)];
        
        external_specified_strain_number = 1;
        external_specified_strain_name = '';
        external_specified_run_number = 600;
        MainRegister;
        
    end
end
