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 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
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
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
0105
0106
0107
0108
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
0120
0121
0122
0123
0124
0125 H = data.H;
0126
0127
0128 head_parm = pa_head_get_parm(H.figure);
0129
0130
0131 [ok, msg] = pa_head_check_parm(H.figure, head_parm);
0132 if ~ok
0133 errordlg(msg);
0134 return;
0135 end
0136
0137
0138
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
0147
0148
0149
0150
0151
0152 return;
0153
0154
0155 function update_model_type(H)
0156
0157
0158
0159
0160
0161
0162 update_vertices(H);
0163 update_skull_source(H);
0164 update_scalp_source(H);
0165
0166 function update_vertices(H);
0167
0168
0169
0170
0171
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
0186
0187
0188
0189
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
0223 set(spm_component, 'Visible', 'on');
0224 case 2
0225
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
0233
0234
0235
0236
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
0259 set(panel_component, 'Visible', 'on');
0260 if get(H.skull_source_popup, 'Value') == 1
0261
0262 set(scalp_component, 'Visible', 'on');
0263 set(skull_thickness_component, 'Visible', 'on');
0264 else
0265
0266 set(fs_component, 'Visible', 'on');
0267 set(skull_thickness_component, 'Visible', 'on');
0268 end
0269
0270
0271 function update_scalp_source(H)
0272
0273
0274
0275
0276
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
0295 set(panel_component, 'Visible', 'on');
0296 if get(H.scalp_source_popup, 'Value') == 1
0297
0298 set(fs_component, 'Visible', 'on');
0299 else
0300
0301 set(face_component, 'Visible', 'on');
0302 end
0303
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
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
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;