Transformation matrices different export options

Dear all,

As I cannot transform directly to MNI in Brainstorm as my MRIs were not processed with Freesurfer before, I exported the volumes and normalized them to MNI space using fieldtrip/spm.
I would like to know intracraneal sEEG positions coregistered correctly with my preoperative MRIs in MNI space. I though I could use from my fieldtrip/spm normalizetion directly mri_norm (normalized mri ft structure).cfg.final transformation matrix. However, there is a problem.

If I export the MRI into Matlab as a brainstorm structure, I have the following transformation matrix:
T =

0.0149    0.9917    0.1277 -119.9746

-0.9998 0.0129 0.0161 79.6231
0.0144 -0.1279 0.9917 -77.3171
0 0 0 1.0000

ft_warp_apply(T, voxel) or ft_warp_apply(inv(T), electrode position) prefectly reproduces the coordinates in SCS (mm) or MRI voxel indices.

However, if I use my transformation matrix from my normalization step to transform the electrode positions in SCS to MNI space, I get wrong results. I realized that the transformation matrix of the exported to file (nifti) MRI is different than the exported to matlab one:

T(exported to file) =
1.0000 0 0 -84.0000
0 0.4688 0 -124.9824
0 0 0.4688 -131.0448
0 0 0 1.0000

The normalization to MNI space was done with the exported to file MRI and I guess there is an additional transformation done during export to file.

How can I get from the T to T(exported to file) so that I can use the transformation matrix from my normalization step? Maybe a stupid question but I get always confused with the transformation steps.

Thanks for your help!

Best,

Stephan Moratti

Hi Stefan,

The transformation saved in the .nii file is not the SCS (because no one would use it). The volumes are saved with no rotation, just a translation to the origin of the “MNI coordinates”. However if you didn’t compute the MNI transformation, we don’t know where the origin of the SPM/MNI coordinates is.

The code that defines the sform transformation in the .nii is in brainstorm3/toolbox/io/out_mri_nii.m, lines 97-106:

% Default origin of the volume: AC, if not middle of the volume
if isfield(sMri, 'NCS') && isfield(sMri.NCS, 'Origin') && ~isempty(sMri.NCS.Origin) 
    Origin = sMri.NCS.Origin - [1 2 2];
elseif isfield(sMri, 'NCS') && isfield(sMri.NCS, 'R') && ~isempty(sMri.NCS.R) && isfield(sMri.NCS, 'T') && ~isempty(sMri.NCS.T) 
    Origin = cs_convert(sMri, 'mni', 'mri', [0 0 0]) .* 1000;
elseif isfield(sMri, 'NCS') && isfield(sMri.NCS, 'AC') && ~isempty(sMri.NCS.AC) 
    Origin = sMri.NCS.AC + [0, -3, 4];
else
    Origin = volDim / 2;
end

Does this help?
I’m not sure why I did it this way… Let me know if you have a better suggestion.

Cheers,
Francois

FYI: We improved significantly the tools available in Brainstorm for processing and visualizing SEEG and ECOG data, including new options for volume coregistration. They are now documented in a new tutorial:
http://neuroimage.usc.edu/brainstorm/Tutorials/Epileptogenicity