Home > vbmeg > functions > plotfunc > check_model > vb_check_brain_model.m

vb_check_brain_model

PURPOSE ^

Plot brain model in 3D & on MRI slice for checking

SYNOPSIS ^

function fig = vb_check_brain_model(proj_root,brain_parm, V, F)

DESCRIPTION ^

 Plot brain model in 3D & on MRI slice for checking
  vb_check_brain_model(proj_root,brain_parm, [V], [F])

 2006/10/19 M. 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 fig = vb_check_brain_model(proj_root,brain_parm, V, F)
0002 % Plot brain model in 3D & on MRI slice for checking
0003 %  vb_check_brain_model(proj_root,brain_parm, [V], [F])
0004 %
0005 % 2006/10/19 M. Sato
0006 %
0007 % Copyright (C) 2011, ATR All Rights Reserved.
0008 % License : New BSD License(see VBMEG_LICENSE.txt)
0009 
0010 %
0011 % Brain file
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 %---- Cortex 3D image
0022 %
0023 
0024 %---- Load vertex coordinate from brain file
0025 if ~exist('V', 'var')
0026     [V, F] = vb_load_cortex(brainfile, 'subj');
0027 end
0028 V = V .* 1000; % [m] to [mm]
0029 
0030 % View angle
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 % figure;
0043 % h=subplot(NY,NX,1);
0044 % vb_plot_surf(V, F.F3L, fclr,eclr,light_mode,max_mode)
0045 % view(angle(1,:));
0046 % title('Left brain')
0047 % xlabel('[mm]'); ylabel('[mm]'); zlabel('[mm]');
0048 % vb_axes_add_click_open(h);
0049 %
0050 % h=subplot(NY,NX,2);
0051 % vb_plot_surf(V, F.F3R, fclr,eclr,light_mode,max_mode)
0052 % view(angle(2,:));
0053 % title('Right brain')
0054 % xlabel('[mm]'); ylabel('[mm]'); zlabel('[mm]');
0055 % vb_axes_add_click_open(h);
0056 %
0057 % h=subplot(NY,NX,3);
0058 % vb_plot_surf(V, F.F3, fclr,eclr,light_mode,max_mode)
0059 % view(angle(3,:));
0060 % title('Both brain [Left angle]')
0061 % xlabel('[mm]'); ylabel('[mm]'); zlabel('[mm]');
0062 % vb_axes_add_click_open(h);
0063 %
0064 % h=subplot(NY,NX,4);
0065 % vb_plot_surf(V, F.F3, fclr,eclr,light_mode,max_mode)
0066 % view(angle(4,:));
0067 % title('Both brain [Right angle]')
0068 % xlabel('[mm]'); ylabel('[mm]'); zlabel('[mm]');
0069 % vb_axes_add_click_open(h);
0070 
0071 V = V ./ 1000; % [mm] to [m]
0072 
0073 %
0074 %---- Cortex on the slice image
0075 %
0076 
0077 %
0078 %---- Load analyze left-handed image
0079 %     & flip to right-handed image
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 % Transform vertex coordinate to analyze right-handed coordinate
0089 Vana   = vb_spm_right_to_analyze_right(V,Vdim,Vsize);
0090 
0091 Msize   = 2;        % marker size
0092 %Mtype   = 'y-';        % marker type
0093 dz      = 5;        % search radius for intersection triangle
0094 vcut    = ['x','y','z'];    % slice cut direction
0095 %indx    = [80 120 130 170 ];    % slice number to cut
0096 indx    = fix([Vdim(1)*0.45 Vdim(2)/2 Vdim(3)*0.5 Vdim(3)*0.7]);% slice number
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 % Slice index in Z-axis
0127 vcut  = 'z';
0128 zindx = fix(Vdim(3)* [0.3:0.1:0.8]);
0129 %zindx = [140:10:190];
0130 
0131 % Number of subplot
0132 %NX   = 3;
0133 %NY   = 2;
0134 Nfig = length(zindx);
0135 
0136 %figure;
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

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005