Transform MNI coordinate to SPM-Right coordinate [Vspm, origin] = convert_mni_spm(Vmni, fname) Vmni ; MNI coordinate (Npoint x 3) fname : file name (patg) of T1 image file Vspm : SPM-Right coordinate origin: origin of MNI cordinate in SPM-Right coordinate Vspm = Vmni + origin; (Vmni = 0 at origin) Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [Vspm, origin] = convert_mni_spm(Vmni, fname) 0002 % Transform MNI coordinate to SPM-Right coordinate 0003 % [Vspm, origin] = convert_mni_spm(Vmni, fname) 0004 % Vmni ; MNI coordinate (Npoint x 3) 0005 % fname : file name (patg) of T1 image file 0006 % Vspm : SPM-Right coordinate 0007 % origin: origin of MNI cordinate in SPM-Right coordinate 0008 % Vspm = Vmni + origin; (Vmni = 0 at origin) 0009 % 0010 % Copyright (C) 2011, ATR All Rights Reserved. 0011 % License : New BSD License(see VBMEG_LICENSE.txt) 0012 0013 Trans = get_coord_trans_mat(fname); 0014 hdr = load_nii_hdr_cbi(fname); 0015 dim = hdr.dime.dim(2:4); 0016 0017 % Trans : transform matrix from voxcel to RAS mm coordinate 0018 % [x y z 1] = [i j k 1] * Trans 0019 % Xstd = Vox * Trans 0020 % Vox = Xstd * inv(Trans) 0021 0022 % Center position of 3D image 0023 center = vb_affine_trans(dim/2 , Trans); 0024 0025 % Get SPM-Right coordinate (center = 0 & mm -> m) 0026 Vspm = vb_repadd(Vmni, -center) * 0.001; 0027 0028 % origin of MNI cordinate in SPM-Right coordinate 0029 origin = -center * 0.001;