0001 function fig = vb_check_brain_model(proj_root,brain_parm, V, F)
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 
0010 
0011 
0012 
0013 analyzefile = brain_parm.analyze_file;
0014 if isempty(proj_root)
0015     brainfile   = [brain_parm.brain_file];
0016 else
0017     brainfile   = [proj_root '/' brain_parm.brain_file];
0018 end
0019 
0020 
0021 
0022 
0023 
0024 
0025 if ~exist('V', 'var')
0026     [V, F] = vb_load_cortex(brainfile, 'subj');
0027 end
0028 V = V .* 1000; 
0029 
0030 
0031 angle = [45 30; -45 30; -60 30; 60 30];
0032 
0033 Nfig  = 4;
0034 NY    = 2;
0035 NX    = 2;
0036 fclr  = [0.8 0.7 0.6];
0037 eclr  = 'none';
0038 
0039 light_mode = 1;
0040 max_mode   = 1;
0041 
0042 
0043 
0044 
0045 
0046 
0047 
0048 
0049 
0050 
0051 
0052 
0053 
0054 
0055 
0056 
0057 
0058 
0059 
0060 
0061 
0062 
0063 
0064 
0065 
0066 
0067 
0068 
0069 
0070 
0071 V = V ./ 1000; 
0072 
0073 
0074 
0075 
0076 
0077 
0078 
0079 
0080 if ~exist(analyzefile,'file'), 
0081     fprintf('There is no analyze file: %s\n',analyzefile)
0082     fprintf('Check of MRI and brain model is skipped\n')
0083     return
0084 end
0085 
0086 [B, Vdim, Vsize] = vb_load_analyze_to_right(analyzefile);
0087 
0088 
0089 Vana   = vb_spm_right_to_analyze_right(V,Vdim,Vsize);
0090 
0091 Msize   = 2;        
0092 
0093 dz      = 5;        
0094 vcut    = ['x','y','z'];    
0095 
0096 indx    = fix([Vdim(1)*0.45 Vdim(2)/2 Vdim(3)*0.5 Vdim(3)*0.7]);
0097 xymode  = 0;
0098 
0099 label   = {'Sagittal cut'; 'Coronal cut'; 'Axial cut'; 'Axial cut'};
0100 
0101 Nfig = length(vcut);
0102 NX   = 3;
0103 NY   = 3;
0104 
0105 fig = figure;
0106 set(fig, 'Menubar', 'none', 'Name', 'Cortex model on slices.', 'NumberTitle', 'off');
0107 set(fig, 'Units', 'normalized', 'Position', [0.3, 0.2, 0.4, 0.7]);
0108 
0109 for n= 1:Nfig
0110     h=vb_subaxis(NY,NX, n, 'MR', 0.05, 'ML', 0.08, 'MT', 0.05, 'MB', 0.05);
0111     vdim = vcut(n);
0112     [strX,strY] = vb_plot_3d_image(B, indx(n), vcut(n), xymode);
0113     xlabel(strX);
0114     ylabel(strY);
0115     
0116     hold on
0117     if isempty(F)
0118         vb_plot_vertex(Vana, vcut(n), indx(n), dz, Msize, 'y.', xymode);
0119     else
0120         vb_plot_cross_section(Vana,F.F3,indx(n),vcut(n),dz,Msize, 'y-',xymode);
0121     end
0122     title(label{n})
0123     vb_axes_add_click_open(h);
0124 end
0125 
0126 
0127 vcut  = 'z';
0128 zindx = fix(Vdim(3)* [0.3:0.1:0.8]);
0129 
0130 
0131 
0132 
0133 
0134 Nfig = length(zindx);
0135 
0136 
0137 
0138 for n= 1:Nfig
0139     h=vb_subaxis(NY,NX,3+n, 'MR', 0.05, 'ML', 0.08, 'MT', 0.1, 'MB', 0.05);
0140     vb_plot_3d_image(B, zindx(n), vcut, xymode);
0141     
0142     hold on
0143     if isempty(F)
0144         vb_plot_vertex(Vana, vcut, zindx(n), dz, Msize, 'y.', xymode);
0145     else
0146         vb_plot_cross_section(Vana,F.F3,zindx(n),vcut,dz,Msize,'y-',xymode);
0147     end
0148     title(['z-slice (' num2str(zindx(n),3) ')'])
0149     colormap(gray);
0150     vb_axes_add_click_open(h);
0151 end
0152 
0153 return