help > Qform matrix in MRIcron and MRIcroGL
Jan 6, 2021  11:01 AM | loutions
Qform matrix in MRIcron and MRIcroGL
Dear MRIcron experts,

I have a set of 3D coordinates in 'lab-space' (obtained using a neuronavigation system) which I want to convert to voxel indices of the respective nifti.
I tried opening the nifti file in MRIcron and check if the coordinates the neuronavigation system gave me made sense, which they do.
To do the conversion, I just thought I'd load the nifti header into MATLAB, extract the qform, and get the voxel indices doing
V = round(inv(Q)*C');
where V are the voxel indices, Q is the qform matrix (which I got from the MRIcron), and C are the coordinates.
(This didn't work, i.e. the returned indices do not match those in MRIcron, and I'm convinced the problem lies in the algebra - if a kind soul could help me, I'd be highly appreciative!)

However, I opened the same image on MRIcroGL to check the header and the qform is different to that displayed in MRIcron (screenshots are in attachment). 
The difference is not just the orientation of the axes (trivial rotations and permutations from the different conventions), but also in the qoffset, which is what puzzles me.
I then displayed the qform matrix of the same nifti using different softwares (FSL's fslhd and Freesurfer's mri_info - the results of which are also attached), and these are congruent with the matrix displayed in MRIcroGL.
I thought it might have something to do with the center of the referential being poorly defined, but subtracting the c_ras from the mri_info output does not correct for the different qoffsets seen between MRIcron and everything else I tested.

I was wondering if someone could explain to me this difference, or re-direct me to a place where I can read about it.
The versions I'm using are:
MRIcron v1.0.20190902
MRIcroGL v1.2.20201102

Thank you very much in advance!
Attachment: screenshots.png

Threaded View

Qform matrix in MRIcron and MRIcroGL
loutions Jan 6, 2021
Chris Rorden Jan 6, 2021