In fact the residual images are written out and then deleted, to save space.  See spm_spm.m, searching for the text "Delete the residuals images".  Comment out the subsequent spm_unlink lines and you'll have the residual images (ResI_xxxx.img) present in the analysis directory.

Also note that if you have more than 64 images, you'll also need to change spm_defaults.m, in particular the line
defaults.stats.maxres   = 64;
which is the maximum number of residual images written.


On Fri, Apr 18, 2008 at 6:31 AM, Joonkoo Park <[log in to unmask]> wrote:
Hi SPM community!

I'm looking for a fast and efficient way to extract residuals (epsilon
hat's) for each time point (for each voxel, of course) during the GLM
procedure. This requires a lot of memory, so I guess SPM just calculates it
on the fly and just keeps the RSS (or actually ResMS), but I wanted to play
with the epsilon hat's.

The method I was going to try was to use the beta_hat's and subtract
Y_fitted from Y_actual (i.e. epsilon_hat = Y_actual - X * beta_hat). But I
wasn't sure if this was a good idea since I understand that SPM's GLM
procedure involves drift correction and filtering so that Y_actual may not
actually be raw signals from the *img files. Or, there could be some other
reasons that this might not be correct.

Is there a better (or more correct) way to extract the residuals for each
time point? Perhaps, a way to modify model specification or estimation

Thanks a lot in advance.


Thomas Nichols, PhD
Director, Modelling & Genetics
GlaxoSmithKline Clinical Imaging Centre

Senior Research Fellow
Oxford University FMRIB Centre