Home > vbmeg > functions > common > coordinate > vb_vox_to_spm_right.m

vb_vox_to_spm_right

PURPOSE ^

Change SBI-Voxcel coordinate to Right-hand SPM coordinate

SYNOPSIS ^

function Vspm = vb_vox_to_spm_right(V,Vdim,Vsize,nflag)

DESCRIPTION ^

 Change SBI-Voxcel coordinate to Right-hand SPM coordinate
  Vspm = vb_vox_to_spm_right(V)            : normal vector
  Vspm = vb_vox_to_spm_right(V,Vdim,Vsize) : coordinate vector
  Vspm = vb_vox_to_spm_right(V,Vdim,Vsize,nflag)
 ---- Input
 V     : NV x 3 SBI-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-handed SPM coordinate 

 --- MRI-Voxel coordinate   

 [Right-hand coordinate]
 X:Front(1) -> Back(256)
 Y:Top(1)   -> Bottom(256) 
 Z:Left(1)  -> Right(191) 

 --- 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)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    Vspm = vb_vox_to_spm_right(V,Vdim,Vsize,nflag)
0002 % Change SBI-Voxcel coordinate to Right-hand SPM coordinate
0003 %  Vspm = vb_vox_to_spm_right(V)            : normal vector
0004 %  Vspm = vb_vox_to_spm_right(V,Vdim,Vsize) : coordinate vector
0005 %  Vspm = vb_vox_to_spm_right(V,Vdim,Vsize,nflag)
0006 % ---- Input
0007 % V     : NV x 3 SBI-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-handed SPM coordinate
0013 %
0014 % --- MRI-Voxel coordinate
0015 %
0016 % [Right-hand coordinate]
0017 % X:Front(1) -> Back(256)
0018 % Y:Top(1)   -> Bottom(256)
0019 % Z:Left(1)  -> Right(191)
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 
0034 if nargin == 1,
0035     nflag = 1;
0036 elseif nargin < 4, 
0037     nflag = 0; 
0038 end;
0039 
0040 NV   = size(V,1);
0041 Vspm = zeros(NV,3);
0042 
0043 if nflag == 1
0044     Vspm(:,1) = V(:,3);
0045     Vspm(:,2) = - V(:,1);
0046     Vspm(:,3) = - V(:,2);
0047 else
0048     Vspm(:,1) =   V(:,3) - Vdim(1)*Vsize(1)*0.5;
0049     Vspm(:,2) = - V(:,1) + Vdim(2)*Vsize(2)*0.5;
0050     Vspm(:,3) = - V(:,2) + Vdim(3)*Vsize(3)*0.5;
0051 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005