Home > functions > common > morphology > vb_make_smooth_cortex_surf.m

vb_make_smooth_cortex_surf

PURPOSE ^

Make cortex surface from brain mask image

SYNOPSIS ^

function [V, F, xx, Xcenter] = vb_make_smooth_cortex_surf(subj_mask,analyzefile,Para)

DESCRIPTION ^

 Make cortex surface from brain mask image
 [V, F, xx, Xcenter] = vb_make_smooth_cortex_surf(subj_mask,analyzefile,Para)
 --- Input 
 analyzefile : Subject analyzefile
 subj_mask   : Subject brain mask file

 Para.gray_val : threshold value for gray matter
   if it is empty, only brain mask is used
   if is is given, voxel with larger intensity than 'val' is selected

 --- バネモデル平滑化パラメタ
 Para.Nvertex = 3000; 出力頂点数
 Para.Radius = [2 -2]; morphological smoothing
 Para.vstep  = 1;   イメージ処理ボクセルサイズ [mm]
 Para.Nloop  = 200; マスク境界フィット繰り返し回数
 Para.Nlast  = 0;   バネモデル平滑化繰り返し回数

 --- Output
 [V, F, xx] : surface vertex, patch index, normal vector
              SPM-right-[m] coordinate
 Xcenter : Center of cortex to separate left/right (SPM-right-[m])

 
 2007/7/05 Masa-aki Sato

 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  [V, F, xx, Xcenter] = vb_make_smooth_cortex_surf(subj_mask,analyzefile,Para)
0002 % Make cortex surface from brain mask image
0003 % [V, F, xx, Xcenter] = vb_make_smooth_cortex_surf(subj_mask,analyzefile,Para)
0004 % --- Input
0005 % analyzefile : Subject analyzefile
0006 % subj_mask   : Subject brain mask file
0007 %
0008 % Para.gray_val : threshold value for gray matter
0009 %   if it is empty, only brain mask is used
0010 %   if is is given, voxel with larger intensity than 'val' is selected
0011 %
0012 % --- バネモデル平滑化パラメタ
0013 % Para.Nvertex = 3000; 出力頂点数
0014 % Para.Radius = [2 -2]; morphological smoothing
0015 % Para.vstep  = 1;   イメージ処理ボクセルサイズ [mm]
0016 % Para.Nloop  = 200; マスク境界フィット繰り返し回数
0017 % Para.Nlast  = 0;   バネモデル平滑化繰り返し回数
0018 %
0019 % --- Output
0020 % [V, F, xx] : surface vertex, patch index, normal vector
0021 %              SPM-right-[m] coordinate
0022 % Xcenter : Center of cortex to separate left/right (SPM-right-[m])
0023 %
0024 %
0025 % 2007/7/05 Masa-aki Sato
0026 %
0027 % Copyright (C) 2011, ATR All Rights Reserved.
0028 % License : New BSD License(see VBMEG_LICENSE.txt)
0029 
0030 % --- バネモデル平滑化パラメタ
0031 if ~isfield(Para,'Nvertex'), Para.Nvertex = 3000; end
0032 if ~isfield(Para,'Radius'),Para.Radius  = [2 -2];end 
0033 if ~isfield(Para,'Nloop'), Para.Nloop = 200; end
0034 if ~isfield(Para,'Nlast'), Para.Nlast = 0; end
0035 if ~isfield(Para,'vstep'), Para.vstep = 1; end;
0036 if ~isfield(Para,'plot_mode'), Para.plot_mode = 0; end
0037 
0038 % Gray matter threshold
0039 if isfield(Para,'gray_val'), 
0040     val = Para.gray_val;
0041 else
0042     val = [];
0043 end
0044 
0045 % Z-slice index for display
0046 zindx = fix([80:15:200]);
0047 
0048 if ~isempty(val),
0049     Nbin = 60;
0050     [hst, x] = vb_get_cortex_histogram(subj_mask,analyzefile,Nbin);
0051     stairs(x,hst);    hold on
0052     plot([val val],[0 max(hst)],'-r'); 
0053     xlim([0 160])
0054     title('histgram of brain region')
0055 end
0056 %
0057 % --- Get subject cortex mask (voxel size = step [mm])
0058 %
0059 step = Para.vstep;
0060 
0061 if    isempty(val)
0062     [avw ,Xcenter] = vb_get_brain_mask(subj_mask,'cortex','', step);
0063 else
0064     [avw ,Xcenter] = vb_get_cortex_mask(subj_mask, analyzefile,'',step,val);
0065 end
0066 
0067 % --- Show boundary of mask
0068 if Para.plot_mode==1,
0069     [xyz] = vb_get_boundary(avw.img);
0070     vb_plot_slice( avw.img, xyz, fix(zindx/step), 1, [3, 3], 1);
0071 end
0072 
0073 %
0074 % --- Extract smooth surface from mask image [analyze_right_mm]
0075 %
0076 [V, F, xx] = vb_mask_to_surf_expand(avw.img, Para);
0077 
0078 %
0079 % --- Plot surface on MRI slice
0080 %
0081 [B, Vdim, Vsize] = vb_load_analyze_to_right(analyzefile);
0082 
0083 Vana  = vb_analyze_mm_to_analyze(V,Vdim,Vsize);
0084 
0085 zindx = fix(zindx/Vsize(3));
0086 dmax  = 10;
0087 xymode=1;
0088 
0089 vb_plot_slice_surf(B, Vana, F, zindx, 'z',[3 3],'r-',dmax,xymode);
0090 
0091 figure
0092 vb_plot_surf(V,F,[],[],1,1);
0093 view([ -130 10]);
0094 
0095 %
0096 % --- SPM-right-[m] coordinate
0097 %
0098 V = vb_analyze_right_mm_to_spm_right(V,Vdim,Vsize);
0099 
0100 
0101 return
0102 
0103 if ~exist('fname','var') | isempty(fname), return; end;
0104 
0105 %
0106 % --- Save file
0107 %
0108 fprintf('Save %s \n',fname)
0109 vb_fsave(fname,'V','F','xx','Xcenter')
0110 
0111 
0112

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