Home > 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     % definition of extension
0073     if get(H.model_3shell_radiobutton, 'Value')
0074         Nvertex = str2num(get(H.vertices_3shell_edit, 'String'))*3;
0075         set(H.head_file_extension_text, 'String', ...
0076             ['_3shell_' num2str(Nvertex), '.head.mat']);
0077     else
0078         Nvertex = str2num(get(H.vertices_1shell_edit, 'String'));
0079         set(H.head_file_extension_text, 'String', ...
0080             ['_CSF_', num2str(Nvertex), '.head.mat']);
0081     end
0082 
0083     % head filename(If it is empty, create from Analyze filename.)
0084     if isempty(head_file)
0085         analyze_file = get(H.analyze_file_edit, 'String');
0086         [f_path, f_name, f_ext] = vb_get_file_parts(analyze_file);
0087         if isempty(f_name)
0088             return;
0089         else
0090             head_file = f_name;
0091         end
0092     end
0093 
0094     %
0095     % --- make filename
0096     %
0097 
0098     head_file = [save_dir, filesep, head_file];
0099     set(H.head_file_edit, 'String', head_file);
0100 
0101     update_exec_push_status(H);
0102 
0103 function update_exec_push_status(H)
0104 % This function changes Exec button status.(clickable or not)
0105 % [IN]
0106 %    H : GUI component handles
0107 % [OUT]
0108 %    none
0109 
0110     head_parm = pa_head_get_parm(H.figure);
0111     [ok, msg] = pa_head_check_parm(H.figure, head_parm);
0112     if ok
0113         set(H.exec_push, 'Enable', 'on');
0114     else
0115         set(H.exec_push, 'Enable', 'off');
0116     end
0117 
0118 function exec_head(data)
0119 % This function execute job_head with set parameter.
0120 % [IN]
0121 %    data : data of head gui(@see pa_head_create)
0122 % [OUT]
0123 %    none
0124 
0125     H = data.H;
0126 
0127     % get parameter from gui
0128     head_parm = pa_head_get_parm(H.figure);
0129 
0130     % parameter check
0131     [ok, msg] = pa_head_check_parm(H.figure, head_parm);
0132     if ~ok
0133         errordlg(msg);
0134         return;
0135     end
0136 
0137     %
0138     % --- execute job
0139     %
0140     set(H.exec_push, 'String', 'Processing...');
0141     proj_root = get(H.prjroot_edit, 'String');
0142     vb_job_head_3shell(proj_root, head_parm);
0143     set(H.exec_push, 'String', 'Exec');
0144     
0145 function reset_parameter(H)
0146 % This function resets head GUI.
0147 % [IN]
0148 %    H : GUI component handles
0149 % [OUT]
0150 %    none
0151 
0152 return;
0153 
0154 
0155 function update_model_type(H)
0156 % This function update screen by model type
0157 % [IN]
0158 %    H : GUI component handles
0159 % [OUT]
0160 %    none
0161 
0162     update_vertices(H);
0163     update_skull_source(H);
0164     update_scalp_source(H);
0165 
0166 function update_vertices(H);
0167 % This function update vertices number
0168 % [IN]
0169 %    H : GUI component handles
0170 % [OUT]
0171 %    none
0172     vertices_component = [
0173         H.vertices_1shell_edit
0174         H.vertices_3shell_edit
0175     ];
0176     set(vertices_component, 'Visible', 'off');
0177 
0178     if get(H.model_3shell_radiobutton, 'Value')
0179         set(H.vertices_3shell_edit, 'Visible', 'on');
0180     else
0181         set(H.vertices_1shell_edit, 'Visible', 'on');
0182     end
0183 
0184 function update_csf_source(H)
0185 % This function update screen by csf source
0186 % [IN]
0187 %    H : GUI component handles
0188 % [OUT]
0189 %    none
0190 
0191     fs_component = [
0192         H.fs_csf_file_text
0193         H.fs_csf_file_edit
0194         H.fs_csf_file_push
0195         H.fs_morphology_text
0196         H.fs_morphology_edit];
0197 
0198     spm_component = [
0199         H.spm_gray_matter_file_text
0200         H.gray_file_edit
0201         H.gray_file_push
0202         H.brain_file_text
0203         H.brain_file_edit
0204         H.brain_file_push
0205         H.gray_morphology_text
0206         H.gray_morphology_edit
0207         fs_component];
0208 
0209     curry_component = [
0210         H.curry_file_text
0211         H.curry_file_edit
0212         H.curry_file_push
0213         H.curry_morphology_text
0214         H.curry_morphology_edit];
0215 
0216     all_component = [spm_component; fs_component; curry_component];
0217     set(all_component, 'Visible', 'off');
0218 
0219     source_type = get(H.csf_source_popup, 'Value');
0220     switch(source_type)
0221         case 1
0222         % SPM segmentation file + Cortical model file
0223             set(spm_component, 'Visible', 'on');
0224         case 2
0225         % Curry v4.5 surface file
0226             set(curry_component, 'Visible', 'on');
0227         otherwise
0228             error('unknown csf source was specified.');
0229     end
0230     
0231 function update_skull_source(H)
0232 % This function update skull panel status
0233 % [IN]
0234 %    H : GUI component handles
0235 % [OUT]
0236 %    none
0237     panel_component = [
0238          H.skull_source_text
0239          H.skull_source_frame
0240          H.skull_source_type_text
0241          H.skull_source_popup];
0242     fs_component = [
0243          H.fs_skull_file_text
0244          H.fs_skull_file_edit
0245          H.fs_skull_file_push];
0246     scalp_component = [
0247          H.scalp_thickness_text
0248          H.scalp_thickness_edit
0249          H.scalp_thickness_unit_text];
0250     skull_thickness_component = [
0251          H.min_skull_thickness_text
0252          H.min_skull_thickness_edit
0253          H.min_skull_thickness_unit_text];
0254 
0255     all_component = [panel_component; fs_component;
0256                      scalp_component; skull_thickness_component];
0257     set(all_component, 'Visible', 'off');
0258 %    if get(H.model_3shell_radiobutton, 'Value')
0259         set(panel_component, 'Visible', 'on');
0260         if get(H.skull_source_popup, 'Value') == 1
0261             % Use Scalp thickness
0262             set(scalp_component, 'Visible', 'on');
0263             set(skull_thickness_component, 'Visible', 'on');
0264         else
0265             % FreeSurfer surface file(outer skull)
0266             set(fs_component, 'Visible', 'on');
0267             set(skull_thickness_component, 'Visible', 'on');
0268         end
0269  %   end
0270 
0271 function update_scalp_source(H)
0272 % This function update scalp panel status
0273 % [IN]
0274 %    H : GUI component handles
0275 % [OUT]
0276 %    none
0277     panel_component = [
0278         H.scalp_source_text
0279         H.scalp_source_frame
0280         H.scalp_source_type_text
0281         H.scalp_source_popup];
0282     fs_component = [
0283         H.fs_scalp_file_text
0284         H.fs_scalp_file_edit
0285         H.fs_scalp_file_push];
0286     face_component = [
0287         H.face_file_text
0288         H.face_file_edit
0289         H.face_file_push];
0290 
0291     all_component = [panel_component; fs_component; face_component];
0292     set(all_component, 'Visible', 'off');
0293 
0294 %    if get(H.model_3shell_radiobutton, 'Value')
0295         set(panel_component, 'Visible', 'on');
0296         if get(H.scalp_source_popup, 'Value') == 1
0297             % FreeSurfer surface file(outer skin)
0298             set(fs_component, 'Visible', 'on');
0299         else
0300             % Face surface file
0301             set(face_component, 'Visible', 'on');
0302         end
0303 %    end
0304     
0305     
0306 function view_model(H, command)
0307 
0308     analyze_file = get(H.analyze_file_edit, 'String');
0309     if exist(analyze_file, 'file') == 0
0310         errordlg('Analyze file should be specified.');
0311         return;
0312     end
0313 
0314     switch(command)
0315         case 'view2d'
0316             % Set 2D view parameter
0317             view2d_setting = bm_view_parm2d_new;
0318             view2d_setting = bm_view_parm2d_set_analyze_file(view2d_setting, analyze_file);
0319 
0320             view2d = bm_edit_app_view2d_new;
0321             view2d = bm_edit_app_view_update(view2d, H.figure, ...
0322                                              @pa_head_load_display_factor, ...
0323                                              view2d_setting);
0324             
0325         case 'view3d'
0326             % Set 3D view parameter
0327             view3d_setting = bm_view_parm3d_new;
0328             view3d = bm_edit_app_view3d_new;
0329             view3d = bm_edit_app_view_update(view3d, H.figure, ...
0330                                              @pa_head_load_display_factor, ...
0331                                              view3d_setting);
0332     end
0333     return;

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005