Why is my SPM batch job printing a warning repeatedly?
Below is a corrected version of the script.  SPM seems to be quite finicky about the structure of the data passed to matlabbatch{...}.spm.spatial.realign.estwrite.daat{...}.



%%job_realign.m  SPM batch module.
% SPM's spm_jobman function will eval this file, and automatically launch a
% batch job if the parameters are valid.  Cryptic errors out of spm_jobman
% are usually an indication of a runtime error in batch modules.

%% Get configuration

cfg = config();

%% Get data
include = cfg.subdir(find(cfg.submask));

for isub = 1:length(include)
    subdir = include{isub};
    fprintf('In directory %s:\n', fileparts(subdir));

    runs = regexpdir(subdir, cfg.regex.rundir, false)';
    runs = [runs regexpdir(subdir, cfg.regex.locdir, false)'];
    runs = [runs regexpdir(subdir, cfg.regex.retdir, false)'];


    for irun=1:length(runs)
        rundir = runs{irun};
        scans = regexpdir(rundir, cfg.regex.funcscan, false);
        fprintf('Scans:  %d\n', size(scans, 1));

        matlabbatch{isub}.spm.spatial.realign.estwrite.data{irun} = scans;
    end



    matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.quality = 0.9;
    matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.sep = 4;
    matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.fwhm = 5;
    matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.rtm = 1;
    matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.interp = 2;
    matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.wrap = [0 0 0];
    matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.weight = {''};
    matlabbatch{isub}.spm.spatial.realign.estwrite.roptions.which = [0 1];    % [0 1] creates mean image only; [1 1] creates all images + mean
    matlabbatch{isub}.spm.spatial.realign.estwrite.roptions.interp = 4;       % 4th degree B-Spline interpolation
    matlabbatch{isub}.spm.spatial.realign.estwrite.roptions.wrap = [0 0 0];
    matlabbatch{isub}.spm.spatial.realign.estwrite.roptions.mask = 1;
    matlabbatch{isub}.spm.spatial.realign.estwrite.roptions.prefix = 'r';
end