Problem with sequentiality when using loops

Dear community,

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.)


It would help if you could provide a short script that demonstrates the calls you are using. Even better would be an example that replicates the issue using public data (e.g. from the SampleData module).

Thanks for posting the code. It looks like the issue here is just that you need range(n_time_volumes) with the parentheses : )

1 Like

Thank you, I don’t know how I missed that, I’m so embarrased :sweat_smile:

1 Like