[FieldTrip] ft_volumereslice rotates the brain, how to fix?

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Tue Mar 7 09:17:50 CET 2017

Hi Andrew,

What’s the point in doing the second, headshape based alignment? I suppose that the template electrode positions are defined in a different coordinate system than ‘spm’?
If so, be aware that probably these template positions do not nicely match the reconstructed headsurface from the template MRI, so you need to do the headshape based alignment by hand, since the automatic icp algorithm probably will get caught in an inappropriate local minimum. As long as you don’t rotate around the z-axis, I would assume that the ‘rotation’ would go away.

Note, that the rotation of the image itself (as per ft_volumereslice) is not the problem, but the fact that it is rotated probably is, because that suggest that your coregistration between anatomy and electrodes does not make sense.


J.M.Schoffelen, MD PhD
Senior Researcher, VIDI-fellow - PI, language in interaction
Telephone: +31-24-3614793
Physical location: room 00.028
Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands

On 06 Mar 2017, at 19:04, Andrew Chang <changa5 at mcmaster.ca<mailto:changa5 at mcmaster.ca>> wrote:

Dear Fieldtrip users,

I am following the tutorial (http://www.fieldtriptoolbox.org/tutorial/natmeg/dipolefitting) to work on coregistering the anatomical MRI (using colin27 template) to the EEG coordinate system, and then reslicing the MRI on to a cubic grid. However, I found that the ft_volumereslice rotates the MRI image, which seems weird.

This is the sourceplot of the realigned MRI (from the 'mri_realigned2' variable, see the code below):

However, this is the sourceplot of the resliced MRI, which was rotated in 3 dimensions (from the 'mri_resliced' variable, see the code below):

I found that this rotation effect can be modulated by adjusting the parameters [rotation, scale, translate] on xyz dimensions, when I use the 'headshap' method for ft_volumerealign (see the code below). However, the effect of adjusting these parameters seems not to be linear or intuitive at all, and I cannot find the best combination to fix the rotation problem.

Any advice or help would be much appreciated! Thank you all in advance!

Here is the .mat file of what I have done: https://www.dropbox.com/s/viazz1vaq8gjyqb/fixingRotationMRI.mat?dl=0

Here is my code
%% load MRI
[mri_orig] = ft_read_mri('colin27_t1_tal_lin.nii');

%% load elec locations
% I do not have the channel location or the headshape file, so I use a template cap to build the channel locations and headshape
sphcoor = [Theta,Phi]';
cartcoor = elp2coor(sphcoor,10)'; % converting theta/phi coorfinates into xyz
elec.elecpos = cartcoor;
elec.chanpos = cartcoor;
elec.label = ChannelName; % 'ChannelName' is a cell array of channel labels
elec.unit = 'cm';

shape.pos = elec.elecpos;
shape.label = elec.label;
shape.unit = elec.unit ;
shape.coordsys = 'spm';

%% Coregister the anatomical MRI to the EEG coordinate system
cfg = [];
cfg.method = 'interactive';
cfg.coordsys = 'spm';
[mri_realigned1] = ft_volumerealign(cfg, mri_orig);

cfg = [];
mri_realigned2 = [];
cfg.method = 'headshape';
cfg.coordsys = 'spm';
cfg.headshape = shape;
[mri_realigned2] = ft_volumerealign(cfg, mri_orig);
% key in the following parameter for controlling the alignment
% rotation: [0,0,0.5]
% scale: [0.95, .8, .8]
% translate: [0, 15, 0]

cfg = [];
cfg.resolution = 1;
cfg.xrange = [-100 100];
cfg.yrange = [-110 110];
cfg.zrange = [-50 120];
mri_resliced = ft_volumereslice(cfg, mri_realigned2);


Andrew Chang, Ph.D. Candidate
Vanier Canada Graduate Scholar

Auditory Development Lab
Department of Psychology, Neuroscience & Behaviour
McMaster University
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20170307/cd3664f9/attachment-0002.html>

More information about the fieldtrip mailing list