Home > vbmeg > functions > tool_box > load_NIFTI > orientation_tool > get_rot_from_orient.m

get_rot_from_orient

PURPOSE ^

get rotation matrix from orientation index vector

SYNOPSIS ^

function R = get_rot_from_orient(orient)

DESCRIPTION ^

 get rotation matrix from orientation index vector
 R = get_rot_from_orient(orient)
 --- orient
 orient : axis dim to get RAS coordinate
        = [orient_x  orient_y  orient_z]
 orient_x : Left to Right axis dim of current image
 orient_y : Posterior to Anterior axis dim of current image
 orient_z : Inferior  to Superior  axis dim of current image
            current image axis dim is [+-1/+-2/+-3] for [+-x/+-y/+-z]
 
 Left to Right           1
 Posterior to Anterior   2
 Inferior to Superior    3
 Right to Left          -1
 Anterior to Posterior  -2
 Superior to Inferior   -3

  Part of this file is copied and modified under GNU license from
  NIFTI TOOLBOX developed by Jimmy Shen

 Made by Masa-aki Sato 2008-02-17

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function R = get_rot_from_orient(orient)
0002 % get rotation matrix from orientation index vector
0003 % R = get_rot_from_orient(orient)
0004 % --- orient
0005 % orient : axis dim to get RAS coordinate
0006 %        = [orient_x  orient_y  orient_z]
0007 % orient_x : Left to Right axis dim of current image
0008 % orient_y : Posterior to Anterior axis dim of current image
0009 % orient_z : Inferior  to Superior  axis dim of current image
0010 %            current image axis dim is [+-1/+-2/+-3] for [+-x/+-y/+-z]
0011 %
0012 % Left to Right           1
0013 % Posterior to Anterior   2
0014 % Inferior to Superior    3
0015 % Right to Left          -1
0016 % Anterior to Posterior  -2
0017 % Superior to Inferior   -3
0018 %
0019 %  Part of this file is copied and modified under GNU license from
0020 %  NIFTI TOOLBOX developed by Jimmy Shen
0021 %
0022 % Made by Masa-aki Sato 2008-02-17
0023 
0024 % --- sform transform
0025 % i = 0 .. dim[1]-1
0026 % j = 0 .. dim[2]-1
0027 % k = 0 .. dim[3]-1
0028 % x = srow_x[0] * i + srow_x[1] * j + srow_x[2] * k + srow_x[3]
0029 % y = srow_y[0] * i + srow_y[1] * j + srow_y[2] * k + srow_y[3]
0030 % z = srow_z[0] * i + srow_z[1] * j + srow_z[2] * k + srow_z[3]
0031 % --- matrix form
0032 % [x ; y ; z] = R * [i ; j ; k] + T
0033 
0034 R = zeros(3,3);
0035 
0036 for i = 1:3
0037    ix = abs(orient(i));
0038    R(i,ix) = sign(orient(i));
0039 end
0040 
0041 return;

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