Home > vbmeg > demo > test_scripts > vb_make_brain_surf.m

vb_make_brain_surf

PURPOSE ^

vb_make_brain_surf

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 vb_make_brain_surf
 Make head surface from brain mask image
 --- Input 
 analyzefile : Subject analyzefile
 subj_mask   : Subject brain mask file
 fname       : Output file name

 --- バネモデル平滑化パラメタ
 Para.Nvertex = 3000; 出力頂点数
 Para.vstep  = 1;   イメージ処理ボクセルサイズ [mm]
 Para.Nloop  = 200; マスク境界フィット繰り返し回数
 Para.Nlast  = 10;  バネモデル平滑化繰り返し回数
 Para.Radius = [2 4 -4 -2 ]; morphological smoothing

 --- Output
 [Vhead, Fhead, XXhead] : surface vertex, patch index, normal vector
                          SPM-right-[m] coordinate
 Xcenter : Center of cortex to separate left/right (SPM-right-[m])

 
 2007/7/05 Masa-aki 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 % vb_make_brain_surf
0002 % Make head surface from brain mask image
0003 % --- Input
0004 % analyzefile : Subject analyzefile
0005 % subj_mask   : Subject brain mask file
0006 % fname       : Output file name
0007 %
0008 % --- バネモデル平滑化パラメタ
0009 % Para.Nvertex = 3000; 出力頂点数
0010 % Para.vstep  = 1;   イメージ処理ボクセルサイズ [mm]
0011 % Para.Nloop  = 200; マスク境界フィット繰り返し回数
0012 % Para.Nlast  = 10;  バネモデル平滑化繰り返し回数
0013 % Para.Radius = [2 4 -4 -2 ]; morphological smoothing
0014 %
0015 % --- Output
0016 % [Vhead, Fhead, XXhead] : surface vertex, patch index, normal vector
0017 %                          SPM-right-[m] coordinate
0018 % Xcenter : Center of cortex to separate left/right (SPM-right-[m])
0019 %
0020 %
0021 % 2007/7/05 Masa-aki Sato
0022 %
0023 % Copyright (C) 2011, ATR All Rights Reserved.
0024 % License : New BSD License(see VBMEG_LICENSE.txt)
0025 
0026 clear all
0027 DEBUG=0;
0028 
0029 % Brain image file
0030 subj_dir = [getenv('MATHOME') '/Retino_TY/'];
0031 
0032 analyzefile = [subj_dir '3d.hdr' ];
0033 subj_mask   = [subj_dir 'brain_mask.mat'];
0034 
0035 % Output file name
0036 fname = [subj_dir 'test_head1.head.mat']; 
0037 
0038 surf_mode = 0;
0039 % = 0: make surface from mask brain image [Default]
0040 % = 1: make surface from skull surface
0041 
0042 % --- バネモデル平滑化パラメタ
0043 Para.Nvertex = 3000; % 出力頂点数
0044 Para.Radius  = [2 4 -4 -2];% morphological smoothing for brain
0045 Para.vstep = 1  ;   % イメージ処理ボクセルサイズ [mm]
0046 Para.Nloop = 200;     % マスク境界フィット繰り返し回数
0047 Para.Nlast = 10;     % バネモデル平滑化繰り返し回数
0048 
0049 % Z-slice index for display
0050 zindx = fix([80:15:200]);
0051 
0052 switch    surf_mode
0053 case    0
0054     %
0055     % --- Get subject brain mask (voxel size = step [mm])
0056     %
0057     [avw ,Xcenter] = vb_get_brain_mask([subj_mask],'brain','', Para.vstep);
0058     
0059     % --- Show boundary of mask
0060     if DEBUG==1,
0061         [xyz] = vb_get_boundary(avw.img);
0062         vb_plot_slice( avw.img, xyz, fix(zindx/Para.vstep), 1, [3, 3], 5);
0063     end
0064     
0065     %
0066     % --- Extract smooth surface from mask image [analyze_right_mm]
0067     %
0068     [Vhead, Fhead, XXhead] = vb_mask_to_surf_expand(avw.img, Para);
0069     
0070 case    1
0071     %
0072     % --- Get skull surface
0073     %
0074     load(subj_mask,'XYZspm')
0075     Fhead = XYZspm{2}.F;
0076     Vhead = XYZspm{2}.xyz;
0077 
0078     [Vdim, Vsize] = analyze_hdr_read(analyzefile);
0079     Para.Dim  = vb_mask_image_size(Vdim,Vsize,Para.vstep);
0080 
0081     Vhead = vb_spm_right_to_analyze_right_mm(Vhead, Vdim, Vsize);
0082 
0083     [Fhead, Vhead, XXhead] = vb_out_normal(Fhead,Vhead);
0084     [Vhead, Fhead, XXhead] = vb_surf_smooth_expand(Vhead, Fhead, XXhead, Para);
0085 end
0086 
0087 [B, Vdim, Vsize] = vb_load_analyze_to_right(analyzefile);
0088 
0089 % --- analyze voxel coordinate
0090 Vana  = vb_analyze_mm_to_analyze(Vhead,Vdim,Vsize);
0091 
0092 %
0093 % --- SPM-right-[m] coordinate
0094 %
0095 Vhead = vb_analyze_right_mm_to_spm_right(Vhead,Vdim,Vsize);
0096 
0097 %
0098 % --- Save file
0099 %
0100 if exist('fname','var') & ~isempty(fname),
0101     fprintf('Save %s \n',fname)
0102     vb_fsave(fname,'Vhead','Fhead','XXhead')
0103 end
0104 
0105 %
0106 % --- Plot surface on MRI slice
0107 %
0108 zindx = fix(zindx/Vsize(3));
0109 Nfig  = [3 3];
0110 
0111 vb_plot_slice_surf(B, Vana, Fhead, zindx, 'z',Nfig,'r-',10, 1);
0112 
0113 figure
0114 vb_plot_surf(Vhead,Fhead,[],[],1,1);
0115 view([ -130 10]);
0116 
0117 return

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