Home > vbmeg > functions > brain > vb_make_brain_std.m

vb_make_brain_std

PURPOSE ^

Make cortex data for MNI standard brain

SYNOPSIS ^

function [V,F,xx,BV_index,Vinfo] = vb_make_brain_std(brain_parm)

DESCRIPTION ^

 Make cortex data for MNI standard brain
 
   [V,F,xx,ORG_index,Vinfo] = vb_make_brain_std(brain_parm)

--- Input

 brain_parm   : structure with following field
 --- fields of brain_parm
 .FS_left_file         = [fs_dir '/bem/lh.smoothwm.asc'];
 .FS_right_file        = [fs_dir '/bem/rh.smoothwm.asc'];
 
 .FS_left_label_file  = [fs_dir '/label/lh.cortex.label'];
 .FS_right_label_file = [fs_dir '/label/rh.cortex.label'];

  .FS_left_sphere_file
  .FS_right_sphere_file
  .FS_sphere_key 

    .Nvertex        : Total number of vertices of the right and left brain
                      after reducing original(BV/FS) model.
                      (Priority: Nvertex>reduce_ratio)
    .N_step         : Division number in searching match points
         頂点対応探索時のZ軸方向分割数
 
--- Output
 
 V     : Cortical vertex point cordinate (SPM_Right_m) [Nvertex, 3]
          頂点位置 ( 頂点の数, 3)
 xx    : Normal vector to cortical surface   [Nvertex, 3]
           頂点の法線方向と位置( 頂点の数, 3)
 F      : Patch index structure
           面(3角形)を構成する3つの頂点番号 ( 面の数, 3)  
  .F3R     : Right cortex
  .F3L     : Left  cortex
  .F3     : Left + Right
 BV_index  : original vertex index in BV corresponding to brain
    .Left     : Left  brain
    .Right    : Right brain
 Cortex area index of original FreeSurfer surface
 BV_index.cortexL 
 BV_index.cortexR 
 Vinfo        : Vertex dimension structure
   .Ndipole   : # of vertex
   .NdipoleL  : # of vertex in Left cortex
   .Npatch    : # of patch
   .Coord     = 'SPM_Right_m';
 Cortex area index of 'V'
 Vinfo.cortexL = 
 Vinfo.cortexR = 

 [history]
 Ver.2.0 New version for group analysis
 2015-12-27 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 [V,F,xx,BV_index,Vinfo] = vb_make_brain_std(brain_parm)
0002 % Make cortex data for MNI standard brain
0003 %
0004 %   [V,F,xx,ORG_index,Vinfo] = vb_make_brain_std(brain_parm)
0005 %
0006 %--- Input
0007 %
0008 % brain_parm   : structure with following field
0009 % --- fields of brain_parm
0010 % .FS_left_file         = [fs_dir '/bem/lh.smoothwm.asc'];
0011 % .FS_right_file        = [fs_dir '/bem/rh.smoothwm.asc'];
0012 %
0013 % .FS_left_label_file  = [fs_dir '/label/lh.cortex.label'];
0014 % .FS_right_label_file = [fs_dir '/label/rh.cortex.label'];
0015 %
0016 %  .FS_left_sphere_file
0017 %  .FS_right_sphere_file
0018 %  .FS_sphere_key
0019 %
0020 %    .Nvertex        : Total number of vertices of the right and left brain
0021 %                      after reducing original(BV/FS) model.
0022 %                      (Priority: Nvertex>reduce_ratio)
0023 %    .N_step         : Division number in searching match points
0024 %         頂点対応探索時のZ軸方向分割数
0025 %
0026 %--- Output
0027 %
0028 % V     : Cortical vertex point cordinate (SPM_Right_m) [Nvertex, 3]
0029 %          頂点位置 ( 頂点の数, 3)
0030 % xx    : Normal vector to cortical surface   [Nvertex, 3]
0031 %           頂点の法線方向と位置( 頂点の数, 3)
0032 % F      : Patch index structure
0033 %           面(3角形)を構成する3つの頂点番号 ( 面の数, 3)
0034 %  .F3R     : Right cortex
0035 %  .F3L     : Left  cortex
0036 %  .F3     : Left + Right
0037 % BV_index  : original vertex index in BV corresponding to brain
0038 %    .Left     : Left  brain
0039 %    .Right    : Right brain
0040 % Cortex area index of original FreeSurfer surface
0041 % BV_index.cortexL
0042 % BV_index.cortexR
0043 % Vinfo        : Vertex dimension structure
0044 %   .Ndipole   : # of vertex
0045 %   .NdipoleL  : # of vertex in Left cortex
0046 %   .Npatch    : # of patch
0047 %   .Coord     = 'SPM_Right_m';
0048 % Cortex area index of 'V'
0049 % Vinfo.cortexL =
0050 % Vinfo.cortexR =
0051 %
0052 % [history]
0053 % Ver.2.0 New version for group analysis
0054 % 2015-12-27 M. Sato
0055 %
0056 %
0057 % Copyright (C) 2011, ATR All Rights Reserved.
0058 % License : New BSD License(see VBMEG_LICENSE.txt)
0059 
0060 plot_mode = 1;
0061 
0062 global vbmeg_inst;
0063 const = vb_define_verbose;
0064 
0065 % Max radius to search corresponding point [mm] in the 1st-step
0066 Rmax = 4; 
0067 EPS  = 1e-10;
0068 
0069 % --- Subject cortical surface (SPM_Right mm cordinate)
0070 vb_disp('Load original brain surface');
0071 
0072 [V0L,F0L,n0L,V0R,F0R,n0R] = vb_load_orig_brain_surf(brain_parm);
0073 % V0L/R  vertex coordinate (SPM_Right mm)
0074 % n0L/R  unit vector
0075 % FOL/R  triangle patch
0076 
0077 % Extract cortex area index
0078 vb_disp('Extract cortex area index');
0079 
0080 [Vindex] = vb_extract_cortex(V0L,F0L,V0R,F0R,brain_parm,1);
0081 
0082 vb_disp('Reduce cortex');
0083 
0084 % reference coordinate: subject original SPM-R mm coordinate
0085 VLref = V0L;
0086 VRref = V0R;
0087 
0088 R = 1.0;
0089 if isfield(brain_parm, 'Nvertex') && ~isempty(brain_parm.Nvertex) &&...
0090    isnumeric(brain_parm.Nvertex)
0091    % Number of verticies after reducing
0092    N = brain_parm.Nvertex;
0093    if((size(V0L, 1) + size(V0R, 1)) < N)
0094      vb_disp(['brain_parm.Nvertex is larger than original model''s one.'...
0095               'No reduction is applied.'], const.VERBOSE_LEVEL_WARNING);
0096    else
0097        R = N;
0098        vb_disp(sprintf('Nvertex = %d is applied.', brain_parm.Nvertex));
0099    end
0100 elseif isfield(brain_parm, 'reduce_ratio') && ...
0101        isnumeric(brain_parm.reduce_ratio)
0102     R = brain_parm.reduce_ratio;
0103     vb_disp(sprintf('reduce_ratio = %.2f is applied.', ...
0104             brain_parm.reduce_ratio));
0105 end
0106 
0107 % target coordinate:
0108 % Subject reduced SPM-R mm cordinate
0109 [FL,VL] = vb_reducepatch( F0L, V0L, R ); % 0 < R < 1: ratio
0110 [FR,VR] = vb_reducepatch( F0R, V0R, R ); % R > 1   : number of verticies
0111 
0112 [FL, VL, xxL] = vb_out_normal_surf(FL,VL);
0113 [FR, VR, xxR] = vb_out_normal_surf(FR,VR);
0114 
0115 %
0116 % ---- Check closed surface by solid_angle/(2*pi) = 1
0117 %
0118 omega  = vb_solid_angle_check(VL,FL);
0119 vb_disp(sprintf('Left solid_angle/(2*pi) = %5.3f',omega));
0120 if abs(omega - 1) > EPS,
0121     vb_disp('Surface is not closed ');
0122 end
0123 omega  = vb_solid_angle_check(VR,FR);
0124 vb_disp(sprintf('Right solid_angle/(2*pi) = %5.3f',omega));
0125 if abs(omega - 1) > EPS,
0126     vb_disp('Surface is not closed ');
0127 end
0128 
0129 NdipoleL = size(VL,1);
0130 NdipoleR = size(VR,1);
0131 Ndipole  = NdipoleL + NdipoleR;
0132 FR = FR + NdipoleL;
0133 
0134 F.F3       = [FL ; FR];
0135 F.F3R       = FR;
0136 F.F3L       = FL;
0137 F.NdipoleL = NdipoleL;
0138 
0139 % Find nearest point from 'Vref' for 'V'
0140 %  [Indx ,ddmin] = vb_find_nearest_point(Vref, V, Rmax,Nstep,Mode,Disp)
0141 % Vref  : Ref vertex point
0142 % Indx  : Ref vertex index nearest to V
0143 
0144 % V0L/R : original vertex coordinate (SPM_Right mm)
0145 vb_disp('Find original point corresponding to reduced model');
0146 
0147 tic;
0148 vb_disp_nonl('Left cortex: ');
0149 [IndxL, ddL] = vb_find_nearest_point(VLref, VL, Rmax, 100, 1, 1);
0150 vb_disp(sprintf('%f[sec]',toc));
0151 
0152 tic;
0153 vb_disp_nonl('Right cortex: ');
0154 [IndxR, ddR] = vb_find_nearest_point(VRref, VR, Rmax, 100, 1, 1);
0155 
0156 vb_disp(sprintf('%f[sec]',toc));
0157 
0158 dd = [ddL; ddR];
0159 dmax = max(dd);
0160 fprintf('Max distance = %4.1f mm \n', dmax)
0161 
0162 %
0163 % --- SPM cordinate in [m] , Normal vector is outward.
0164 %
0165 V  = [VL; VR]/1000;
0166 
0167 % ---  Normal vector of reduced surface
0168 xx  = [xxL ; xxR]; 
0169 
0170 % Dimension of Original vertex
0171 NdipoleL0 = size(VLref,1);
0172 NdipoleR0 = size(VRref,1);
0173 Npatch    = size(F.F3,1);
0174 
0175 % Original vertex index corresponding to reduced brain 'V'
0176 BV_index.Left  = IndxL; 
0177 BV_index.Right = IndxR + NdipoleL0;
0178 
0179 % Cortex area index of original FreeSurfer surface
0180 BV_index.cortexL = Vindex.cortexL;
0181 BV_index.cortexR = Vindex.cortexR + NdipoleL0;
0182 
0183 % Dimensional info
0184 Vinfo.Ndipole   = Ndipole;
0185 Vinfo.NdipoleL  = NdipoleL;
0186 Vinfo.NdipoleR  = NdipoleR;
0187 
0188 Vinfo.Ndipole0  = NdipoleL0 + NdipoleR0;
0189 Vinfo.NdipoleL0 = NdipoleL0;
0190 Vinfo.NdipoleR0 = NdipoleR0;
0191 
0192 Vinfo.Npatch    = Npatch;
0193 Vinfo.Coord     = 'SPM_Right_m';
0194 Vinfo.dd_match  = dd;
0195 
0196 % Cortex area index of reduced surface
0197 flgL = zeros(NdipoleL0,1);
0198 flgR = zeros(NdipoleR0,1);
0199 
0200 % Cortex flag
0201 flgL(Vindex.cortexL) = 1;
0202 flgR(Vindex.cortexR) = 1;
0203 
0204 % Reduced index table
0205 tblL = zeros(NdipoleL0,1);
0206 tblR = zeros(NdipoleR0,1);
0207 
0208 tblL(IndxL) = 1:NdipoleL;
0209 tblR(IndxR) = 1:NdipoleR;
0210 
0211 % Get cortex index in Reduced surface
0212 ixL  = find( tblL .* flgL > 0);
0213 ixR  = find( tblR .* flgR > 0);
0214 
0215 Vinfo.cortexL = tblL(ixL);
0216 Vinfo.cortexR = tblR(ixR) + NdipoleL;
0217 
0218 if plot_mode == 0, return; end;
0219 
0220 % plot
0221 nonL = vb_setdiff2([1:NdipoleL], Vinfo.cortexL);
0222 nonR = vb_setdiff2([(NdipoleL+1):Ndipole], Vinfo.cortexR);
0223 
0224 FLz = vb_patch_select(nonL, F.F3L, Ndipole);
0225 FRz = vb_patch_select(nonR, F.F3R, Ndipole);
0226 
0227 figure;
0228 subplot(1,2,1)
0229 vb_plot_surf(V,F.F3L,'','b')
0230 hold on
0231 vb_plot_surf(V,FLz,'r','r')
0232 
0233 subplot(1,2,2)
0234 vb_plot_surf(V,F.F3R,'','b')
0235 hold on
0236 vb_plot_surf(V,FRz,'r','r')
0237

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