Convert SPM-right-m to MNI-right-m & Talairach coordinate -- Usage [XYZmni , XYZtal, dd] = vb_convert_spm_to_mni(V,snfile) -- Input V : SPM-right-m coordinate [Nveretex * 3] snfile : spatial normalization file created by SPM The normalize transformation is contained. -- Output XYZmni : MNI coordinate (unit:m) [Nveretex * 3] XYZtal : Talairach coordinate (unit:m) [Nveretex * 3] dd : error distance between 'V' and points on the MNI coordinate Masa-aki Sato 2010-1-15 Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [XYZmni , XYZtal, dd] = vb_convert_spm_to_mni(V,snfile) 0002 % Convert SPM-right-m to MNI-right-m & Talairach coordinate 0003 % -- Usage 0004 % [XYZmni , XYZtal, dd] = vb_convert_spm_to_mni(V,snfile) 0005 % 0006 % -- Input 0007 % V : SPM-right-m coordinate [Nveretex * 3] 0008 % snfile : spatial normalization file created by SPM 0009 % The normalize transformation is contained. 0010 % 0011 % -- Output 0012 % XYZmni : MNI coordinate (unit:m) [Nveretex * 3] 0013 % XYZtal : Talairach coordinate (unit:m) [Nveretex * 3] 0014 % dd : error distance between 'V' and points on the MNI coordinate 0015 % 0016 % Masa-aki Sato 2010-1-15 0017 % 0018 % Copyright (C) 2011, ATR All Rights Reserved. 0019 % License : New BSD License(see VBMEG_LICENSE.txt) 0020 0021 Npoint = size(V,1); 0022 0023 % Generate MNI coordinate 0024 % XYZmm - 3 x n matrix of XYZ locations 0025 % mm-coordinates in MNI-space) 0026 Xmax = 100; % Max coordinate 0027 Xmin = -100; % Min coordinate 0028 Xstep = 5; % Step size 0029 0030 % Low resolution coordinate 0031 [X,Y,Z] = ndgrid(Xmin:Xstep:Xmax); 0032 XYZmni = [X(:)'; Y(:)'; Z(:)']; 0033 0034 % High resolution coordinate 0035 [X,Y,Z] = ndgrid(-2*Xstep:2*Xstep); 0036 dXYZ = [X(:)'; Y(:)'; Z(:)']; 0037 Nnear = size(dXYZ,2); 0038 0039 %clear X Y Z 0040 0041 %fprintf('--- Back transformation to subject-image (1st)\n'); 0042 0043 % Back transformation to subject image 0044 sn = load(deblank(snfile)); 0045 %[pXYZmni,flip_flag] = vb_unsn_for_mask(XYZmni,sn); 0046 [pXYZmni] = vb_unsn(XYZmni,sn); 0047 0048 XYZmni = XYZmni'; % mm-coordinates in MNI-coordinate 0049 pXYZmni = pXYZmni'; % mm-coordinates in subject image 0050 0051 %if flip_flag, 0052 % XYZmni(:,1) = -1*XYZmni(:,1); 0053 %end 0054 0055 %fprintf('--- Mapping MNI-coordinate onto a subject-brain (1st)\n'); 0056 0057 % Max radius for search in the 1st-step 0058 Rmax = 10; 0059 % Find nearest point in MNI coordinate for each vertex 'V' 0060 [indx, dd] = vb_find_nearest_point(pXYZmni, V*1000, Rmax, 100, 1, 1); 0061 XYZ = XYZmni(indx,:); 0062 0063 % Generate MNI coordinate near target points 0064 XYZmni = zeros(3,Npoint*Nnear); 0065 nst = 0; 0066 0067 for n=1:Npoint 0068 XYZmni(:, nst+(1:Nnear)) = vb_repadd(dXYZ, XYZ(n,:)'); 0069 nst = nst + Npoint; 0070 end 0071 0072 %fprintf('--- Back transformation to subject-image (2st)\n'); 0073 0074 % Back transformation to subject image 0075 [pXYZmni] = vb_unsn(XYZmni,sn); 0076 0077 XYZmni = XYZmni'; % mm-coordinates in MNI-coordinate 0078 pXYZmni = pXYZmni'; % mm-coordinates in subject image 0079 0080 %if flip_flag, 0081 % XYZmni(:,1) = -1*XYZmni(:,1); 0082 %end 0083 0084 %fprintf('--- Mapping MNI-coordinate onto a subject-brain (2st)\n'); 0085 0086 % Max radius for search in the 2nd-step 0087 Rmax = 2; 0088 % Find nearest point in MNI coordinate for each vertex 'V' 0089 [indx, dd] = vb_find_nearest_point(pXYZmni, V*1000, Rmax, 100, 1, 1); 0090 0091 % XYZmni : MNI-coordinate corresponding to V(:,1:3) 0092 XYZmni = XYZmni(indx,:); 0093 0094 % mni2tal : MNI to Talairach coordinate transformation 0095 XYZtal = mni2tal(XYZmni); 0096 0097 XYZtal = XYZtal/1000; % mm -> m 0098 XYZmni = XYZmni/1000; % mm -> m 0099 dd = dd / 1000; % mm -> m