


Change Neuromag-Head coordinate to Right-hand SPM [m] coordinate
Point coordinate
[Vhead,Vox] = spm_right_to_neuro_vox(Vspm,trans_info,Vdim,Vsize)
Normal vector
[Vhead,Vox] = spm_right_to_neuro_vox(Vspm,trans_info,Vdim,Vsize,1)
---- Input
Vspm : NV x 3 right-handed SPM coordinate
Vdim : Voxel dimension of Analize image
Vsize : Voxel size of Analize image
nflag = 0 : coordinate transformation (default)
= 1 : normal vector transformation
: no translation is applied
---- Output
Vhead : NV x 3 Neuromag-Head coordinate
Vox : NV x 3 left-handed Voxcel coordinate
--- MRI-Voxel coordinate (Image based)
[Left-hand coordinate]
X:Right(1) -> Left(256) R->L
Y:Front(1) -> Back(256) A->P
Z:Top(1) -> Bottom(136) S->I
--- SPM coordinate (Image based)
[Right-hand coordinate]
X: Left(-191/2) -> Right(191/2)
Y: Back(-256/2) -> Front(256/2)
Z: Bottom(-256/2) -> Top(256/2)
--- Head coordinate
X : from left to right : LPA -> RPA
Y : from back to front : Nasion -> x-axis
Z : from bottom to up.
Masa-aki Sato 2009-4-13
Copyright (C) 2011, ATR All Rights Reserved.
License : New BSD License(see VBMEG_LICENSE.txt)

0001 function [Vhead,Vox] = spm_right_to_neuro_vox(Vspm,trans_info,Vdim,Vsize,nflag) 0002 % Change Neuromag-Head coordinate to Right-hand SPM [m] coordinate 0003 % Point coordinate 0004 % [Vhead,Vox] = spm_right_to_neuro_vox(Vspm,trans_info,Vdim,Vsize) 0005 % Normal vector 0006 % [Vhead,Vox] = spm_right_to_neuro_vox(Vspm,trans_info,Vdim,Vsize,1) 0007 % ---- Input 0008 % Vspm : NV x 3 right-handed SPM coordinate 0009 % Vdim : Voxel dimension of Analize image 0010 % Vsize : Voxel size of Analize image 0011 % nflag = 0 : coordinate transformation (default) 0012 % = 1 : normal vector transformation 0013 % : no translation is applied 0014 % ---- Output 0015 % Vhead : NV x 3 Neuromag-Head coordinate 0016 % Vox : NV x 3 left-handed Voxcel coordinate 0017 % 0018 % --- MRI-Voxel coordinate (Image based) 0019 % 0020 % [Left-hand coordinate] 0021 % X:Right(1) -> Left(256) R->L 0022 % Y:Front(1) -> Back(256) A->P 0023 % Z:Top(1) -> Bottom(136) S->I 0024 % 0025 % --- SPM coordinate (Image based) 0026 % 0027 % [Right-hand coordinate] 0028 % X: Left(-191/2) -> Right(191/2) 0029 % Y: Back(-256/2) -> Front(256/2) 0030 % Z: Bottom(-256/2) -> Top(256/2) 0031 % 0032 % --- Head coordinate 0033 % X : from left to right : LPA -> RPA 0034 % Y : from back to front : Nasion -> x-axis 0035 % Z : from bottom to up. 0036 % 0037 % Masa-aki Sato 2009-4-13 0038 % 0039 % Copyright (C) 2011, ATR All Rights Reserved. 0040 % License : New BSD License(see VBMEG_LICENSE.txt) 0041 0042 if nargin < 4, error('Input argument error'); end 0043 if nargin < 5, nflag = 0; end; 0044 0045 NV = size(Vspm,1); 0046 Vox = zeros(NV,3); 0047 % Change [m] to [mm] 0048 Vspm = Vspm*1000; 0049 0050 if nflag == 1 0051 % SPM -> Voxcel 0052 Vox(:,1) = - Vspm(:,1)/Vsize(1); 0053 Vox(:,2) = - Vspm(:,2)/Vsize(2); 0054 Vox(:,3) = - Vspm(:,3)/Vsize(3); 0055 0056 % Voxcel -> Head 0057 Vhead = Vox * inv(trans_info.trans_head2vox(1:3,1:3)); 0058 0059 % normalization 0060 Vhead = vb_repmultiply(Vhead , 1./sqrt(sum(Vhead.^2, 2)) ); 0061 %Vox = repmultiply(Vox , 1./sqrt(sum(Vox.^2, 2)) ); 0062 % Vox coordinate is not physical coordinate and different scale axis 0063 else 0064 % SPM -> Voxcel 0065 Vox(:,1) = - Vspm(:,1) /Vsize(1) + Vdim(1)*0.5; 0066 Vox(:,2) = - Vspm(:,2) /Vsize(2) + Vdim(2)*0.5; 0067 Vox(:,3) = - Vspm(:,3) /Vsize(3) + Vdim(3)*0.5; 0068 0069 % Voxcel -> Head 0070 Vhead = [Vox ones(NV,1)] * inv(trans_info.trans_head2vox); 0071 end 0072 0073 Vhead = Vhead(:,1:3);