change Analyze Left-hand voxcel coordinate to Right-hand SPM (m) coord. Vspm = vb_analyze_to_spm_right(Vana) : normal vector Vspm = vb_analyze_to_spm_right(Vana,Vdim,Vsize) : coordinate vector Vspm = vb_analyze_to_spm_right(Vana,Vdim,Vsize,nflag) --- Input Vana : NV x 3 Analyze Left-hand voxcel coordinate Vdim : Voxel dimension of Analyze image Vsize : Voxel size of Analyze image nflag = 1 : normal vector : no translation and scaling is applied --- Output Vspm : NV x 3 Right-hand SPM (m) coord. --- Analyze voxcel coordinate [Left-hand coordinate] X: Right(1) -> Left(191) Y: Back(1) -> Front(256) Z: Bottom(1) -> Top(256) --- SPM coordinate [Right-hand coordinate] X: Left(-191/2) -> Right(191/2) Y: Back(-256/2) -> Front(256/2) Z: Bottom(-256/2) -> Top(256/2) written by M. Sato 2005-8-1 Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function Vspm = vb_analyze_to_spm_right(Vana,Vdim,Vsize,nflag) 0002 % change Analyze Left-hand voxcel coordinate to Right-hand SPM (m) coord. 0003 % Vspm = vb_analyze_to_spm_right(Vana) : normal vector 0004 % Vspm = vb_analyze_to_spm_right(Vana,Vdim,Vsize) : coordinate vector 0005 % Vspm = vb_analyze_to_spm_right(Vana,Vdim,Vsize,nflag) 0006 % --- Input 0007 % Vana : NV x 3 Analyze Left-hand voxcel coordinate 0008 % Vdim : Voxel dimension of Analyze image 0009 % Vsize : Voxel size of Analyze image 0010 % nflag = 1 : normal vector : no translation and scaling is applied 0011 % --- Output 0012 % Vspm : NV x 3 Right-hand SPM (m) coord. 0013 % 0014 % --- Analyze voxcel coordinate 0015 % 0016 % [Left-hand coordinate] 0017 % X: Right(1) -> Left(191) 0018 % Y: Back(1) -> Front(256) 0019 % Z: Bottom(1) -> Top(256) 0020 % 0021 % --- SPM coordinate 0022 % 0023 % [Right-hand coordinate] 0024 % X: Left(-191/2) -> Right(191/2) 0025 % Y: Back(-256/2) -> Front(256/2) 0026 % Z: Bottom(-256/2) -> Top(256/2) 0027 % 0028 % written by M. Sato 2005-8-1 0029 % 0030 % Copyright (C) 2011, ATR All Rights Reserved. 0031 % License : New BSD License(see VBMEG_LICENSE.txt) 0032 0033 if nargin == 1, 0034 nflag = 1; 0035 elseif nargin < 4, 0036 nflag = 0; 0037 end; 0038 0039 if nflag == 1, 0040 Vspm(:,1) = -Vana(:,1); 0041 return; 0042 end; 0043 0044 NV = size(Vana,1); 0045 Vspm = zeros(NV,3); 0046 0047 Vspm(:,1) = -( Vana(:,1) - Vdim(1)*0.5 )*Vsize(1); 0048 Vspm(:,2) = ( Vana(:,2) - Vdim(2)*0.5 )*Vsize(2); 0049 Vspm(:,3) = ( Vana(:,3) - Vdim(3)*0.5 )*Vsize(3); 0050 0051 % Change [mm] to [m] 0052 Vspm = Vspm*0.001;