


gets data from image files at specified locations FORMAT [Y] = spm_get_data(V,XYZ); V - [1 x n] struct array of file handles (or filename matrix) XYZ - [4 x m] or [3 x m]location matrix (voxel) Y - (n x m) double values see spm_sample_vol __________________________________________________________________________ Copyright (C) 2005 Wellcome Department of Imaging Neuroscience



0001 function [Y] = nic_spm_get_data(V,XYZ) 0002 % gets data from image files at specified locations 0003 % FORMAT [Y] = spm_get_data(V,XYZ); 0004 % 0005 % V - [1 x n] struct array of file handles (or filename matrix) 0006 % XYZ - [4 x m] or [3 x m]location matrix (voxel) 0007 % 0008 % Y - (n x m) double values 0009 % 0010 % see spm_sample_vol 0011 %__________________________________________________________________________ 0012 % Copyright (C) 2005 Wellcome Department of Imaging Neuroscience 0013 0014 % Karl Friston 0015 % $Id: spm_get_data.m 905 2007-09-04 14:38:28Z guillaume $ 0016 0017 0018 % ensure V is an array of handle structures 0019 %-------------------------------------------------------------------------- 0020 if ~isstruct(V) 0021 V = spm_vol(V); 0022 try 0023 V = cat(2,V{:}); 0024 end 0025 end 0026 0027 % get data 0028 %-------------------------------------------------------------------------- 0029 Y = zeros(length(V),size(XYZ,2)); 0030 for i = 1:length(V) 0031 0032 % check files exists, if not try pwd 0033 %---------------------------------------------------------------------- 0034 if exist(V(i).fname,'file') ~=2 0035 [p,n,e] = fileparts(V(i).fname); 0036 V(i).fname = [n e]; 0037 end 0038 0039 %-Load mask image within current mask & update mask 0040 %---------------------------------------------------------------------- 0041 Y(i,:) = spm_sample_vol(V(i),XYZ(1,:),XYZ(2,:),XYZ(3,:),0); 0042 end 0043