I actually had the same problem, it can be quite tricky to solve when the scans differ between runs. I created a set of Linux shell scripts that uses FSL's avwutils to count the number of scans in each file. Then it creates a batch file from a template (a manually created batch file with all image references deleted) and runs a loop that adds a new image line for each image count. Then it starts Matlab and runs the batch. A much simpler solution would have been if you could instruct SPM to map all scans in a 4D file, but unfortunately such a functionality is not implemented. Thinking of it, it should be quite easy to write a simple Java program that handles this. Perhaps I will do that instead if I come across this problem again. I'd be happy to send you my scripts if you like to have a look at it. /Johan On Wed, 11 Apr 2007 21:45:11 +0100, Claus Lamm <[log in to unmask]> wrote: >Using SPM5, I set up a default preprocessing batch-script that specifies all >the preprocessing steps. > >now I want to run those steps for all my subjects, i.e. basically run a loop >over them. > >I saw several entries on the helpline but weren't really able to implement >this. one problem might be that my study has several runs, with different >number of scans per run. > >so my question is: how could I implement such a loop? or, alternatively: how >can I change the data/filenames in my batch.mat? > >THANKS in advance > >Claus >========================================================================