Home > functions > common > morphology > vb_cortex_fill.m

vb_cortex_fill

PURPOSE ^

fill inside of cortex surface

SYNOPSIS ^

function [B, XL, XR] =vb_cortex_fill(V,F,step,Radius,LR_mode,Dim,mask_mode)

DESCRIPTION ^

 fill inside of cortex surface
  [B, XL, XR] = vb_cortex_fill(V,F,step,Radius,LR_mode,Dim,mask_mode)

 皮質面の内部を塗りつぶし3Dマスクパターンに変換
 
--- Input Brain Data

 V     : Cortical vertex point cordinate   [Nvertex, 3]
 F      : Patch index structure
  .F3R     : Right cortex
  .F3L     : Left  cortex
  .F3     : Left + Right
  .NdipoleL  : # of vertex for Left cortex
 
 step    : voxcel size of mask (mm)
 Radius  : morphology radius for smoothing
 LR_mode = 'LR' : Left & Right cortex
         = 'L'  : Left  cortex
         = 'R'  : Right cortex

 if mask_mode == -1, no filling   is done
 if mask_mode ==  0, no morphology is done
 if mask_mode ==  1, morphology is done (Default)
    XLeft = (XLeftCenter + XCenter)/2 : start of filling
 if mask_mode ==  2, morphology is done
    XLeft = XLeftCenter  : start of filling
 Dim : dimension of mask image
 --- Output
 B  : voxcel mask pattern for cortex
 
 XL = Center of Left cortex
 XR = Center of Right cortex


 Made by M. Sato 2007-3-15

 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  [B, XL, XR] = ...
0002             vb_cortex_fill(V,F,step,Radius,LR_mode,Dim,mask_mode)
0003 % fill inside of cortex surface
0004 %  [B, XL, XR] = vb_cortex_fill(V,F,step,Radius,LR_mode,Dim,mask_mode)
0005 %
0006 % 皮質面の内部を塗りつぶし3Dマスクパターンに変換
0007 %
0008 %--- Input Brain Data
0009 %
0010 % V     : Cortical vertex point cordinate   [Nvertex, 3]
0011 % F      : Patch index structure
0012 %  .F3R     : Right cortex
0013 %  .F3L     : Left  cortex
0014 %  .F3     : Left + Right
0015 %  .NdipoleL  : # of vertex for Left cortex
0016 %
0017 % step    : voxcel size of mask (mm)
0018 % Radius  : morphology radius for smoothing
0019 % LR_mode = 'LR' : Left & Right cortex
0020 %         = 'L'  : Left  cortex
0021 %         = 'R'  : Right cortex
0022 %
0023 % if mask_mode == -1, no filling   is done
0024 % if mask_mode ==  0, no morphology is done
0025 % if mask_mode ==  1, morphology is done (Default)
0026 %    XLeft = (XLeftCenter + XCenter)/2 : start of filling
0027 % if mask_mode ==  2, morphology is done
0028 %    XLeft = XLeftCenter  : start of filling
0029 % Dim : dimension of mask image
0030 % --- Output
0031 % B  : voxcel mask pattern for cortex
0032 %
0033 % XL = Center of Left cortex
0034 % XR = Center of Right cortex
0035 %
0036 %
0037 % Made by M. Sato 2007-3-15
0038 %
0039 % Copyright (C) 2011, ATR All Rights Reserved.
0040 % License : New BSD License(see VBMEG_LICENSE.txt)
0041 
0042 if ~exist('LR_mode','var'), LR_mode = 'LR'; end;
0043 if ~exist('mask_mode','var'), mask_mode = 1; end;
0044 
0045 % DEBUG mode flag
0046 debug_mode = 0;
0047 
0048 % Vertex for Left/Right cortex
0049 Ndipole  = size(V,1);
0050 NdipoleL = F.NdipoleL;
0051 NdipoleR = Ndipole - NdipoleL;
0052 
0053 VL = V(1:NdipoleL,:);
0054 VR = V((NdipoleL+1):Ndipole,:);
0055 
0056 %
0057 %------- 左右の脳を塗りつぶす開始位置計算
0058 %
0059 % Center of Left/Right cortex
0060 XL = sum(VL)/(NdipoleL*step);
0061 XR = sum(VR)/(NdipoleR*step);
0062 % Center of (Left-Right)
0063 XC = (XL(1) + XR(1))/2;
0064 
0065 % 左脳を塗りつぶす開始位置
0066 if mask_mode ~=  2
0067     XL(1) = (XL(1) + XC)/2;
0068 end
0069 XL      = round(XL);
0070 % 右脳を塗りつぶす開始位置
0071 if mask_mode ~=  2
0072     XR(1) = (XR(1) + XC)/2;
0073 end
0074 XR      = round(XR);
0075 
0076 %
0077 %-------- マスクパターンの作成 --------
0078 %
0079 
0080 % 三角形分割長さ
0081 dmin   = step/2;
0082 
0083 % Surface patch of Left/Right cortex
0084 switch    LR_mode
0085 case    'LR'
0086     F = F.F3;
0087 case    'L'
0088     F = F.F3L;
0089     V = VL;
0090 case    'R'
0091     F = F.F3R - NdipoleL;
0092     V = VR;
0093 end
0094 
0095 % 脳皮質をマスクに変換
0096 B = vb_surf_to_mask(V,F,step,dmin,Dim);
0097 
0098 if mask_mode == -1 && debug_mode==1,
0099     vb_plot_surf(V,F)
0100     vb_plot_slice( B, [XL], [XL(3)], 1, [1, 1], 20);
0101     title('Left Brain Center')
0102     vb_plot_slice( B, [XR], [XR(3)], 1, [1, 1], 20);
0103     title('Right Brain Center')
0104 end
0105 
0106 if mask_mode == -1, return; end;
0107 
0108 %
0109 %------- 左右の脳を塗りつぶす
0110 
0111 %
0112 % 内部点マスクの値
0113 % voxcel value for filled voxcel
0114 filval = 1;
0115 % 内部点を塗りつぶす時の閾値:この値より小さい値を塗りつぶす
0116 % threshold value for filling in
0117 level  = 0.5;
0118 
0119 switch    LR_mode
0120 case    'LR'
0121     % 左脳内部の塗りつぶし
0122     B = vb_flood_fill_3d(B, XL, filval, level);
0123     % 右脳内部の塗りつぶし
0124     B = vb_flood_fill_3d(B, XR, filval, level);
0125 case    'L'
0126     % 左脳内部の塗りつぶし
0127     B = vb_flood_fill_3d(B, XL, filval, level);
0128 case    'R'
0129     % 右脳内部の塗りつぶし
0130     B = vb_flood_fill_3d(B, XR, filval, level);
0131 end
0132 
0133 if mask_mode == 0, return; end;
0134 if ~exist('Radius','var')| isempty(Radius), return; end;
0135 
0136 %
0137 %-------- モルフォロジー変換 --------
0138 %
0139 
0140 % Radius of Morfology operation
0141 R = Radius/step; 
0142 
0143 % 穴埋め
0144 B = vb_closing_3d(B, R, R);
0145 B = vb_opening_3d(B, R, R);

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