first_stack = 1;
last_stack = 140;

first_position = 1;
last_position = 5;

first_color = 1;
last_color = 1;

prefix = 'mov__ ';
suffix = '';


for position = first_position:last_position
    cd(['Position ' num2str(position)]);
    mkdir('maximum projections')
    for color = first_color:last_color
for i = first_stack:last_stack
    stack = TiffStackImport([prefix 'Stack ' num2str(i) ' Position ' num2str(position) ' Color ' num2str(color) suffix]);
    max_project = max(stack,[],3);
    cd('maximum projections')
    TiffStackWrite(max_project,[prefix 'Stack ' num2str(i) ' Position ' num2str(position) ' Color ' num2str(color) ''],16)
    fprintf(num2str(i))
    cd ..
end
    end
    cd ..
end