Layer stacking and applying mask on the stack

Please use only one topic for the same quesiton: Batch processing for VIs calculation

You can modify the title to adjust it to the problem.