0001 function [V, F, xx, Xcenter] = vb_make_smooth_cortex_surf(subj_mask,analyzefile,Para)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
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
0039 if isfield(Para,'gray_val'),
0040 val = Para.gray_val;
0041 else
0042 val = [];
0043 end
0044
0045
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
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
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
0075
0076 [V, F, xx] = vb_mask_to_surf_expand(avw.img, Para);
0077
0078
0079
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
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
0107
0108 fprintf('Save %s \n',fname)
0109 vb_fsave(fname,'V','F','xx','Xcenter')
0110
0111
0112