0001 function surfw = SurfStatInflate( surf, w, spherefile );
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 if nargin<2
0020 w=0.5;
0021 end
0022 v=size(surf.coord,2);
0023 if v<=81924
0024 if nargin<3
0025 spherefile='sphere.obj';
0026 end
0027 sphere=SurfStatReadSurf(spherefile);
0028 if v==81924
0029 sphere.tri=[sphere.tri sphere.tri+v];
0030 sphere.coord=[sphere.coord(1,:).*(sphere.coord(1,:)<0) ...
0031 -sphere.coord(1,:).*(sphere.coord(1,:)<0);
0032 sphere.coord(2:3,:) sphere.coord(2:3,:)];
0033 else
0034 if mean(surf.coord(1,:))/mean(abs(surf.coord(1,:)))<-0.5
0035 sphere.coord=[sphere.coord(1,:).*(sphere.coord(1,:)<0);
0036 sphere.coord(2:3,:)];
0037 else
0038 sphere.coord=[-sphere.coord(1,:).*(sphere.coord(1,:)<0);
0039 sphere.coord(2:3,:)];
0040 end
0041 end
0042 else
0043 if nargin<3
0044 spherefile='lh.sphere';
0045 end
0046 sphere=SurfStatReadSurf(spherefile);
0047 if v==327684
0048 sphere.tri=[sphere.tri sphere.tri+v];
0049 sphere.coord=[sphere.coord(1,:).*(sphere.coord(1,:)<0) ...
0050 sphere.coord(1,:).*(sphere.coord(1,:)>0);
0051 sphere.coord(2:3,:) sphere.coord(2:3,:)];
0052 else
0053 if mean(surf.coord(1,:))/mean(abs(surf.coord(1,:)))<-0.5
0054 sphere.coord=[sphere.coord(1,:).*(sphere.coord(1,:)<0);
0055 sphere.coord(2:3,:)];
0056 else
0057 sphere.coord=[sphere.coord(1,:).*(sphere.coord(1,:)>0);
0058 sphere.coord(2:3,:)];
0059 end
0060 end
0061 end
0062 maxs=max(surf.coord,[],2);
0063 mins=min(surf.coord,[],2);
0064 maxsp=max(sphere.coord,[],2);
0065 minsp=min(sphere.coord,[],2);
0066 surfw=surf;
0067 for i=1:3
0068 surfw.coord(i,:)=((sphere.coord(i,:)-minsp(i))/(maxsp(i)-minsp(i))...
0069 *(maxs(i)-mins(i))+mins(i))*w+surf.coord(i,:)*(1-w);
0070 end
0071
0072 return
0073 end
0074