Home > functions > tool_box > load_NIFTI > orientation_tool > get_orient_from_rot.m

get_orient_from_rot

PURPOSE ^

get orientation index vector from rotation matrix

SYNOPSIS ^

function orient = get_orient_from_rot(R)

DESCRIPTION ^

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

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