function [oriention] = nic_ShowOrientation(Head)
% Get the orientation of data with format of Nifti according to the header (Head) 
% and print the infomation of orientation (dim0, dim1, dim2).
%
% Usage: [oriention] = nic_ShowOrientation(Head)
%
% Input:
% 1. Head - the header of data with format of Nifti, a structure of SPM5
% Output:
% 1. orientation - a string text show the orientation of image, E.G. 'LPI', 'RPI', ...
%
%____________________________________________________________________________
% Copyright (C) 2007 Neuroimage Computing Group, State Key Laboratory of
% Cognitive Neuroscience and Learning
%
% Guiwen Chen, gwenchill@gmail.com
% @(#)nic_ShowOrientation.m  ver 1.0, 07/11/23

% the mat in the header
mat=Head.mat;
%mat1=abs(mat);
str=[];

for (k=1:3),
	mas=mat(k,k);
	  switch(k)
	  case 1
		if(mas>0)
		   str=[str,'L'];
		   t=sprintf('Dim%d: Left ¡ú Right',k-1);
		else
		   str=[str,'R'];
		   t=sprintf('Dim%d: Right ¡ú Left',k-1);
		end
		disp(t);
	  case 2
		if(mas>0)
		   str=[str,'P'];
		   t=sprintf('Dim%d: Posterior ¡ú Anterior',k-1);
		else
		   str=[str,'A'];
		   t=sprintf('Dim%d: Anterior ¡ú Posterior',k-1);
		end
		disp(t);
	  case 3
		if(mas>0)
		   str=[str,'I'];
		   t=sprintf('Dim%d: Inferior ¡ú Superior',k-1);
		else
		   str=[str,'S'];
		   t=sprintf('Dim%d: Superior ¡ú Inferior',k-1);
		end
		disp(t);
	  otherwise
		str=[];
	  end
	  oriention=str;
end
