Home > functions > common > coordinate > vb_bvoyger_to_vox.m

vb_bvoyger_to_vox

PURPOSE ^

change BrainVoyger coordinate to SBI-Voxcel coordinate

SYNOPSIS ^

function Vox = vb_bvoyger_to_vox(V,Vdim,Vsize,nflag)

DESCRIPTION ^

 change BrainVoyger coordinate to SBI-Voxcel coordinate
  Vox = vb_bvoyger_to_vox(V)            : normal vector
  Vox = vb_bvoyger_to_vox(V,Vdim,Vsize) : coordinate vector
  Vox = vb_bvoyger_to_vox(V,Vdim,Vsize,nflag)
 --- Input
 V     : NV x 3 BrainVoyger coordinate
 Vdim  : Voxel dimension of Analyze image
 Vsize : Voxel size of Analyze image
 nflag = 1 : normal vector : no translation and scaling is applied
 --- Output
 Vox   : NV x 3 SBI-Voxcel coordinate

 --- Brain-Voyager coordinate (1 voxcel size = mm)

 [Left-hand coordinate]
 X:Front(0) -> Back(255)
 Y:Top(0)   -> Bottom(255)
 Z:Right(0) -> Left(255)

 --- MRI-Voxel coordinate   

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

 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    Vox = vb_bvoyger_to_vox(V,Vdim,Vsize,nflag)
0002 % change BrainVoyger coordinate to SBI-Voxcel coordinate
0003 %  Vox = vb_bvoyger_to_vox(V)            : normal vector
0004 %  Vox = vb_bvoyger_to_vox(V,Vdim,Vsize) : coordinate vector
0005 %  Vox = vb_bvoyger_to_vox(V,Vdim,Vsize,nflag)
0006 % --- Input
0007 % V     : NV x 3 BrainVoyger 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 % Vox   : NV x 3 SBI-Voxcel coordinate
0013 %
0014 % --- Brain-Voyager coordinate (1 voxcel size = mm)
0015 %
0016 % [Left-hand coordinate]
0017 % X:Front(0) -> Back(255)
0018 % Y:Top(0)   -> Bottom(255)
0019 % Z:Right(0) -> Left(255)
0020 %
0021 % --- MRI-Voxel coordinate
0022 %
0023 % [Right-hand coordinate]
0024 % X:Front(1) -> Back(256)
0025 % Y:Top(1)   -> Bottom(256)
0026 % Z:Left(1)  -> Right(191)
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     Vox = V;
0041     Vox(:,3) = - V(:,3);
0042 else
0043     NV  = size(V,1);
0044     Vox = zeros(NV,3);
0045     
0046     Vox(:,1) = V(:,1) + 1; 
0047     Vox(:,2) = V(:,2) + 1; 
0048     Vox(:,3) = 256 - V(:,3) - fix( (256 - Vdim(1)*Vsize(1))/2 );
0049 end

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005