0001 function pa_head_util(fig, command)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
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
0026
0027
0028
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
0053 guidata(fig, data);
0054
0055 function update_output_fname(H)
0056
0057
0058
0059
0060
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
0070 save_dir = get(H.save_dir_edit, 'String');
0071
0072
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
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
0094
0095
0096
0097
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
0109
0110
0111
0112
0113
0114 H = data.H;
0115
0116
0117 head_parm = pa_head_get_parm(H.figure);
0118
0119
0120 [ok, msg] = pa_head_check_parm(H.figure, head_parm);
0121 if ~ok
0122 errordlg(msg);
0123 return;
0124 end
0125
0126
0127
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
0136
0137
0138
0139
0140
0141 return;
0142
0143
0144 function update_model_type(H)
0145
0146
0147
0148
0149
0150
0151 update_vertices(H);
0152 update_skull_source(H);
0153 update_scalp_source(H);
0154
0155 function update_vertices(H);
0156
0157
0158
0159
0160
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
0175
0176
0177
0178
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
0212 set(spm_component, 'Visible', 'on');
0213 case 2
0214
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
0222
0223
0224
0225
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
0248 set(panel_component, 'Visible', 'on');
0249 if get(H.skull_source_popup, 'Value') == 1
0250
0251 set(scalp_component, 'Visible', 'on');
0252 set(skull_thickness_component, 'Visible', 'on');
0253 else
0254
0255 set(fs_component, 'Visible', 'on');
0256 set(skull_thickness_component, 'Visible', 'on');
0257 end
0258
0259
0260 function update_scalp_source(H)
0261
0262
0263
0264
0265
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
0284 set(panel_component, 'Visible', 'on');
0285 if get(H.scalp_source_popup, 'Value') == 1
0286
0287 set(fs_component, 'Visible', 'on');
0288 else
0289
0290 set(face_component, 'Visible', 'on');
0291 end
0292
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
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
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;