first_stack = 1;
last_stack = 145;

dataset = 11;

first_position =2;
last_position = 2;

first_color = 0;
last_color = 1;

x_bounds = 35:385;
y_bounds = 110:360;

num_slices = 93;

output_stack = zeros(350,250,num_slices);

read_prefix = 'mov2__ ';
write_prefix = '';
strain_name = 'NG_';
start_time = '27-Mar-2015 18.23.24';

mkdir('resized images')
for position = first_position:last_position
    cd(['Position ' num2str(position)]);
    mkdir('resized images')
    for color = first_color:last_color
        for i = first_stack:last_stack
            filename1 = [read_prefix 'Stack ' num2str(i) ' Position ' num2str(position) ' Color ' num2str(color)];
            filename2 = [write_prefix strain_name 'Ds' num2str(dataset) '_Pos' num2str(position) '_Co' num2str(color) '_St' num2str(i)];
            
            input_stack = TiffStackImport(filename1);
            output_stack = input_stack(y_bounds,x_bounds,:);
            cd('resized images')
            TiffStackWrite(output_stack,[filename2 ''],16);
            TiffStackMaxProjectCallable(output_stack,[filename2 ' max project'])
            fprintf(num2str(i))
            cd ..
        end
    end
    cd ..
end


