Home > SurfStat > SurfStatInflate.m

SurfStatInflate

PURPOSE ^

Inflates a surface towards two fitted hemi-ellipsoids.

SYNOPSIS ^

function surfw = SurfStatInflate( surf, w, spherefile );

DESCRIPTION ^

Inflates a surface towards two fitted hemi-ellipsoids.

 Usage: surfw = SurfStatInflate( surf [, w [, spherefile ]] );

 surf.coord  = 3 x v matrix of coordinates, v=#vertices.
 w           = weight in [0,1] given to hemi-ellipsoids, default 0.5.
 spherefile  = file name of a sphere surface for the left hemisphere. If
               it is a .obj file, it assumes that the triangulation of the
               right hemisphere is a mirror image; if it is an FS file,
               then it assumes it is identical. The default is sphere.obj
               for a 40962 vertex (v=81924 for both hemispheres)
               icosahedral mesh, or lh.sphere for a 163842 vertex
               (v=327684 for both hemispheres) icosahedral mesh.

 surfw.coord = 3 x v matrix of inflated coordinates.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function surfw = SurfStatInflate( surf, w, spherefile );
0002 
0003 %Inflates a surface towards two fitted hemi-ellipsoids.
0004 %
0005 % Usage: surfw = SurfStatInflate( surf [, w [, spherefile ]] );
0006 %
0007 % surf.coord  = 3 x v matrix of coordinates, v=#vertices.
0008 % w           = weight in [0,1] given to hemi-ellipsoids, default 0.5.
0009 % spherefile  = file name of a sphere surface for the left hemisphere. If
0010 %               it is a .obj file, it assumes that the triangulation of the
0011 %               right hemisphere is a mirror image; if it is an FS file,
0012 %               then it assumes it is identical. The default is sphere.obj
0013 %               for a 40962 vertex (v=81924 for both hemispheres)
0014 %               icosahedral mesh, or lh.sphere for a 163842 vertex
0015 %               (v=327684 for both hemispheres) icosahedral mesh.
0016 %
0017 % surfw.coord = 3 x v matrix of inflated coordinates.
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

Generated on Fri 26-Sep-2008 14:05:29 by m2html © 2003