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