returns values from all the images at points given in XYZmm FORMAT vals = point_vals(obj, XYZmm, holdlist) (for the following, I is number of images in object, N is the number of points to resample from) Input obj - object XYZmm - 3xN XYZ natrix of points (in mm) holdlist - optional 1xI vector of resample hold values Outputs vals - IxN vector of values in images $Id: point_vals.m,v 1.1 2005/04/20 15:05:36 matthewbrett Exp $
0001 function vals = point_vals(obj, XYZmm, holdlist) 0002 % returns values from all the images at points given in XYZmm 0003 % FORMAT vals = point_vals(obj, XYZmm, holdlist) 0004 % 0005 % (for the following, I is number of images in object, N is the number 0006 % of points to resample from) 0007 % Input 0008 % obj - object 0009 % XYZmm - 3xN XYZ natrix of points (in mm) 0010 % holdlist - optional 1xI vector of resample hold values 0011 % 0012 % Outputs 0013 % vals - IxN vector of values in images 0014 % 0015 % $Id: point_vals.m,v 1.1 2005/04/20 15:05:36 matthewbrett Exp $ 0016 0017 if nargin < 2 0018 error('Need XYZmm'); 0019 end 0020 if nargin < 3 0021 holdlist = [obj.img(:).hold]; 0022 end 0023 0024 X=1;Y=2;Z=3; 0025 nimgs = length(obj.img); 0026 nvals = size(XYZmm,2); 0027 vals = zeros(nimgs,nvals)+NaN; 0028 if size(XYZmm,1)~=4 0029 XYZmm = [XYZmm(X:Z,:); ones(1,nvals)]; 0030 end 0031 for i = 1:nimgs 0032 I = obj.img(i); 0033 XYZ = I.vol.mat\XYZmm; 0034 if ~mars_struct('isthere', I.vol, 'imgdata') 0035 vol = I.vol; 0036 else 0037 vol = I.vol.imgdata; 0038 end 0039 vals(i,:) = spm_sample_vol(vol, XYZ(X,:), XYZ(Y,:),XYZ(Z,:),[holdlist(i) ... 0040 I.background]); 0041 end 0042 return 0043