Dear Experts,
I have used mcflirt to correct for subject motion. The original magnitude image is 100x100x20x8x3x5 corresponding to 20 slices, 8 times steps, 3 directions and 5 frequencies (MRE data). I make the image into a 4D image (100x100x20x120) and separate each slice (so 120 slices per anatomical slice that need to be corrected)
Complex magnitude - 100x100x20x120
%motion correct each slice separately (for all 120 images)
slice1 = a(:,:,1,:);
slice1 = make_nii(slice1,[2.3 2.3 2.3], re.hdr.dime.datatype);
save_nii(slice1,'slice1.nii')
!$FSLDIR/bin/mcflirt -in slice1 -meanvol -mats
Output - slice1_mcf and slice_mcf.mat file (120 4x4 matrices)
I then want to apply all of the 120 matrices to the real and imaginary parts of the same image:
%REAL = motion correct each slice separately
re1 = re.img(:,:,1,:);
re1 = make_nii(re1,[2.3 2.3 2.3], re.hdr.dime.datatype);
save_nii(re1,'re1.nii')
!$FSLDIR/bin/flirt -in re1 -ref slice1_mcf -out real1 -applyxfm -init MAT_0000
But wouldn't this just apply for first matrix MAT_0000 to all 120 images? How can I apply MAT_0001, MAT_0002 etc to the appropriate slice in the series.
I assume this would need a loop or something, but I have no experience in this whatsoever.
Also, the MC doesn't work as well as I had hoped. Is there a way to improve this?
Many thanks for your help
Lucy
|