0001 function [B, F, V, Vmiss, Fmiss] = vb_face_extract_trial(imagefile,Para)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 if ~exist('Para','var'), Para.job_mode = 1; end;
0016
0017 if ~isfield(Para,'job_mode'),
0018 job_mode = 1;
0019 else
0020 job_mode = Para.job_mode ;
0021 end;
0022 if ~isfield(Para,'plot_mode'),
0023 plot_mode = 1;
0024 else
0025 plot_mode = Para.plot_mode ;
0026 end;
0027 if ~isfield(Para,'Radius'),
0028 Radius = [ -2 2 ];
0029 else
0030 Radius = Para.Radius ;
0031 end;
0032 if ~isfield(Para,'step'),
0033 step = 2;
0034 else
0035 step = Para.step ;
0036 end;
0037 if ~isfield(Para,'Bval'),
0038 Bval = [];
0039 else
0040 Bval = Para.Bval ;
0041 end;
0042 if ~isfield(Para,'pmax'),
0043 pmax = 0.998;
0044 Bval = [];
0045 else
0046 pmax = Para.pmax ;
0047 Bval = [];
0048 end;
0049 if ~isfield(Para,'zmin'),
0050 zmin = 10;
0051 else
0052 zmin = Para.zmin;
0053 end;
0054
0055 if ~isfield(Para,'zindx'),
0056
0057 zindx = [40:20:200];
0058 else
0059 zindx = Para.zindx;
0060 end;
0061 if ~isfield(Para,'Nfig'),
0062
0063 Nfig = [3, 3];
0064 else
0065 Nfig = Para.Nfig ;
0066 end;
0067 if ~isfield(Para,'Msize'),
0068
0069 Msize = 4;
0070 else
0071 Msize = Para.Msize;
0072 end;
0073
0074
0075
0076
0077
0078 [B, DIM] = vb_load_analyze_to_right(imagefile);
0079
0080
0081
0082
0083 if isempty(Bval)
0084 [Bval, Nhist, level] = vb_back_threshold(B,pmax,plot_mode);
0085 end
0086
0087 if job_mode == -2, return; end;
0088
0089
0090
0091 B = vb_image_to_mask(B, Bval, step, plot_mode, zindx, Nfig);
0092
0093 if job_mode < 0, return; end;
0094
0095
0096
0097 B = vb_morphology_operation(B, Radius, step, plot_mode, zindx, Nfig);
0098
0099 if job_mode == 0, return; end;
0100
0101
0102
0103
0104
0105 [F, V, xx, Vmiss, Fmiss] = vb_surf_extract(B, step);
0106
0107
0108 if plot_mode > 0,
0109 figure;
0110 vb_plot_surf(V,F,[0.8 0.7 0.6],'none',1);
0111 view([135, 15]);
0112 end
0113
0114 Nmin = 20;
0115 Vmax = max(V);
0116 Vmin = min(V);
0117 Nsurf = size(Vmiss,1);
0118 NX = 2; NY = 2;
0119 nfig = NX*NY;
0120
0121 if plot_mode > 0,
0122 for n=1:Nsurf
0123 if size(Vmiss{n},1) < Nmin, continue; end;
0124 nfig = nfig+1;
0125 if nfig > NX*NY, figure; nfig = 1; end;
0126 subplot(NY,NX,nfig)
0127 vb_plot_surf(Vmiss{n},Fmiss{n},[0.8 0.7 0.6],'none',1);
0128 hold on
0129 xlim([Vmin(1) Vmax(1)]);
0130 ylim([Vmin(2) Vmax(2)]);
0131 zlim([Vmin(3) Vmax(3)]);
0132 view([135, 15]);
0133 end
0134 end
0135
0136 if plot_mode == 2,
0137
0138 figure;
0139 plot(level,Nhist);
0140 hold on
0141 plot([Bval Bval], [0 Nhist(round(Bval))*2], 'r-');
0142 title('Histgram of MRI intensity')
0143
0144
0145 [B, DIM] = vb_load_analyze_to_right(imagefile);
0146 vb_plot_slice( B, V, zindx, 1, Nfig, Msize);
0147 end
0148
0149 if job_mode == 1, return; end;
0150
0151
0152
0153
0154 B = vb_face_to_mask(V,F,DIM,step,zmin,plot_mode,zindx);
0155
0156
0157
0158 if job_mode < 3, return; end;
0159