Doxygen Source Code Documentation
AFNI_OrientCode.m
Go to the documentation of this file.00001 function [err, Vo, DS] = AFNI_OrientCode (V)
00002 %
00003 % [err, Vo, DirSign] = AFNI_OrientCode (V)
00004 %
00005 %Purpose:
00006 % Changes the orientation code from number to letters and vice versa
00007 %
00008 %
00009 %Input Parameters:
00010 % V, a 3x1 vector of numbers or characters
00011 % like [0 2 4] or 'RPI'
00012 %
00013 %
00014 %Output Parameters:
00015 % err : 0 No Problem
00016 % : 1 Mucho Problems
00017 % Vo, a 3x1 vector of numbers or characters corresponding to the input
00018 % DirSign: is a 3x1 vector of +1 or -1 indicating whether the ith
00019 % dimension of Vo is of the same direction (+1) or not (-1)
00020 % with AFNI's colinear equivalent in the R A I convention.
00021 %
00022 %
00023 %
00024 %Key Terms:
00025 %
00026 %More Info :
00027 % AFNI .HEAD files
00028 % BrikInfo
00029 % [err, Vo, DirSign] = AFNI_OrientCode ([0 3 4]); Vo, DirSign
00030 % or
00031 % [err, Vo, DirSign] = AFNI_OrientCode ('SAR');Vo, DirSign
00032 %
00033 % Author : Ziad Saad
00034 % Date : Tue Sep 5 19:09:52 PDT 2000
00035 % LBC/NIMH/ National Institutes of Health, Bethesda Maryland
00036
00037
00038 %Define the function name for easy referencing
00039 FuncName = 'AFNI_OrientCode';
00040
00041 %Debug Flag
00042 DBG = 1;
00043
00044 %initailize return variables
00045 err = 1;
00046 Vo = [];DS = [];
00047
00048 if (length(V) ~= 3),
00049 err = ErrEval(FuncName,'Err_Bad code length');
00050 return;
00051 end
00052
00053 if (ischar(V)),
00054 Vo = [-1 -1 -1];
00055 for (i=1:1:3),
00056 switch V(i),
00057 case 'R'
00058 Vo(i) = 0;
00059 DS(i) = 1;
00060 case 'L'
00061 Vo(i) = 1;
00062 DS(i) = -1;
00063 case 'P'
00064 Vo(i) = 2;
00065 DS(i) = -1;
00066 case 'A'
00067 Vo(i) = 3;
00068 DS(i) = 1;
00069 case 'I'
00070 Vo(i) = 4;
00071 DS(i) = 1;
00072 case 'S'
00073 Vo(i) = 5;
00074 DS(i) = -1;
00075 otherwise,
00076 err = ErrEval(FuncName,'Err_Cannot understand Orientation code');
00077 return;
00078 end
00079 end
00080 else
00081 Vo = ['-' '-' '-'];
00082 for (i=1:1:3),
00083 switch V(i),
00084 case 0
00085 Vo(i) = 'R';
00086 DS(i) = 1;
00087 case 1
00088 Vo(i) = 'L';
00089 DS(i) = -1;
00090 case 2
00091 Vo(i) = 'P';
00092 DS(i) = -1;
00093 case 3
00094 Vo(i) = 'A';
00095 DS(i) = 1;
00096 case 4
00097 Vo(i) = 'I';
00098 DS(i) = 1;
00099 case 5
00100 Vo(i) = 'S';
00101 DS(i) = -1;
00102 otherwise,
00103 err = ErrEval(FuncName,'Err_Cannot understand Orientation code');
00104 return;
00105 end
00106 end
00107 end
00108
00109
00110
00111
00112 err = 0;
00113 return;
00114