0001 function pa_brain_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, data.output_filename);
0036 case 'update_model_type'
0037 update_model_type(data.H);
0038 case 'exec_brain'
0039 exec_brain(data);
0040 end
0041
0042
0043 guidata(fig, data);
0044
0045 function update_output_fname(H, output_filename)
0046
0047
0048
0049
0050
0051
0052 global vbmeg_inst;
0053 define = vbmeg_inst.const;
0054
0055
0056 save_dir = get(H.save_dir_edit, 'String');
0057
0058 if isempty(output_filename)
0059
0060 fname = get(H.analyze_edit, 'String');
0061 sep = [];
0062 if isempty(fname) | isempty(fname)
0063 return;
0064 end
0065
0066
0067 [f_path, f_name, f_ext] = vb_get_file_parts(fname);
0068
0069 else
0070 f_name = output_filename;
0071 end
0072
0073
0074 brain_file = [save_dir, filesep, f_name, define.BRAIN_EXTENSION];
0075 set(H.brain_file_edit, 'String', brain_file);
0076
0077 area_file = [save_dir, filesep, f_name, define.AREA_EXTENSION];
0078 set(H.area_file_edit, 'String', area_file);
0079
0080 act_file = [save_dir, filesep, f_name, define.FMRI_EXTENSION];
0081 set(H.act_file_edit, 'String', act_file);
0082
0083 update_exec_push_status(H);
0084
0085 function update_exec_push_status(H)
0086
0087
0088
0089
0090
0091
0092
0093 if isempty(get(H.analyze_edit, 'String'))
0094 set(H.brain_exec_push, 'Enable', 'off');
0095 return;
0096 end
0097
0098 if isempty(get(H.save_dir_edit, 'String'))
0099 set(H.brain_exec_push, 'Enable', 'off');
0100 return;
0101 end
0102
0103 if get(H.model_brainvoyager_radiobutton, 'Value')
0104
0105 if ~isempty(get(H.left_edit, 'String')) && ...
0106 ~isempty(get(H.right_edit, 'String')) && ...
0107 ~isempty(get(H.left_inflate_edit, 'String')) &&...
0108 ~isempty(get(H.right_inflate_edit, 'String'))
0109
0110 set(H.brain_exec_push, 'Enable', 'on');
0111 else
0112 set(H.brain_exec_push, 'Enable', 'off');
0113 end
0114 elseif get(H.model_freesurfer_radiobutton, 'Value')
0115
0116 if exist(get(H.freesurfer_left_edit, 'String'), 'file') == 2 && ...
0117 exist(get(H.freesurfer_right_edit, 'String'), 'file') == 2 && ...
0118 exist(get(H.freesurfer_left_inflate_edit, 'String'), 'file') == 2 && ...
0119 exist(get(H.freesurfer_right_inflate_edit, 'String'), 'file') == 2 && ...
0120 exist(get(H.freesurfer_left_curv_edit, 'String'), 'file') == 2 && ...
0121 exist(get(H.freesurfer_right_curv_edit, 'String'), 'file') == 2 && ...
0122 exist(get(H.freesurfer_left_label_edit, 'String'), 'file') == 2 && ...
0123 exist(get(H.freesurfer_right_label_edit, 'String'), 'file') == 2 && ...
0124 exist(get(H.freesurfer_left_sphere_edit, 'String'), 'file') == 2 && ...
0125 exist(get(H.freesurfer_right_sphere_edit, 'String'), 'file') == 2
0126 set(H.brain_exec_push, 'Enable', 'on');
0127 else
0128 set(H.brain_exec_push, 'Enable', 'off');
0129 end
0130 else
0131 set(H.brain_exec_push, 'Enable', 'off');
0132 end
0133
0134 function exec_brain(data)
0135
0136
0137
0138
0139
0140
0141 H = data.H;
0142
0143
0144
0145
0146
0147 proj_root = get(H.prjroot_edit, 'String');
0148
0149
0150 brain_parm = data.brain_parm;
0151
0152
0153 brain_parm.analyze_file = get(H.analyze_edit, 'String');
0154
0155 if get(H.model_brainvoyager_radiobutton, 'Value')
0156
0157
0158
0159
0160 brain_parm.BV_left_file = get(H.left_edit, 'String');
0161
0162 brain_parm.BV_right_file = get(H.right_edit, 'String');
0163
0164 brain_parm.BV_left_infl_file = get(H.left_inflate_edit, 'String');
0165
0166 brain_parm.BV_right_infl_file = get(H.right_inflate_edit, 'String');
0167
0168
0169 brain_parm.spm_normalization_file = get(H.spm_normalization_file_edit, 'String');
0170
0171 elseif get(H.model_freesurfer_radiobutton, 'Value')
0172
0173
0174
0175
0176 brain_parm.FS_left_file = get(H.freesurfer_left_edit, 'String');
0177
0178 brain_parm.FS_right_file = get(H.freesurfer_right_edit, 'String');
0179
0180 brain_parm.FS_left_infl_file = get(H.freesurfer_left_inflate_edit, 'String');
0181
0182 brain_parm.FS_right_infl_file = get(H.freesurfer_right_inflate_edit, 'String');
0183
0184 brain_parm.FS_left_curv_file = get(H.freesurfer_left_curv_edit, 'String');
0185
0186 brain_parm.FS_right_curv_file = get(H.freesurfer_right_curv_edit, 'String');
0187
0188 brain_parm.FS_left_label_file = get(H.freesurfer_left_label_edit, 'String');
0189
0190 brain_parm.FS_right_label_file = get(H.freesurfer_right_label_edit, 'String');
0191
0192 brain_parm.FS_left_sphere_file = get(H.freesurfer_left_sphere_edit, 'String');
0193
0194 brain_parm.FS_right_sphere_file = get(H.freesurfer_right_sphere_edit, 'String');
0195
0196
0197 brain_parm.registration_mode='FS';
0198 brain_parm.FS_sphere_key = 'sphere.reg';
0199
0200
0201 if isfield(brain_parm, 'BV_left_file')
0202 brain_parm = rmfield(brain_parm, 'BV_left_file');
0203 end
0204 if isfield(brain_parm, 'BV_right_file')
0205 brain_parm = rmfield(brain_parm, 'BV_right_file');
0206 end
0207 if isfield(brain_parm, 'BV_left_infl_file')
0208 brain_parm = rmfield(brain_parm, 'BV_left_infl_file');
0209 end
0210 if isfield(brain_parm, 'BV_right_infl_file')
0211 brain_parm = rmfield(brain_parm, 'BV_right_infl_file');
0212 end
0213 end
0214
0215
0216 brain_parm.brain_file = get(H.brain_file_edit, 'String');
0217
0218
0219 brain_parm.area_file = get(H.area_file_edit, 'String');
0220
0221
0222 brain_parm.act_file = get(H.act_file_edit, 'String');
0223
0224
0225
0226
0227 set(H.brain_exec_push, 'String', 'Processing...');
0228 pause(0.01)
0229 vb_job_brain(proj_root, brain_parm);
0230 set(H.brain_exec_push, 'String', 'Exec');
0231
0232 function update_model_type(H)
0233
0234
0235
0236
0237
0238
0239 bv_group = [H.brainvoyager_left_brain_label;
0240 H.left_edit;
0241 H.left_push;
0242 H.brainvoyager_right_brain_label;
0243 H.right_edit;
0244 H.right_push;
0245 H.brainvoyager_left_inf_label;
0246 H.left_inflate_edit;
0247 H.left_inflate_push;
0248 H.brainvoyager_right_inf_label;
0249 H.right_inflate_edit;
0250 H.right_inflate_push];
0251
0252 fs_group = [H.freesurfer_left_brain_label;
0253 H.freesurfer_left_edit;
0254 H.freesurfer_left_push;
0255 H.freesurfer_right_brain_label;
0256 H.freesurfer_right_edit;
0257 H.freesurfer_right_push;
0258 H.freesurfer_left_inflate_label;
0259 H.freesurfer_left_inflate_edit;
0260 H.freesurfer_left_inflate_push;
0261 H.freesurfer_right_inflate_label;
0262 H.freesurfer_right_inflate_edit;
0263 H.freesurfer_right_inflate_push;
0264 H.freesurfer_left_curv_label;
0265 H.freesurfer_left_curv_edit;
0266 H.freesurfer_left_curv_push;
0267 H.freesurfer_right_curv_label;
0268 H.freesurfer_right_curv_edit;
0269 H.freesurfer_right_curv_push;];
0270
0271 common_group = [H.spm_normalization_label;
0272 H.spm_normalization_file_edit;
0273 H.spm_normalization_file_push];
0274
0275
0276
0277
0278
0279
0280
0281 model_type = 1;
0282 set(H.fs_quick_input_push, 'Visible', 'off');
0283 if get(H.model_brainvoyager_radiobutton, 'Value')
0284 model_type = 1;
0285 elseif get(H.model_freesurfer_radiobutton, 'Value')
0286 set(H.fs_quick_input_push, 'Visible', 'on');
0287 model_type = 2;
0288 else
0289 error('model type error : pa_brain_util()');
0290 end
0291
0292 switch(model_type)
0293 case 1
0294 set(bv_group, 'Visible', 'on');
0295 set(fs_group, 'Visible', 'off');
0296 case 2
0297 set(bv_group, 'Visible', 'off');
0298 set(fs_group, 'Visible', 'on');
0299 end
0300 set(common_group, 'Visible', 'on');