ignore tmp/
re-factored to work for z-stacks, tested for XYT, XYCT and XYZT (not multichannel z-stacks)