A MATLAB toolbox for various preprocessing operations (registration, reslicing, denoising, segmentation, etc.) of neuroimaging data. Builds on the SPM12 software.
I am using spm-hospital-preproc to register clinical MRIs (registered well-over 110K sessions recently and can confirm it is working beautifully). I would now like to keep the final affine transformation matrices for each input image once the pipeline is finished, i.e. the M cell in RunPreproc.m. The problem is that I am reslicing, so I get to line 208 of RunPreproc and it runs reslice_images.m, which on lines 31-34 replaces all the affine matrices with the one corresponding to the first image (the ref_ix image):
% Update M
for n=source_ix
M{n} = M{ref_ix};
end
Up until this point, as far as I can tell, the ith element of M is the composition of all the affine transformations applied to input image i thus far, which is what I want! Have I missed something? It would be really nice if I could affine register + reslice but still get the overall transformation matrix for each image.
Running a pipeline with two images, including segmentation and bias field correction, the bias field correction step crashes with "Index exceeds the number of array elements.". It is looking for a bias-corrected image for each of the segmentation inputs, but there is only one in line 7: Nii{1}(n) = nifti(pth_seg{7}{n});
Inputs to bf_correct.m:
Nii - 1x1 cell array
Nii{1} - 1x2 nifti
pth_seg - 1x8 cell array
pth_seg{5:7} - 1x1 cell arrays
pth_seg{[1:4,8]} - empty (0x0 double)
pth_seg{7} - 1x1 cell array, with a bias corrected image filename corresponding to the first input image
It looks like the internal SPM function only writes bias corrected for one image. It seems like a decision is needed about whether to limit the user to one bias-corrected image (which may break later steps), or save the bias field and apply it to each image after SPM has finished.