Home > vbmeg > functions > tool_box > neuromag > neuro_head_to_spm_right.m

neuro_head_to_spm_right

PURPOSE ^

Change Neuromag-Head coordinate to Right-hand SPM [m] coordinate

SYNOPSIS ^

function [Vspm, Vox] = neuro_head_to_spm_right(Vhead,trans_info,Vdim,nflag)

DESCRIPTION ^

 Change Neuromag-Head coordinate to Right-hand SPM [m] coordinate
  Point coordinate 
  Vspm = neuro_head_to_spm_right(Vhead,trans_info,Vdim)
  Normal vector
  Vspm = neuro_head_to_spm_right(Vhead,trans_info,Vdim, 1)
 ---- Input
 Vhead : NV x 3 Neuromag-Head coordinate
 trans_info
       .trans_head2vox : [4 x 4 double]
                       : transformation matrix (HEAD(RAS) ==> Voxel)
       .trans_vox2mri  : [4 x 4 double]
                       : transformation matrix (VOXEL ==> MRI(RAS))
 Vdim  : Voxel dimension
 nflag = 0 : coordinate transformation (default)
       = 1 : normal vector transformation
           : no translation is applied
 ---- Output
 Vspm : NV x 3 right-handed SPM coordinate 
 Vox  : NV x 3 left-handed Voxel coordinate 


 --- SPM coordinate (RAS)
 X: Left(-191/2)   -> Right(191/2) 
 Y: Back(-256/2)   -> Front(256/2)
 Z: Bottom(-256/2) -> Top(256/2) 

 --- Head coordinate(RAS)
 X : from left to right
 Y : from back to front
 Z : from bottom to up

 Masa-aki Sato 2009-4-13

 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, Vox] = neuro_head_to_spm_right(Vhead,trans_info,Vdim,nflag)
0002 % Change Neuromag-Head coordinate to Right-hand SPM [m] coordinate
0003 %  Point coordinate
0004 %  Vspm = neuro_head_to_spm_right(Vhead,trans_info,Vdim)
0005 %  Normal vector
0006 %  Vspm = neuro_head_to_spm_right(Vhead,trans_info,Vdim, 1)
0007 % ---- Input
0008 % Vhead : NV x 3 Neuromag-Head coordinate
0009 % trans_info
0010 %       .trans_head2vox : [4 x 4 double]
0011 %                       : transformation matrix (HEAD(RAS) ==> Voxel)
0012 %       .trans_vox2mri  : [4 x 4 double]
0013 %                       : transformation matrix (VOXEL ==> MRI(RAS))
0014 % Vdim  : Voxel dimension
0015 % nflag = 0 : coordinate transformation (default)
0016 %       = 1 : normal vector transformation
0017 %           : no translation is applied
0018 % ---- Output
0019 % Vspm : NV x 3 right-handed SPM coordinate
0020 % Vox  : NV x 3 left-handed Voxel coordinate
0021 %
0022 %
0023 % --- SPM coordinate (RAS)
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 % --- Head coordinate(RAS)
0029 % X : from left to right
0030 % Y : from back to front
0031 % Z : from bottom to up
0032 %
0033 % Masa-aki Sato 2009-4-13
0034 %
0035 % Copyright (C) 2011, ATR All Rights Reserved.
0036 % License : New BSD License(see VBMEG_LICENSE.txt)
0037 
0038 if nargin < 3, error('Input argument error'); end
0039 if nargin < 4, nflag = 0; end;
0040 
0041 NV   = size(Vhead,1);
0042 Vspm = zeros(NV,3);
0043 
0044 % Get permutation matrix from rotation matrix
0045 % trans_vox2mri : rotation + flip + scaling
0046 % Rspm : transform matrix corresponding to axis permutation + flip + scaling
0047 Rspm = get_transform_axis( trans_info.trans_vox2mri(1:3,1:3) );
0048 
0049 if nflag == 1
0050     % Unit vector rotation
0051     % Head -> Voxel
0052     Vox  = Vhead * trans_info.trans_head2vox(1:3,1:3);
0053     
0054     % Voxel -> MRI/SPM
0055     Vspm = Vox * Rspm;
0056     
0057     % normalization
0058     Vspm = vb_repmultiply(Vspm, 1./sqrt(sum(Vspm.^2, 2)) );
0059     %Vox  = repmultiply(Vox , 1./sqrt(sum(Vox.^2, 2)) );
0060     % Vox coordinate is not physical coordinate and different scale axis
0061 else
0062     % Head -> Voxel
0063     Vox  = [Vhead ones(NV,1)] * trans_info.trans_head2vox;
0064     
0065     % center origin
0066     Vspm(:,1) =  ( Vox(:,1) - Vdim(1)*0.5 );
0067     Vspm(:,2) =  ( Vox(:,2) - Vdim(2)*0.5 );
0068     Vspm(:,3) =  ( Vox(:,3) - Vdim(3)*0.5 );
0069     
0070     % MRI(RAS) [m] only differs origin with SPM-Right
0071     Vspm = Vspm * Rspm;
0072 
0073 end
0074 
0075 Vox = Vox(:,1:3);

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