SPM5 Coregistration
Coregistration needs some overlap between the images; I used Christian Gaser's idea of center-of-mass shift prior to running coregistration, and it works well.
New Way
Apply a shift to the images, in the case below for an image to an MNI template. cspm_im_centerofmass_shift2MNI.m
Old Way
This is just a matter of adding the "params" field to the flags that are passed to the coregistration estimation. I got it going with the following changes:
spm_defauts.m - line 78 defaults.coreg.estimate.params = 0 0 0 0 0 0;
spm_config_coreg - line 81 %------------------------------------------------------------------------ params.type = 'entry'; params.name = 'Starting estimates'; params.tag = 'params'; params.num = 1 6; params.strtype = 'e'; params.def = 'coreg.estimate.params'; params.help = {[... 'Starting estimates (x/y/z/rotx/roty/rotz); can be useful if there is no initial ',... 'overlap between images.']};
spm_config_coreg - line 110 (after inserting the above) eoptions.val = {cost_fun,sep,tol,params,fwhm};
FYI, I am using Christian Gaser's idea aligning of the center-of-mass to get the starting estimate:
function params = cspm_im_centerofmass_shift2MNI( source, reference, flag_highres_T1 ) % params = cspm_im_centerofmass_shift2MNI( source, reference, flag_highres_T1 ) % Find x/y/z shift ("params") between two images % "source" shifted to "reference" % Use Christian Gaser's center-of-mass concept - set COM of image to COM % of reference (using coreg starting estimates; no need to update the file header) % If shifting high-res T1 anatomical (e.g., MPRAGE) to MNI template, Christian suggests % a -30 mm z-shift as the MNI is cutoff much higher than standard T1's.
% use center-of-mass (COM) to roughly correct for differences in the % position between image and template com_reference = cspm_im_centerofmass( reference );
if flag_highres_T1 % Christian: % pre-estimated COM of MNI template % the z-axis was corrected by -30 mm because the MNI template % is much more limited at the inferior part than most raw images % (based on a trial with 20 brains from 4 different scanners) % Paul: I just shifted by -30 mm
com_reference = com_reference + 0 0 -30; end
% get COM for image com_source = cspm_im_centerofmass( source );
% update starting parameters by shift image according to COM differences params = (com_reference - com_source);
function com = cspm_im_centerofmass( im )
V = spm_vol(im); Y,XYZmm = spm_read_vols( V );
% Use spm_minmax to return suitable background threshold thresh,mx = spm_minmax( Y );
% exclude use background values XYZmm2 = XYZmm(:,Y > thresh);
% COM is mean of remaining coordinates above threshold com = mean(XYZmm,2)';