Home > vbmeg > functions > gui > preAnalysis > head > head_spm_curry > pa_head_util.m

pa_head_util

PURPOSE ^

This function is subcontracting function of head GUI.

SYNOPSIS ^

function pa_head_util(fig, command)

DESCRIPTION ^

 This function is subcontracting function of head GUI.
 [USAGE]
    pa_head_util(<fig>, <command>);
 [IN]
        fig : figure handle of head gui.
    command : command
 [OUT]
    none

 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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function pa_head_util(fig, command)
0002 % This function is subcontracting function of head GUI.
0003 % [USAGE]
0004 %    pa_head_util(<fig>, <command>);
0005 % [IN]
0006 %        fig : figure handle of head gui.
0007 %    command : command
0008 % [OUT]
0009 %    none
0010 %
0011 % Copyright (C) 2011, ATR All Rights Reserved.
0012 % License : New BSD License(see VBMEG_LICENSE.txt)
0013 
0014 %
0015 % --- Previous check
0016 %
0017 if ~exist('fig', 'var') || isempty(fig) || ~ishandle(fig)
0018     error('invalid figure handle is specified.');
0019 end
0020 if ~exist('command', 'var') || isempty(command)
0021     error('invalid command is specified.');
0022 end
0023 
0024 %
0025 % --- Main Procedure
0026 %
0027 
0028 % load data(@see pa_head_create)
0029 data = guidata(fig);
0030 
0031 switch(command)
0032     case 'update_exec_push_status'
0033         update_exec_push_status(data.H);
0034     case 'update_output_fname'
0035         update_output_fname(data.H);
0036     case 'update_model_type'
0037         update_model_type(data.H);
0038     case 'update_csf_source'
0039         update_csf_source(data.H);
0040     case 'update_skull_source'
0041         update_skull_source(data.H);
0042     case 'update_scalp_source'
0043         update_scalp_source(data.H);
0044     case 'reset_parameter'
0045         reset_parameter(data.H);
0046     case 'exec_head'
0047         exec_head(data);
0048     case {'view2d', 'view3d'}
0049         view_model(data.H, command);
0050 end
0051 
0052 % save data
0053 guidata(fig, data);
0054 
0055 function update_output_fname(H)
0056 % This function makes output filename and sets filename to GUI.
0057 % [IN]
0058 %    H : GUI component handles
0059 % [OUT]
0060 %    none
0061 
0062     global vbmeg_inst;
0063     define = vbmeg_inst.const;
0064 
0065     head_file = get(H.head_file_edit, 'String');
0066     [f_path, f_name, f_ext] = vb_get_file_parts(head_file);
0067     head_file = [f_name, f_ext];
0068 
0069     % save_dir
0070     save_dir = get(H.save_dir_edit, 'String');
0071 
0072     % head filename(If it is empty, create from Analyze filename.)
0073     if isempty(head_file)
0074         analyze_file = get(H.analyze_file_edit, 'String');
0075         [f_path, f_name, f_ext] = vb_get_file_parts(analyze_file);
0076         if isempty(f_name)
0077             return;
0078         else
0079             head_file = [f_name, '.head.mat'];
0080         end
0081     end
0082 
0083     %
0084     % --- make filename
0085     %
0086 
0087     head_file = fullfile(save_dir, head_file);
0088     set(H.head_file_edit, 'String', head_file);
0089 
0090     update_exec_push_status(H);
0091 
0092 function update_exec_push_status(H)
0093 % This function changes Exec button status.(clickable or not)
0094 % [IN]
0095 %    H : GUI component handles
0096 % [OUT]
0097 %    none
0098 
0099     head_parm = pa_head_get_parm(H.figure);
0100     [ok, msg] = pa_head_check_parm(H.figure, head_parm);
0101     if ok
0102         set(H.exec_push, 'Enable', 'on');
0103     else
0104         set(H.exec_push, 'Enable', 'off');
0105     end
0106 
0107 function exec_head(data)
0108 % This function execute job_head with set parameter.
0109 % [IN]
0110 %    data : data of head gui(@see pa_head_create)
0111 % [OUT]
0112 %    none
0113 
0114     H = data.H;
0115 
0116     % get parameter from gui
0117     head_parm = pa_head_get_parm(H.figure);
0118 
0119     % parameter check
0120     [ok, msg] = pa_head_check_parm(H.figure, head_parm);
0121     if ~ok
0122         errordlg(msg);
0123         return;
0124     end
0125 
0126     %
0127     % --- execute job
0128     %
0129     set(H.exec_push, 'String', 'Processing...');
0130     proj_root = get(H.prjroot_edit, 'String');
0131     vb_job_head_3shell(proj_root, head_parm);
0132     set(H.exec_push, 'String', 'Exec');
0133     
0134 function reset_parameter(H)
0135 % This function resets head GUI.
0136 % [IN]
0137 %    H : GUI component handles
0138 % [OUT]
0139 %    none
0140 
0141 return;
0142 
0143 
0144 function update_model_type(H)
0145 % This function update screen by model type
0146 % [IN]
0147 %    H : GUI component handles
0148 % [OUT]
0149 %    none
0150 
0151     update_vertices(H);
0152     update_skull_source(H);
0153     update_scalp_source(H);
0154 
0155 function update_vertices(H);
0156 % This function update vertices number
0157 % [IN]
0158 %    H : GUI component handles
0159 % [OUT]
0160 %    none
0161     vertices_component = [
0162         H.vertices_1shell_edit
0163         H.vertices_3shell_edit
0164     ];
0165     set(vertices_component, 'Visible', 'off');
0166 
0167     if get(H.model_3shell_radiobutton, 'Value')
0168         set(H.vertices_3shell_edit, 'Visible', 'on');
0169     else
0170         set(H.vertices_1shell_edit, 'Visible', 'on');
0171     end
0172 
0173 function update_csf_source(H)
0174 % This function update screen by csf source
0175 % [IN]
0176 %    H : GUI component handles
0177 % [OUT]
0178 %    none
0179 
0180     fs_component = [
0181         H.fs_csf_file_text
0182         H.fs_csf_file_edit
0183         H.fs_csf_file_push
0184         H.fs_morphology_text
0185         H.fs_morphology_edit];
0186 
0187     spm_component = [
0188         H.spm_gray_matter_file_text
0189         H.gray_file_edit
0190         H.gray_file_push
0191         H.brain_file_text
0192         H.brain_file_edit
0193         H.brain_file_push
0194         H.gray_morphology_text
0195         H.gray_morphology_edit
0196         fs_component];
0197 
0198     curry_component = [
0199         H.curry_file_text
0200         H.curry_file_edit
0201         H.curry_file_push
0202         H.curry_morphology_text
0203         H.curry_morphology_edit];
0204 
0205     all_component = [spm_component; fs_component; curry_component];
0206     set(all_component, 'Visible', 'off');
0207 
0208     source_type = get(H.csf_source_popup, 'Value');
0209     switch(source_type)
0210         case 1
0211         % SPM segmentation file + Cortical model file
0212             set(spm_component, 'Visible', 'on');
0213         case 2
0214         % Curry v4.5 surface file
0215             set(curry_component, 'Visible', 'on');
0216         otherwise
0217             error('unknown csf source was specified.');
0218     end
0219     
0220 function update_skull_source(H)
0221 % This function update skull panel status
0222 % [IN]
0223 %    H : GUI component handles
0224 % [OUT]
0225 %    none
0226     panel_component = [
0227          H.skull_source_text
0228          H.skull_source_frame
0229          H.skull_source_type_text
0230          H.skull_source_popup];
0231     fs_component = [
0232          H.fs_skull_file_text
0233          H.fs_skull_file_edit
0234          H.fs_skull_file_push];
0235     scalp_component = [
0236          H.scalp_thickness_text
0237          H.scalp_thickness_edit
0238          H.scalp_thickness_unit_text];
0239     skull_thickness_component = [
0240          H.min_skull_thickness_text
0241          H.min_skull_thickness_edit
0242          H.min_skull_thickness_unit_text];
0243 
0244     all_component = [panel_component; fs_component;
0245                      scalp_component; skull_thickness_component];
0246     set(all_component, 'Visible', 'off');
0247 %    if get(H.model_3shell_radiobutton, 'Value')
0248         set(panel_component, 'Visible', 'on');
0249         if get(H.skull_source_popup, 'Value') == 1
0250             % Use Scalp thickness
0251             set(scalp_component, 'Visible', 'on');
0252             set(skull_thickness_component, 'Visible', 'on');
0253         else
0254             % FreeSurfer surface file(outer skull)
0255             set(fs_component, 'Visible', 'on');
0256             set(skull_thickness_component, 'Visible', 'on');
0257         end
0258  %   end
0259 
0260 function update_scalp_source(H)
0261 % This function update scalp panel status
0262 % [IN]
0263 %    H : GUI component handles
0264 % [OUT]
0265 %    none
0266     panel_component = [
0267         H.scalp_source_text
0268         H.scalp_source_frame
0269         H.scalp_source_type_text
0270         H.scalp_source_popup];
0271     fs_component = [
0272         H.fs_scalp_file_text
0273         H.fs_scalp_file_edit
0274         H.fs_scalp_file_push];
0275     face_component = [
0276         H.face_file_text
0277         H.face_file_edit
0278         H.face_file_push];
0279 
0280     all_component = [panel_component; fs_component; face_component];
0281     set(all_component, 'Visible', 'off');
0282 
0283 %    if get(H.model_3shell_radiobutton, 'Value')
0284         set(panel_component, 'Visible', 'on');
0285         if get(H.scalp_source_popup, 'Value') == 1
0286             % FreeSurfer surface file(outer skin)
0287             set(fs_component, 'Visible', 'on');
0288         else
0289             % Face surface file
0290             set(face_component, 'Visible', 'on');
0291         end
0292 %    end
0293     
0294     
0295 function view_model(H, command)
0296 
0297     analyze_file = get(H.analyze_file_edit, 'String');
0298     if exist(analyze_file, 'file') == 0
0299         errordlg('Analyze file should be specified.');
0300         return;
0301     end
0302 
0303     switch(command)
0304         case 'view2d'
0305             % Set 2D view parameter
0306             view2d_setting = bm_view_parm2d_new;
0307             view2d_setting = bm_view_parm2d_set_analyze_file(view2d_setting, analyze_file);
0308 
0309             view2d = bm_edit_app_view2d_new;
0310             view2d = bm_edit_app_view_update(view2d, H.figure, ...
0311                                              @pa_head_load_display_factor, ...
0312                                              view2d_setting);
0313             
0314         case 'view3d'
0315             % Set 3D view parameter
0316             view3d_setting = bm_view_parm3d_new;
0317             view3d = bm_edit_app_view3d_new;
0318             view3d = bm_edit_app_view_update(view3d, H.figure, ...
0319                                              @pa_head_load_display_factor, ...
0320                                              view3d_setting);
0321     end
0322     return;

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