Home > vbmeg > functions > gui > preAnalysis > brain > pa_brain_util.m

pa_brain_util

PURPOSE ^

This function is subcontracting function of brain GUI.

SYNOPSIS ^

function pa_brain_util(fig, command)

DESCRIPTION ^

 This function is subcontracting function of brain GUI.
 [USAGE]
    pa_brain_util(<fig>, <command>);
 [IN]
        fig : figure handle of brain gui.
    command : command
 [OUT]
    none

 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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function pa_brain_util(fig, command)
0002 % This function is subcontracting function of brain GUI.
0003 % [USAGE]
0004 %    pa_brain_util(<fig>, <command>);
0005 % [IN]
0006 %        fig : figure handle of brain gui.
0007 %    command : command
0008 % [OUT]
0009 %    none
0010 %
0011 % Copyright (C) 2011, ATR All Rights Reserved.
0012 % License : New BSD License(see VBMEG_LICENSE.txt)
0013 
0014 %
0015 % --- Previous check
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 % --- Main Procedure
0026 %
0027 
0028 % load data(@see pa_brain_create)
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 % save data
0043 guidata(fig, data);
0044 
0045 function update_output_fname(H, output_filename)
0046 % This function makes output filename and sets filename to GUI.
0047 % [IN]
0048 %    H : GUI component handles
0049 % [OUT]
0050 %    none
0051 
0052     global vbmeg_inst;
0053     define = vbmeg_inst.const;
0054 
0055     % save_dir
0056     save_dir = get(H.save_dir_edit, 'String');
0057 
0058     if isempty(output_filename)
0059         % make output filename from analyze filename
0060         fname   = get(H.analyze_edit, 'String');
0061         sep     = [];
0062         if isempty(fname) | isempty(fname)
0063             return;
0064         end
0065 
0066         % get Analyze filename(without path and extension)
0067         [f_path, f_name, f_ext] = vb_get_file_parts(fname);
0068 
0069     else
0070         f_name = output_filename;
0071     end
0072 
0073     % 'BRAIN file'
0074     brain_file = [save_dir, filesep, f_name, define.BRAIN_EXTENSION];
0075     set(H.brain_file_edit, 'String', brain_file);
0076     % 'AREA file'
0077     area_file = [save_dir, filesep, f_name, define.AREA_EXTENSION];
0078     set(H.area_file_edit, 'String', area_file);
0079     % 'ACT file'
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 % This function changes Exec button status.(clickable or not)
0087 % [IN]
0088 %    H : GUI component handles
0089 % [OUT]
0090 %    none
0091 
0092     % Analyze file input check
0093     if isempty(get(H.analyze_edit, 'String'))
0094         set(H.brain_exec_push, 'Enable', 'off');
0095         return;
0096     end
0097     % Save directory input check
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         % BrainVoyager file input check
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            % ~isempty(get(H.keyword_edit, 'String'))
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         % FreeSurfer file input check
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 % This function execute vb_job_brain with set parameter.
0136 % [IN]
0137 %    data : data of brain gui(@see pa_brain_create)
0138 % [OUT]
0139 %    none
0140 
0141     H = data.H;
0142 
0143     %%%%%%%%%%%%%%%%%%%%
0144     % Parameter setting
0145     %%%%%%%%%%%%%%%%%%%%
0146     % project root directory
0147     proj_root = get(H.prjroot_edit, 'String');
0148 
0149     % advanced parameters are set here.
0150     brain_parm = data.brain_parm;
0151     
0152     % Analyze file
0153     brain_parm.analyze_file = get(H.analyze_edit, 'String');
0154 
0155     if get(H.model_brainvoyager_radiobutton, 'Value')
0156         %
0157         % --- BrainVoyager
0158         %
0159         % Left-brain file
0160         brain_parm.BV_left_file = get(H.left_edit, 'String');
0161         % Right-brain file
0162         brain_parm.BV_right_file = get(H.right_edit, 'String');
0163         % Left-inflate file
0164         brain_parm.BV_left_infl_file = get(H.left_inflate_edit, 'String');
0165         % Right-inflate file
0166         brain_parm.BV_right_infl_file = get(H.right_inflate_edit, 'String');
0167 
0168         % SPM normalization file
0169         brain_parm.spm_normalization_file = get(H.spm_normalization_file_edit, 'String');
0170 
0171     elseif get(H.model_freesurfer_radiobutton, 'Value')
0172         %
0173         % --- FreeSurfer
0174         %
0175         % Left-brain file
0176         brain_parm.FS_left_file = get(H.freesurfer_left_edit, 'String');
0177         % Right-brain file
0178         brain_parm.FS_right_file = get(H.freesurfer_right_edit, 'String');
0179         % Left-inflate file
0180         brain_parm.FS_left_infl_file = get(H.freesurfer_left_inflate_edit, 'String');
0181         % Right-inflate file
0182         brain_parm.FS_right_infl_file = get(H.freesurfer_right_inflate_edit, 'String');
0183         % Left-curv file
0184         brain_parm.FS_left_curv_file = get(H.freesurfer_left_curv_edit, 'String');
0185         % Right-curv file
0186         brain_parm.FS_right_curv_file = get(H.freesurfer_right_curv_edit, 'String');
0187         % Left-label file
0188         brain_parm.FS_left_label_file = get(H.freesurfer_left_label_edit, 'String');
0189         % Right-label file
0190         brain_parm.FS_right_label_file = get(H.freesurfer_right_label_edit, 'String');
0191         % Left-sphere file
0192         brain_parm.FS_left_sphere_file = get(H.freesurfer_left_sphere_edit, 'String');
0193         % Right-sphere file
0194         brain_parm.FS_right_sphere_file = get(H.freesurfer_right_sphere_edit, 'String');
0195 
0196         % Sphere model registration
0197         brain_parm.registration_mode='FS';
0198         brain_parm.FS_sphere_key        = 'sphere.reg';
0199 
0200         % remove BV field(default is set by vb_set_brain_parm.m)
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     % BRAIN file
0216     brain_parm.brain_file = get(H.brain_file_edit, 'String');
0217 
0218     % AREA file
0219     brain_parm.area_file  = get(H.area_file_edit, 'String');
0220 
0221     % fMRI file
0222     brain_parm.act_file   = get(H.act_file_edit, 'String');
0223     
0224     %%%%%%%%%%%%%%%%%%%%
0225     % execute job
0226     %%%%%%%%%%%%%%%%%%%%
0227     set(H.brain_exec_push, 'String', 'Processing...');
0228     pause(0.01) % button string change
0229     vb_job_brain(proj_root, brain_parm);
0230     set(H.brain_exec_push, 'String', 'Exec');
0231 
0232 function update_model_type(H)
0233 % This function update screen by model type
0234 % [IN]
0235 %    H : GUI component handles
0236 % [OUT]
0237 %    none
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 %                H.freesurfer_left_sphere_label;
0275 %                H.freesurfer_left_sphere_edit;
0276 %                H.freesurfer_left_sphere_push;
0277 %                H.freesurfer_right_sphere_label;
0278 %                H.freesurfer_right_sphere_edit;
0279 %                H.freesurfer_right_sphere_push];
0280 
0281     model_type = 1; % 1 : BrainVoyager, 2:FreeSurfer
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');

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