I am trying to do something rather simple.
I have two T1w anatomy scans of the same subject, acquired in the same session, hence they are already roughly aligned.
Let’s call them template.nii and T1_B.nii
What I want to do is align scan T1_B.nii with template.nii and (maybe…) reslice T1_B.nii so that is in the same voxel space as template.nii
In theory one can use the fsl command
flirt -in T1_B.nii -ref template.nii -out rigid_T1_B.nii
except flirt is in the habit of being terribly unreliable often even in the most basic situations *1).
So I am looking to use mrregister.
I have read the wiki page on this, and it’s good and helpful, but it is limited.
I could use:
which works essentially fine but it does seem a little cumbersome. It does have the clear advantage over flirt that is does do the job correctly…
I tried various options that seemed to make sense to me using different flags from reading the docs, but somehow I always seem to get the order of things wrong.
*1) flirt fails aligning the exact same scan with it’s upsampled and skull stripped version. Yes, take file, skull strip it, upsample. The skull striped and upsampled image is still perfectly aligned with the original in any MRimage viewer I tested. Yet flirt manages to mess it all up. And not only in one subject but in every one I tested.
It does seem to do what I want it to do, except it fails the alignment just like flirt did (though coming to a different wrong solution…). Which is weird, I would think the alignment would be easy to achieve, almost impossible to mess up.
As you can see in the screenshot (from ITKSnap), template and T1_B are very well aligned, but after the mrregister they no longer are. I checked this using mrview, too.
Now as for your second comment -strides 1,2,3 I am not sure I understand what that is supposed to do or even how exactly that should be used.
P.S. ITKSnap is infallible able to perform this registrating with a push of a button, indeed even fit the mismatch between template and T1_B_at_template. This would confirm that the task isn’t a hard one. But of course I want to be able to script this…
Not sure if this is helpful, but I’ve had issues performing registration with flirt as well that “magically” seem to go away after reorienting the images with fslreorient2std. Also, I’m not sure if the bias field inhomogeneity is causing it to trip up, in which case you can always try playing around with cost function used, or first correct the images before registration (run fast with the -B option).
Given how much of the brain has been stripped out in one of the images, I wouldn’t be surprised if the initialisation of the registration (typically by centre of mass) is what causes things to fail, for both flirt and mrregister. I think you could quickly check that with mrregister by specifying the brain mask using the -mask1 or -mask2 option (whichever applies to the skull-stripped image). If that’s the issue, I guess itksnap gets it right because it initialises with what’s on screen – i.e. no initialisation – but that’s pure speculation on my part…
That essentially does the same job as the fslreorient2std suggestion from @NicDC. You’d use it with mrconvert, e.g.:
If you don’t have a mask, you can initialise mrregister to the geometric centre or to zero offset in scanner space with -rigid_init_translation geometric or -rigid_init_translation none. Also, make sure that image intensities between images are comparable as the least-squares metric is sensitive to intensity scaling.