0001 function brain_file_maker_callback(obj, hObj)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 if ~exist('obj', 'var'), error('obj is a required parameter.'); end
0020
0021
0022
0023
0024 H = obj.H;
0025
0026 evalin('base', 'clear avw');
0027
0028 switch(hObj)
0029 case H.proj_root_push
0030 dir_name = get(H.proj_root_edit, 'String');
0031 if isempty(dir_name)
0032 dir_name = pwd;
0033 end
0034 dir_name = dir_dialog(dir_name);
0035 if ~isempty(dir_name)
0036 obj.proj_root = dir_name;
0037 obj = brain_file_maker_update_display(obj);
0038 end
0039 case H.proj_root_edit
0040 proj_root = get(hObj, 'String');
0041 if exist(proj_root, 'dir') == 7
0042 obj.proj_root = proj_root;
0043 else
0044 obj.proj_root = [];
0045 end
0046
0047 obj = brain_file_maker_update_display(obj);
0048 case H.analyze_file_push
0049 [dir_name, f_name] = visible(obj.fdlg_analyze);
0050 if ~isempty(dir_name)
0051
0052 analyze_file = [dir_name, filesep, f_name{1}];
0053 obj.analyze_file = analyze_file;
0054 obj.analyze_info = vb_analyze_info_new(analyze_file);
0055
0056 obj = brain_file_maker_update_display(obj);
0057
0058 obj.fdlg_analyze = set(obj.fdlg_analyze, 'current_dir', dir_name);
0059 end
0060 case H.analyze_file_edit
0061 analyze_file = get(hObj, 'String');
0062 if exist(analyze_file, 'file') == 2
0063 obj.analyze_info = vb_analyze_info_new(analyze_file);
0064 else
0065 obj.analyze_info = [];
0066 end
0067
0068 obj = brain_file_maker_update_ui_state(obj);
0069 case H.product_type_popup
0070 obj.product_type = get(hObj, 'Value');
0071
0072 obj = brain_file_maker_update_ui_state(obj);
0073 case H.output_brain_file_comment
0074 obj.comment = get(hObj, 'String');
0075 case H.brain_dir_push
0076 dir_name = dir_dialog(obj.proj_root, false);
0077 if ~isempty(dir_name)
0078 rel_path = vb_relativepath(dir_name, obj.proj_root);
0079 set(H.brain_dir_edit, 'String', rel_path);
0080 obj.brain_dir = rel_path;
0081 obj = brain_file_maker_update_display(obj);
0082 end
0083 case H.brain_dir_edit
0084 obj.brain_dir = get(hObj, 'String');
0085 obj = brain_file_maker_update_display(obj);
0086 case H.filter_edit
0087 set(H.brain_file_listbox, 'Value', 1);
0088 set(H.area_file_listbox, 'Value', 1);
0089 set(H.act_file_listbox, 'Value', 1);
0090 obj = brain_file_maker_update_display(obj);
0091 case {H.brain_file_listbox, H.area_file_listbox, H.act_file_listbox}
0092 obj = brain_file_maker_set_selected_filename(obj);
0093 if hObj == H.brain_file_listbox & ishandle(obj.view2d)
0094 h = brain_file_maker_show_wait_dialog;
0095 obj = brain_file_maker_view2d(obj, ...
0096 [obj.proj_root, filesep, obj.brain_file], obj.analyze_info);
0097 brain_file_maker_delete_wait_dialog(h);
0098 end
0099
0100
0101
0102 case H.spm_norm_file_push
0103 [dir_name, f_name] = visible(obj.fdlg_spm_norm_file);
0104 if ~isempty(dir_name)
0105 spm_norm_file = [dir_name, filesep, f_name{1}];
0106
0107 obj.fdlg_spm_norm_file = set(obj.fdlg_spm_norm_file,...
0108 'current_dir', dir_name);
0109 obj.spm_norm_file = spm_norm_file;
0110
0111 obj = brain_file_maker_update_display(obj);
0112 end
0113 case H.spm_norm_file_edit
0114 obj.spm_norm_file = get(hObj, 'String');
0115 obj = brain_file_maker_update_ui_state(obj);
0116 case H.brain_file_output_filename_edit
0117 obj.brain_file_output_filename = get(hObj, 'String');
0118 obj = brain_file_maker_update_display(obj);
0119 case H.brain_file_output_dir_push
0120 [dir_name cancelled] = pa_prjdir_select(obj.proj_root);
0121 if ~cancelled
0122 obj.brain_file_output_dir = dir_name;
0123 obj = brain_file_maker_update_display(obj);
0124 end
0125 case H.brain_file_output_dir_edit
0126 obj.brain_file_output_dir = get(hObj, 'String');
0127 obj = brain_file_maker_update_display(obj);
0128
0129
0130
0131
0132 case H.view3d_push
0133 if isempty(obj.brain_file)
0134 errordlg('Brain file is not specified.', 'notice');
0135 else
0136 h = brain_file_maker_show_wait_dialog;
0137 obj = brain_file_maker_view3d(obj, ...
0138 [obj.proj_root, filesep, obj.brain_file], ...
0139 [obj.proj_root, filesep, obj.area_file], ...
0140 [obj.proj_root, filesep, obj.act_file]);
0141
0142
0143
0144
0145
0146 if obj.view3d == obj.view2d
0147 obj.view2d = -1;
0148 end
0149 brain_file_maker_delete_wait_dialog(h);
0150 end
0151 case H.view2d_push
0152 if isempty(obj.brain_file)
0153 errordlg('Brain file is not specified.', 'notice');
0154 else
0155 h = brain_file_maker_show_wait_dialog;
0156 obj = brain_file_maker_view2d(obj,...
0157 [obj.proj_root, filesep, obj.brain_file], obj.analyze_info);
0158
0159
0160
0161
0162
0163 if obj.view2d == obj.view3d
0164 obj.view3d = -1;
0165 end
0166 brain_file_maker_delete_wait_dialog(h);
0167 end
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185 case H.make_smoothed_brain_push
0186 const = define_brain_file_maker;
0187 parm = job_smooth_cortex_parm_get_parm(obj.job_smooth_cortex_parm);
0188
0189 [obj, cancelled] = ...
0190 brain_file_maker_edit_parm(obj, const.JOB_SMOOTH_CORTEX_PARM);
0191 if cancelled, return; end
0192 output_dir = get(H.brain_dir_edit, 'String');
0193
0194 [result, cancelled] = brain_file_maker_smooth_brainfiles(...
0195 obj, parm);
0196 if result == SUCCESS && cancelled == false
0197 obj = brain_file_maker_update_display(obj);
0198 end
0199 case H.make_brain_from_mask_push
0200
0201
0202
0203 const = define_brain_file_maker;
0204 parm = job_brain_std2sbj_parm_get_parm(obj.job_brain_std2sbj_parm);
0205 comment = get(H.output_brain_file_comment, 'String');
0206
0207 [obj, cancelled] = ...
0208 brain_file_maker_edit_parm(obj, const.JOB_BRAIN_STD2SBJ_PARM);
0209 if cancelled, return; end
0210
0211
0212 spm_norm_file = get(H.spm_norm_file_edit, 'String');
0213 output_mask_file = ...
0214 [obj.proj_root, filesep, get(H.output_mask_file_text, 'String')];
0215 global vbmeg_inst;
0216 standard_mask_file = vbmeg_inst.const.FILE_STD_BRAIN_MASK_MAT;
0217 [result, cancelled] = brain_file_maker_make_mask_file(...
0218 obj, spm_norm_file, standard_mask_file, output_mask_file);
0219 if result == SUCCESS && cancelled == false
0220 obj = brain_file_maker_update_display(obj);
0221 elseif cancelled == true && exist(output_mask_file, 'file') == 2
0222
0223 elseif cancelled == true && exist(output_mask_file, 'file') ~= 2
0224 msgbox('Processing was aborted.');
0225 return;
0226 elseif result == FAILURE
0227 error('Error was occured when making Mask file.');
0228 end
0229
0230
0231 parm.spm_normalization_file = obj.spm_norm_file;
0232 [result, cancelled] = ...
0233 brain_file_maker_make_brainfiles_from_mask_file(obj, parm, comment);
0234 if result == SUCCESS && cancelled == false
0235 obj = brain_file_maker_update_display(obj);
0236 elseif cancelled == true
0237 msgbox('Processing was aborted.');
0238 else
0239 error('Error was occured when making Cortical files.');
0240 end
0241 case H.make_brain_from_standard_push
0242 comment = get(H.output_brain_file_comment, 'String');
0243 parm = obj.job_brain_model_std2sbj_parm;
0244 [result, cancelled] = brain_file_maker_make_brainfiles_from_standard_model(...
0245 obj, parm, comment);
0246 if result == SUCCESS && cancelled == false
0247 obj = brain_file_maker_update_display(obj);
0248 elseif cancelled == true
0249 msgbox('Processing was aborted.');
0250 else
0251 error('Error was occured when making Cortical files.');
0252 end
0253 end
0254
0255
0256
0257
0258 guidata(obj.H.figure, obj);