Hi Xiang,
the way you tried to use "Save batch and script" is not exactly how it is intended.
1) You would set up your batch for one subject, but without entering any subject specific data (files, folders etc.).
2) Then you would run "Save batch and script", which gives you the batch variable and the script. The script will give you the chance to specify inputs for each of the "<-X" marked items in your batch.
3) Do not modify anything in the batch variable itself. The script is a skeleton where you can add your own MATLAB code to e.g. select files, folders etc. for all subjects. Compute nrun based on the number of subjects determined by your MATLAB program. Then, modify the lines in the for loop such that data for each run will be assigned to the correct input. Use standard MATLAB and SPM commands for this. Files, folders must be entered as cell arrays of strings.
4) Run the script, and it will loop over all subjects. It is a good idea to run it one or two subjects first and try whether all inputs are assigned correctly. You can also inspect the inputs cell array before the call to spm_jobman('serial',...) to see whether your own code got all inputs right.
Hope this helps,
Volkmar
|