Doxygen Source Code Documentation
AfniIndex2AfniXYZ.m
Go to the documentation of this file.00001 function [err, XYZ] = AfniIndex2AfniXYZ (Indx, Nxx, Nyy)
00002 %
00003 % [err, XYZ] = AfniIndex2AfniXYZ (Indx, Nxx, Nyy);
00004 %
00005 % Returns the XYZ coordinates of an AFNI voxel with
00006 % an AFNI index of Indx
00007 %
00008 % Indx : Nx1 vector containing the AFNI indices
00009 % Indx must be an integer vector. If it is not, it's values
00010 % are rounded to the nearest integer
00011 %
00012 % Nxx, Nyy : Number of pixels in the slice in the X and Y directions
00013 %
00014 % err = 0 No problem
00015 % err = 1 input Matrix size problems
00016 %
00017 % XYZ : is the XYZ triplets matrix Nx3
00018 %
00019 % Ziad Saad Sun Mar 15 19:24:39 CST 1998
00020
00021 [n1,m1] = size(Indx);
00022
00023 if (m1 ~= 1),
00024 fprintf (1,'\a\nError in AfniIndex2AfniXYZ : Bad size for Indx\n\n');
00025 err = 1;
00026 return;
00027 end
00028
00029 Indx = round (Indx);
00030
00031 NxxNyy = Nxx .* Nyy;
00032
00033 Z = floor (Indx ./ NxxNyy);
00034 Y = floor ((Indx - Z .* NxxNyy) ./ Nxx);
00035 X = Indx - ( Y .* Nxx) - (Z .* NxxNyy) ;
00036
00037 XYZ = [X Y Z];
00038
00039 err = 0;
00040 return;