Calculating magnet coordinates from transform header

Hello all,

I am trying to calculate the orientation of the head in the scanner with respect to the z-axis of the bore for a few structural images and I believe for the first step I can use qform to move between image and magnet coordinates. I assume the “transform” field of mrinfo gives me the matrices I need as my sforms and qforms are exactly the same.

So, if I multiply the voxel coordinates of a raw image by the rotation component of the transform matrix that I can get with transformcalc, I should get the original orientation of the head in the scanner, am I correct? However, when I do this, the orientation of the head looks nothing like the orientation in the scout image of the same subject which should already be in the magnet coordinates. My scout images have identity matrices in the rotation component of their transformations, so I think they are definitely in the magnet space. So, I am not sure what I am doing wrong. The mrview can align scouts with the structurals with no issues, so I think my matrices are good. It’s either that I have an issue in my code that I keep missing or I am entirely barking up the wrong tree. Does mrview try to align two images by multiplying qform of one of the images and inverse qform of the other by the image coordinates of the first image or is there some other operation taking place?


Hi Ozzy,

I think the issue here relates to MRtrix’s internal handling of strides & transform. Please refer to this page in the docs for the full context.

Long story short: try adding the -config RealignTransform false option to your mrinfo -transform command…