Home > vbmeg > functions > job > subdirectory > vb_job_smooth_head.m

vb_job_smooth_head

PURPOSE ^

Smooth surface by morphology & spring model, and reduce number of vertex

SYNOPSIS ^

function vb_job_smooth_head(headfile_old, headfile_new, Para)

DESCRIPTION ^

 Smooth surface by morphology & spring model, and reduce number of vertex
   vb_job_smooth_head( headfile_old, headfile_new, Para )

 --- Input parameters
 headfile_old: Original head model file (Usually imported Curry surface)
 headfile_new: New head model file. 
 Para : Surface smoothing parameter set
 Para.analyze_file : analyze file for plot
 Para.brain_file   : brain file
 --- Optional field ( = Default )
 Para.Nvertex : Final surface vertex number ( = 5000)
 Para.Nloop   : Iteration number of expand to boundary ( = 200)
 Para.Nlast   : Iteration number of surface smoothing  ( = 20)
 Para.tangent_rate : Rate of smoothing force ( = 0.3)
 Para.Radius  : morphological radius ( = [ 4 -4 ])
 Para.vstep   : Subsampling step for mask image [mm]
 --- Optional input for result plot
 Para.plot_mode   = 0 : No plot
                  = 1 : plot     (Default)

 2005-05-12 Taku Yoshioka
 modefied M. Sato 2006-10-19
 M. Sato 2007-3-16
 ---

 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 vb_job_smooth_head(headfile_old, headfile_new, Para)
0002 % Smooth surface by morphology & spring model, and reduce number of vertex
0003 %   vb_job_smooth_head( headfile_old, headfile_new, Para )
0004 %
0005 % --- Input parameters
0006 % headfile_old: Original head model file (Usually imported Curry surface)
0007 % headfile_new: New head model file.
0008 % Para : Surface smoothing parameter set
0009 % Para.analyze_file : analyze file for plot
0010 % Para.brain_file   : brain file
0011 % --- Optional field ( = Default )
0012 % Para.Nvertex : Final surface vertex number ( = 5000)
0013 % Para.Nloop   : Iteration number of expand to boundary ( = 200)
0014 % Para.Nlast   : Iteration number of surface smoothing  ( = 20)
0015 % Para.tangent_rate : Rate of smoothing force ( = 0.3)
0016 % Para.Radius  : morphological radius ( = [ 4 -4 ])
0017 % Para.vstep   : Subsampling step for mask image [mm]
0018 % --- Optional input for result plot
0019 % Para.plot_mode   = 0 : No plot
0020 %                  = 1 : plot     (Default)
0021 %
0022 % 2005-05-12 Taku Yoshioka
0023 % modefied M. Sato 2006-10-19
0024 % M. Sato 2007-3-16
0025 % ---
0026 %
0027 % Copyright (C) 2011, ATR All Rights Reserved.
0028 % License : New BSD License(see VBMEG_LICENSE.txt)
0029 
0030 %
0031 % Default parameter
0032 %
0033 if nargin<3, Para = []; end
0034 
0035 if ~isfield(Para,'analyze_file')| isempty(Para.analyze_file), 
0036     error('No analyze file is specified');
0037 end
0038 
0039 if ~isfield(Para,'Nloop'), Para.Nloop = 200; end
0040 if ~isfield(Para,'Nlast'), Para.Nlast = 20; end
0041 if ~isfield(Para,'Nvertex'), Para.Nvertex = 5000; end
0042 if ~isfield(Para,'tangent_rate'), Para.tangent_rate = 0.3; end
0043 if ~isfield(Para,'vangle'), Para.vangle = [40 25 ; -130 10]; end
0044 if ~isfield(Para,'Radius'), Para.Radius = [ 4 -4 ]; end;
0045 if ~isfield(Para,'brain_file'), Para.brain_file = []; end;
0046 if ~isfield(Para,'plot_mode'), Para.plot_mode = 1; end;
0047 if ~isfield(Para,'vstep'), Para.vstep = 2; end;
0048 
0049 %
0050 % Load original head model
0051 %
0052 load(headfile_old,'Vhead','Fhead','XXhead');
0053 
0054 %
0055 %----- ΊΒΙΈΚΡ΄Ή: Spm_right [m] -> Analyze_right [mm]
0056 %
0057 disp(['--- Change coordinate to Analyze_right [mm] ']);
0058 
0059 [Vdim, Vsize] = analyze_hdr_read(Para.analyze_file);
0060 Vhead = vb_spm_right_to_analyze_right_mm(Vhead, Vdim, Vsize);
0061 Para.Dim  = vb_mask_image_size(Vdim,Vsize,Para.vstep);
0062 
0063 maxV  = max(Vhead);
0064 minV  = min(Vhead);
0065 
0066 %
0067 % Surface smoothing
0068 %
0069 disp('--- Surface smoothing');
0070 
0071 [Vhead,Fhead,XXhead] = vb_surf_smooth_expand(Vhead,Fhead,XXhead, Para);
0072 
0073 maxV  = max(Vhead) - maxV;
0074 minV  = min(Vhead) - minV;
0075 
0076 fprintf('Max_new - Max_old = [%f, %f, %f]\n', maxV)
0077 fprintf('Min_new - Min_old = [%f, %f, %f]\n', minV)
0078 
0079 %
0080 % --- Back to original coordinate
0081 %  Vox  = V*1000 - Vorgin;
0082 %   V   = (Vox + Vorgin) * 0.001;
0083 disp(['--- Back to Spm_right [m] coordinate ']);
0084 
0085 Vhead = vb_analyze_right_mm_to_spm_right(Vhead,Vdim,Vsize);
0086 
0087 %
0088 % Save result
0089 %
0090 disp(['--- Save head model file: ']);
0091 disp([headfile_new]);
0092 vb_fsave(headfile_new,'Vhead','Fhead','XXhead');
0093 
0094 clear Vhead Fhead XXhead
0095 
0096 %
0097 % Check cortex is inside of skull
0098 %
0099 
0100 if Para.plot_mode == 0, return; end;
0101 
0102 vb_plot_head_surf(headfile_new, Para.brain_file)
0103 
0104 view(Para.vangle(2,:))
0105 alpha(0.9);
0106 
0107 if ~isempty(Para.analyze_file)
0108     vb_plot_slice_head(headfile_new, Para.analyze_file, Para.brain_file);
0109 end

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