0001 function s = SurfStatVol2Surf( vol, surf );
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if isnumeric(surf.coord)
0017 v=size(surf.coord,2);
0018 one=ones(v,1);
0019 if ndims(surf.coord)==2
0020 vox=(double(surf.coord')-one*vol.origin)./(one*vol.vox(1:3))+1;
0021 s=interpn(vol.data,vox(:,1),vox(:,2),vox(:,3),'linear',0);
0022 else
0023 n=size(surf.coord,1);
0024 s=zeros(v,1);
0025 fprintf(1,'%s',[num2str(n) ' surfaces to interpolate, % remaining: 100 ']);
0026 n10=floor(n/10);
0027 for i=1:n
0028 if rem(i,n10)==0
0029 fprintf(1,'%s',[num2str(round(100*(1-i/n))) ' ']);
0030 end
0031 c=double(squeeze(surf.coord(i,:,:)));
0032 vox=(c-one*vol.origin)./(one*vol.vox(1:3))+1;
0033 s=s+interpn(vol.data,vox(:,1),vox(:,2),vox(:,3),'linear',0);
0034 end
0035 s=s'/n;
0036 fprintf(1,'%s\n','Done');
0037 end
0038 else
0039 sz=surf.coord.Format{2};
0040 v=sz(1);
0041 n=sz(3);
0042 one=ones(v,1);
0043 s=zeros(v,1);
0044 fprintf(1,'%s',[num2str(n) ' surfaces to interpolate, % remaining: 100 ']);
0045 n10=floor(n/10);
0046 for i=1:n
0047 if rem(i,n10)==0
0048 fprintf(1,'%s',[num2str(round(100*(1-i/n))) ' ']);
0049 end
0050 c=double(surf.coord.Data(1).Data(:,:,i));
0051 vox=(c-one*vol.origin)./(one*vol.vox(1:3))+1;
0052 s=s+interpn(vol.data,vox(:,1),vox(:,2),vox(:,3),'linear',0);
0053 end
0054 s=s'/n;
0055 fprintf(1,'%s\n','Done');
0056 end
0057
0058 return
0059 end