Home > functions > common > morphology > vb_smooth_cortex.m

vb_smooth_cortex

PURPOSE ^

Make smooth cortex from brain model by morphological smoothing

SYNOPSIS ^

function [Vx,Fnew,xx,Vindx,Vinfo] = vb_smooth_cortex(V, F, Para)

DESCRIPTION ^

 Make smooth cortex from brain model by morphological smoothing
  [Vnew,Fnew,xxnew,Vindx,Vinfo] = vb_smooth_cortex(V, F, Para)
--- Input 

 V     : Cortical vertex point cordinate , Analyze_right [mm]
 F      : Patch index structure
  .F3R     : Right cortex
  .F3L     : Left  cortex
  .F3     : Left + Right

 Para.Dim      : Dimension of mask image
 Para.vstep    : subsampling step size of mask image [mm]
 Para.R_fill   = [4] :radius for fill-in cortex surface
 Para.R_smooth = [ 6 6 -6 -6] :radius for morphological smoothing
 Para.Nloop    = 200: iteration number for expanding sphere to brain surface
 Para.Nlast    = 0:   iteration number for additional smoothing
 Para.Nvertex  = 3000 : Reduced number of cortex
--- Output 

 Vnew  : Cortical vertex point cordinate     [Nvertex, 3]
 xxnew : Normal vector to cortical surface   [Nvertex, 3]
 Fnew   : Patch index structure
  .F3R     : Right cortex
  .F3L     : Left  cortex
  .F3     : Left + Right
 Vinfo        : Vertex dimension structure
   .Ndipole   : # of vertex
   .NdipoleL  : # of vertex in Left cortex
   .Npatch    : # of patch
   .Coord     = 'Analyze_Right_mm';
 Vindx   : Old vertex index list corresponding to new vertex

 --- Method: 皮質の皺を平滑化した平滑化皮質モデルを作る
 皮質面を3Dマスクパターンに変換
 内部の塗りつぶし & モルフォロジー変換
 内部に球面を作成
 球面をマスクパターンの境界面に膨張
 (バネモデル による平滑化)

 Made by M. Sato 2006-3-28
 Made by M. Sato 2006-11-11
 Made by M. Sato 2007-3-16

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function  [Vx,Fnew,xx,Vindx,Vinfo] = vb_smooth_cortex(V, F, Para)
0002 % Make smooth cortex from brain model by morphological smoothing
0003 %  [Vnew,Fnew,xxnew,Vindx,Vinfo] = vb_smooth_cortex(V, F, Para)
0004 %--- Input
0005 %
0006 % V     : Cortical vertex point cordinate , Analyze_right [mm]
0007 % F      : Patch index structure
0008 %  .F3R     : Right cortex
0009 %  .F3L     : Left  cortex
0010 %  .F3     : Left + Right
0011 %
0012 % Para.Dim      : Dimension of mask image
0013 % Para.vstep    : subsampling step size of mask image [mm]
0014 % Para.R_fill   = [4] :radius for fill-in cortex surface
0015 % Para.R_smooth = [ 6 6 -6 -6] :radius for morphological smoothing
0016 % Para.Nloop    = 200: iteration number for expanding sphere to brain surface
0017 % Para.Nlast    = 0:   iteration number for additional smoothing
0018 % Para.Nvertex  = 3000 : Reduced number of cortex
0019 %--- Output
0020 %
0021 % Vnew  : Cortical vertex point cordinate     [Nvertex, 3]
0022 % xxnew : Normal vector to cortical surface   [Nvertex, 3]
0023 % Fnew   : Patch index structure
0024 %  .F3R     : Right cortex
0025 %  .F3L     : Left  cortex
0026 %  .F3     : Left + Right
0027 % Vinfo        : Vertex dimension structure
0028 %   .Ndipole   : # of vertex
0029 %   .NdipoleL  : # of vertex in Left cortex
0030 %   .Npatch    : # of patch
0031 %   .Coord     = 'Analyze_Right_mm';
0032 % Vindx   : Old vertex index list corresponding to new vertex
0033 %
0034 % --- Method: 皮質の皺を平滑化した平滑化皮質モデルを作る
0035 % 皮質面を3Dマスクパターンに変換
0036 % 内部の塗りつぶし & モルフォロジー変換
0037 % 内部に球面を作成
0038 % 球面をマスクパターンの境界面に膨張
0039 % (バネモデル による平滑化)
0040 %
0041 % Made by M. Sato 2006-3-28
0042 % Made by M. Sato 2006-11-11
0043 % Made by M. Sato 2007-3-16
0044 %
0045 % Copyright (C) 2011, ATR All Rights Reserved.
0046 % License : New BSD License(see VBMEG_LICENSE.txt)
0047 
0048 if ~exist('Para','var'), Para = []; end
0049 
0050 if ~isfield(Para,'Dim') | isempty(Para.Dim)
0051     error('Size of mask image is not specified');
0052 else
0053     Dim = Para.Dim;
0054 end
0055 
0056 % --- subsampling step for mask image [mm]
0057 % 3D 画像処理のための間引きステップサイズ
0058 if ~isfield(Para,'vstep'), 
0059     error('Step size of mask image is not specified');
0060 else
0061     step = Para.vstep;
0062 end;
0063 
0064 % Number of vertex
0065 if ~isfield(Para,'Nvertex'), Para.Nvertex = 3000; end;
0066 
0067 % --- Radius of Morfology operation [mm]
0068 % 穴埋め・孤立点削除 (モルフォロジー) 変換の半径
0069 if ~isfield(Para,'R_fill'),      Para.R_fill   = [4]; end;
0070 if ~isfield(Para,'R_smooth'), Para.R_smooth = [ 6 6 -6 -6]; end;
0071 
0072 % Surface smoothing parameter
0073 if ~isfield(Para,'Nloop'), Para.Nloop = 200; end
0074 if ~isfield(Para,'Nlast'), Para.Nlast = 0; end
0075 if ~isfield(Para,'plot_mode'),Para.plot_mode = 0; end;
0076 
0077 
0078 %
0079 % --- Make mask from LR cortex
0080 %
0081 % 皮質面を3Dマスクパターンに変換
0082 % 内部の塗りつぶし & モルフォロジー変換
0083 %      Dim = size(B)
0084 tic
0085 fprintf('--- Make mask image from cortical surface\n')
0086 B = vb_cortex_fill(V, F, step, Para.R_fill, 'LR', Dim);
0087 vb_ptime(toc)
0088 
0089 % モルフォロジー変換
0090 B = vb_morphology_operation(B, Para.R_smooth, step);
0091 
0092 if  Para.plot_mode > 2,
0093     % subplot の 数
0094     Nfig  = [3, 3];
0095     % スライス画像表示の Z-座標リスト
0096     zindx = [20:10:Dim(3)];
0097     vb_plot_slice( B, [], zindx, 1, Nfig);
0098 end
0099 
0100 %
0101 % --- 3次元データの平滑化
0102 %
0103 tic
0104 fprintf('smoothing\n')
0105 B = smooth3(B,'gaussian',3);
0106 vb_ptime(toc);
0107 
0108 %
0109 %------- マスクパターンの境界面に膨張
0110 %
0111 tic
0112 fprintf('--- Surface expansion\n')
0113 
0114 % 内接球面作成 R = (mean radius of V)
0115 [Vx0, Fx, xx, X0] = vb_make_inner_sphere(V, Para.Nvertex);
0116 
0117 % 境界面に膨張
0118 [Vx, Fx, xx] = vb_surf_smooth_fit(Vx0,Fx,xx, B, Para);
0119 
0120 if Para.plot_mode > 1
0121     dmax = 10;
0122     vb_plot_slice_surf( B, Vx0/step, Fx, X0(1)/step, 'x',[1 1],'r-',dmax);
0123     vb_plot_slice_surf([], Vx/step,  Fx, X0(1)/step, 'x',[1 1],'b-',dmax);
0124     vb_plot_slice_surf( B, Vx0/step, Fx, X0(2)/step, 'y',[1 1],'r-',dmax);
0125     vb_plot_slice_surf([], Vx/step,  Fx, X0(2)/step, 'y',[1 1],'b-',dmax);
0126     vb_plot_slice_surf( B, Vx0/step, Fx, X0(3)/step, 'z',[1 1],'r-',dmax);
0127     vb_plot_slice_surf([], Vx/step,  Fx, X0(3)/step, 'z',[1 1],'b-',dmax);
0128 end
0129 
0130 %
0131 %------- バネモデル による平滑化
0132 %
0133 fprintf('--- Surface smoothing by spring model\n')
0134 
0135 if Para.Nlast > 0,
0136     Para.Nloop = Para.Nlast;     % バネモデル平滑化繰り返し回数
0137     [Vx, Fx, xx] = vb_surf_smooth(Vx,Fx,xx,Para);
0138 end
0139 
0140 vb_ptime(toc)
0141 
0142 if Para.plot_mode > 0
0143     dmax = 10;
0144     vb_plot_slice_surf( B, Vx/step, Fx, X0(1)/step, 'x',[1 1],'r-',dmax);
0145     vb_plot_slice_surf( B, Vx/step, Fx, X0(2)/step, 'y',[1 1],'r-',dmax);
0146     vb_plot_slice_surf( B, Vx/step, Fx, X0(3)/step, 'z',[1 1],'r-',dmax);
0147 end
0148 
0149 Ndipole = size(Vx,1);
0150 Npatch  = size(Fx,1);
0151 
0152 fprintf('# of patches : %d\n',Npatch);
0153 fprintf('# of vertices: %d\n',Ndipole);
0154 
0155 % Find old vertex point corresponding to new vertex
0156 % Zstep : Number of steps to divide Z-axis
0157 % Rmax  : find nearest point within radius Rmax [mm]
0158 Zstep = 100;
0159 Rmax  = 10;
0160 
0161 fprintf('Find original vertex corresponding to the smoothed surface\n')
0162 [Vindx ,ddmin] = vb_find_nearest_point(V, Vx, Rmax, Zstep);
0163 
0164 fprintf('Max distance between new and old vertex = %f [mm]\n',max(ddmin))
0165 
0166 % Find Left/Right cortex
0167 NdipoleL = F.NdipoleL;
0168 
0169 ixL = find(Vindx <= NdipoleL);
0170 ixR = find(Vindx >  NdipoleL);
0171 
0172 % Left/Right ordering
0173 Vix = [ixL ; ixR ];
0174 Vx  = Vx(Vix,:);
0175 NL  = length(ixL);
0176 
0177 Itrans = zeros(Ndipole,1);
0178 Itrans(Vix) = 1:Ndipole;
0179 
0180 Fx = Itrans(Fx);
0181 
0182 Fnew.F3L = vb_patch_select([1:NL],Fx,Ndipole);
0183 Fnew.F3R = vb_patch_select([(NL+1):Ndipole],Fx,Ndipole);
0184 %Fnew.F3 = [Fnew.F3L ; Fnew.F3R];
0185 Fnew.F3  = Fx;
0186 Fnew.NdipoleL = NL ;
0187 
0188 % Dimensional info
0189 Vinfo.NdipoleL  = NL ;
0190 Vinfo.Ndipole   = Ndipole;
0191 Vinfo.Npatch    = Npatch;
0192 Vinfo.Coord     = 'Analyze_Right_mm';

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005