I am working in a python script to load 4D images and then repeat the same operations in each time volume. Therefore, my script includes first the loading instructions and then a for loop. I am having trouble with the loop, as it is being executed before the images are completely loaded. If I remove the loop and perform the operations for one only volume, the loop is executed after loading the images, as desired.
How can I solve this? I mean, how can I guarantee that the for loop is executed once the images are completely loaded?
(I am using Slicer 5.2.1 in linux.)