Transform coordinate of individual brain to the MNI starndard brain. -- Usage [XYZmni , IMGinfo] = trans_subj_mni_coord(V,parm) V : vertex coordinate [Npoint x 3] SPM-right-mm -- Input (Fields in 'parm' struct) parm.brainfile -- Output XYZmni : MNI coordinate (unit:mm) [Npoint * 3] IMGinfo.dd : error distance between 'V' and points on the MNI brain 2014-11-10 Masa-aki Sato 2016-6-1 M Sato Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [XYZmni , IMGinfo] = trans_subj_mni_coord(V,parm) 0002 % Transform coordinate of individual brain to the MNI starndard brain. 0003 % 0004 % -- Usage 0005 % [XYZmni , IMGinfo] = trans_subj_mni_coord(V,parm) 0006 % V : vertex coordinate [Npoint x 3] SPM-right-mm 0007 % -- Input (Fields in 'parm' struct) 0008 % parm.brainfile 0009 % -- Output 0010 % XYZmni : MNI coordinate (unit:mm) [Npoint * 3] 0011 % IMGinfo.dd : error distance between 'V' and points on the MNI brain 0012 % 0013 % 2014-11-10 Masa-aki Sato 0014 % 2016-6-1 M Sato 0015 % 0016 % Copyright (C) 2011, ATR All Rights Reserved. 0017 % License : New BSD License(see VBMEG_LICENSE.txt) 0018 0019 % Max radius to check minimum distance to corresponding point [mm] 0020 if isfield(parm,'Rlimit') 0021 Rlimit = parm.Rlimit; 0022 else 0023 Rlimit = 4; 0024 end 0025 0026 % Max radius to search corresponding point [mm] in the 1st-step 0027 if isfield(parm,'Rmax') 0028 Rmax = parm.Rmax; 0029 else 0030 Rmax = 2; 0031 end 0032 0033 % In the 1st-step, nearest point is searched within Rmax 0034 % In the 2nd-step, nearest point is searched for all candidates 0035 % This value determine, efficiency of search, 0036 % but does not change the result 0037 0038 %%% 0039 %%% Backward coordinate transformation 0040 %%% from the template brain to a subject's brain 0041 %%% Template file is neurological format (right handed spm). 0042 0043 Npoint = size(V,1); 0044 0045 Vref = vb_load_cortex(parm.brainfile, 'subj'); 0046 Vmni = vb_load_cortex(parm.brainfile, 'MNI'); 0047 0048 %%% 0049 %%% Map MNI-coordinate to individual's cortical surface 0050 %%% 0051 0052 fprintf('--- Mapping MNI-coordinate onto a subject-brain \n'); 0053 0054 % Find nearest point in atlas for each vertex 'V' 0055 %[indx, dd] = vb_find_nearest_point(pXYZmni, V*1000, Rmax, 100, 1, 1); 0056 [indx, dd] = vb_find_nearest_point(Vref*1000, V, Rmax, 100, 1, 1); 0057 0058 % Map template-coordinate to subject cortex 0059 % XYZmni : MNI-coordinate corresponding to V(:,1:3) 0060 XYZmni = Vmni(indx,:)*1000; 0061 0062 % Number of points whose minimum distance is less than Rlimit 0063 ix_match = find( dd <= Rlimit ); 0064 Nmatch = length(ix_match); 0065 0066 IMGinfo.dd = dd; 0067 0068 0069 fprintf('# of points = %d\n',Npoint) 0070 fprintf('# of points ( d <= %3.0f mm ) = %d\n',Rlimit,Nmatch) 0071 fprintf('# of points ( d > %3.0f mm ) = %d\n',Rlimit,Npoint - Nmatch) 0072 fprintf('dmax = %4.1f mm \n', max(dd)) 0073 %fprintf('[Xmin, Ymin, Zmin] = %6.1f %6.1f %6.1f\n',xmin) 0074