Home > vbmeg > functions > gui > brain_file_maker > brain_file_maker_callback.m

brain_file_maker_callback

PURPOSE ^

Processing brain_file_maker gui callback.

SYNOPSIS ^

function brain_file_maker_callback(obj, hObj)

DESCRIPTION ^

 Processing brain_file_maker gui callback.
 [USAGE]
    brain_file_maker_callback(<obj>);
 [IN]
    obj : brain_file_maker object
 [OUT]
    none 

 Author: rhayashi
 Created: 2007-07-13

 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:

SOURCE CODE ^

0001 function brain_file_maker_callback(obj, hObj)
0002 % Processing brain_file_maker gui callback.
0003 % [USAGE]
0004 %    brain_file_maker_callback(<obj>);
0005 % [IN]
0006 %    obj : brain_file_maker object
0007 % [OUT]
0008 %    none
0009 %
0010 % Author: rhayashi
0011 % Created: 2007-07-13
0012 %
0013 % Copyright (C) 2011, ATR All Rights Reserved.
0014 % License : New BSD License(see VBMEG_LICENSE.txt)
0015 
0016 %
0017 % --- Previous check
0018 %
0019 if ~exist('obj', 'var'), error('obj is a required parameter.'); end
0020 
0021 %
0022 % --- Main Procedure
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         % update ui status
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             % get analyze file information
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             % update ui status
0056             obj = brain_file_maker_update_display(obj);
0057             % set selected directory for next dialog open.
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         % update ui status
0068         obj = brain_file_maker_update_ui_state(obj);
0069     case H.product_type_popup
0070         obj.product_type = get(hObj, 'Value');
0071         % update ui status
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     % --- Mask file maker
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             % set selected directory for next dialog open.
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             % update ui status
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     % --- View/Edit callbacks
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             % 3D表示にjob_view_cortexを起動する。
0142             % job_view_cortexとmri_point_selectで、
0143             % figureハンドルが被る可能性があるので、その辺の注意が必要。
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             % 2D表示にmri_point_selectを起動する。
0159             % job_view_cortexとmri_point_selectで、
0160             % figureハンドルが被る可能性があるので、その辺の注意が必要。
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 %     % --- Parameter menu callbacks
0170 %     %
0171 %     case {H.job_smooth_cortex_parm_menu, H.job_brain_std2sbj_parm_menu}
0172 %         const = define_brain_file_maker;
0173 %         switch(hObj)
0174 %             case H.job_smooth_cortex_parm_menu
0175 %                 parm_type = const.JOB_SMOOTH_CORTEX_PARM;
0176 %             case H.job_brain_std2sbj_parm_menu
0177 %                 parm_type = const.JOB_BRAIN_STD2SBJ_PARM;
0178 %             otherwise
0179 %                 error('invalid parameter is specified.');
0180 %         end
0181 %         obj = brain_file_maker_edit_parm(obj, parm_type);
0182     %
0183     % --- Job callbacks
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         % Open parameter edit dialog
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         % Make smoothed brain files
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         % --- Execute make brain file from mask file.
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         % Open parameter edit dialog
0207         [obj, cancelled] = ...
0208             brain_file_maker_edit_parm(obj, const.JOB_BRAIN_STD2SBJ_PARM);
0209         if cancelled, return; end
0210         
0211         % make mask file
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             % use input file.(here, do nothing)
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         % make cortical files from mask file
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 % --- save application instance to figure
0257 %
0258 guidata(obj.H.figure, obj);

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005