Home > 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);
0036     case 'update_model_type'
0037         update_model_type(data.H);
0038     case 'reset_parameter'
0039         reset_parameter(data.H);
0040     case 'exec_brain'
0041         exec_brain(data);
0042 end
0043 
0044 % save data
0045 guidata(fig, data);
0046 
0047 function update_output_fname(H)
0048 % This function makes output filename and sets filename to GUI.
0049 % [IN]
0050 %    H : GUI component handles
0051 % [OUT]
0052 %    none
0053 
0054     global vbmeg_inst;
0055     define = vbmeg_inst.const;
0056 
0057     % make output filename from analyze filename and keyword
0058     keyword = get(H.keyword_edit, 'String');
0059     fname   = get(H.analyze_edit, 'String');
0060     sep     = [];
0061     if isempty(fname) | isempty(fname)
0062         return;
0063     end
0064 
0065     % save_dir
0066     save_dir = get(H.save_dir_edit, 'String');
0067 
0068     % get Analyze filename(without path and extension)
0069 %    [path name ext] = fileparts(fname);
0070     [f_path, f_name, f_ext] = vb_get_file_parts(fname);
0071     
0072     if length(keyword) ~= 0
0073         sep = '_';
0074     else
0075         sep = [];
0076     end
0077     
0078     % 'BRAIN file'
0079     brain_file = [save_dir, filesep, f_name, sep, keyword, define.BRAIN_EXTENSION];
0080     set(H.brain_file_edit, 'String', brain_file);
0081     % 'AREA file'
0082     area_file = [save_dir, filesep, f_name, sep, keyword, define.AREA_EXTENSION];
0083     set(H.area_file_edit, 'String', area_file);
0084     % 'ACT file'
0085     act_file = [save_dir, filesep, f_name, sep, keyword, define.FMRI_EXTENSION];
0086     set(H.act_file_edit, 'String', act_file);
0087 
0088     update_exec_push_status(H);
0089 
0090 function update_exec_push_status(H)
0091 % This function changes Exec button status.(clickable or not)
0092 % [IN]
0093 %    H : GUI component handles
0094 % [OUT]
0095 %    none
0096 
0097     % Analyze file input check
0098     if isempty(get(H.analyze_edit, 'String'))
0099         set(H.brain_exec_push, 'Enable', 'off');
0100         return;
0101     end
0102     % Save directory input check
0103     if isempty(get(H.save_dir_edit, 'String'))
0104         set(H.brain_exec_push, 'Enable', 'off');
0105         return;
0106     end
0107 
0108     if get(H.model_brainvoyager_radiobutton, 'Value')
0109         % BrainVoyager file input check
0110         if ~isempty(get(H.left_edit, 'String')) &...
0111            ~isempty(get(H.right_edit, 'String')) &...
0112            ~isempty(get(H.left_inflate_edit, 'String')) &...
0113            ~isempty(get(H.right_inflate_edit, 'String'))
0114            % ~isempty(get(H.keyword_edit, 'String'))
0115             set(H.brain_exec_push, 'Enable', 'on');
0116         else
0117             set(H.brain_exec_push, 'Enable', 'off');
0118         end
0119     elseif get(H.model_freesurfer_radiobutton, 'Value')
0120         % FreeSurfer file input check
0121         if ~isempty(get(H.freesurfer_left_edit, 'String')) &...
0122            ~isempty(get(H.freesurfer_right_edit, 'String')) &...
0123            ~isempty(get(H.freesurfer_left_inflate_edit, 'String')) &...
0124            ~isempty(get(H.freesurfer_right_inflate_edit, 'String')) &...
0125            ~isempty(get(H.freesurfer_left_curve_edit, 'String')) &...
0126            ~isempty(get(H.freesurfer_right_curv_edit, 'String'))
0127             set(H.brain_exec_push, 'Enable', 'on');
0128         else
0129             set(H.brain_exec_push, 'Enable', 'off');
0130         end
0131     else
0132        set(H.brain_exec_push, 'Enable', 'off');
0133     end
0134 
0135 function exec_brain(data)
0136 % This function execute vb_job_brain with set parameter.
0137 % [IN]
0138 %    data : data of brain gui(@see pa_brain_create)
0139 % [OUT]
0140 %    none
0141 
0142     H = data.H;
0143 
0144     %%%%%%%%%%%%%%%%%%%%
0145     % Parameter setting
0146     %%%%%%%%%%%%%%%%%%%%
0147     % project root directory
0148     proj_root = get(H.prjroot_edit, 'String');
0149 
0150     % advanced parameters are set here.
0151     brain_parm = data.brain_parm;
0152     
0153     % Analyze file
0154     brain_parm.analyze_file = get(H.analyze_edit, 'String');
0155 
0156     if get(H.model_brainvoyager_radiobutton, 'Value')
0157         %
0158         % --- BrainVoyager
0159         %
0160         % Left-brain file
0161         brain_parm.BV_left_file = get(H.left_edit, 'String');
0162         % Right-brain file
0163         brain_parm.BV_right_file = get(H.right_edit, 'String');
0164         % Left-inflate file
0165         brain_parm.BV_left_infl_file = get(H.left_inflate_edit, 'String');
0166         % Right-inflate file
0167         brain_parm.BV_right_infl_file = get(H.right_inflate_edit, 'String');
0168     elseif get(H.model_freesurfer_radiobutton, 'Value')
0169         %
0170         % --- FreeSurfer
0171         %
0172         % Left-brain file
0173         brain_parm.FS_left_file = get(H.freesurfer_left_edit, 'String');
0174         % Right-brain file
0175         brain_parm.FS_right_file = get(H.freesurfer_right_edit, 'String');
0176 %        % xfm file
0177 %        brain_parm.FS_xfm_file = get(H.freesurfer_xfm_edit, 'String');
0178         % Left-inflate file
0179         brain_parm.FS_left_infl_file = get(H.freesurfer_left_inflate_edit, 'String');
0180         % Right-inflate file
0181         brain_parm.FS_right_infl_file = get(H.freesurfer_right_inflate_edit, 'String');
0182         % Left-curv file
0183         brain_parm.FS_left_curv_file = get(H.freesurfer_left_curve_edit, 'String');
0184         % Right-curv file
0185         brain_parm.FS_right_curv_file = get(H.freesurfer_right_curv_edit, 'String');
0186         
0187         % remove BV field( default is set by vb_set_brain_parm.m)
0188         if isfield(brain_parm, 'BV_left_file')
0189             brain_parm = rmfield(brain_parm, 'BV_left_file');
0190         end
0191         if isfield(brain_parm, 'BV_right_file')
0192             brain_parm = rmfield(brain_parm, 'BV_right_file');
0193         end
0194         if isfield(brain_parm, 'BV_left_infl_file')
0195             brain_parm = rmfield(brain_parm, 'BV_left_infl_file');
0196         end
0197         if isfield(brain_parm, 'BV_right_infl_file')
0198             brain_parm = rmfield(brain_parm, 'BV_right_infl_file');
0199         end
0200     end
0201 
0202     % SPM normalization file
0203     brain_parm.spm_normalization_file = get(H.spm_normalization_file_edit, 'String');
0204 
0205     % BRAIN file
0206     brain_parm.brain_file = get(H.brain_file_edit, 'String');
0207 
0208     % AREA file
0209     brain_parm.area_file  = get(H.area_file_edit, 'String');
0210 
0211     % fMRI file
0212     brain_parm.act_file   = get(H.act_file_edit, 'String');
0213     
0214     % keyword
0215     brain_parm.keyword = get(H.keyword_edit, 'String');
0216 
0217     % Comment
0218     brain_parm.comment = get(H.comment_edit, 'String');
0219 
0220     %%%%%%%%%%%%%%%%%%%%
0221     % execute job
0222     %%%%%%%%%%%%%%%%%%%%
0223     str = get(H.brain_exec_push, 'String');
0224     set(H.brain_exec_push, 'String', 'Processing...');
0225     pause(0.01) % button string change
0226     vb_job_brain(proj_root, brain_parm);
0227     % vb_job_inflate(proj_root, brain_parm); 2011/1/28 comment out
0228     set(H.brain_exec_push, 'String', 'Exec');
0229 
0230 function reset_parameter(H)
0231 % This function resets brain GUI.
0232 % [IN]
0233 %    H : GUI component handles
0234 % [OUT]
0235 %    none
0236 
0237     set(H.analyze_edit, 'String', '');
0238     set(H.analyze_edit, 'String', '');
0239     set(H.left_edit, 'String', '');
0240     set(H.right_edit, 'String', '');
0241     set(H.left_inflate_edit, 'String', '');
0242     set(H.right_inflate_edit, 'String', '');
0243     set(H.freesurfer_left_edit, 'String', '');
0244     set(H.freesurfer_right_edit, 'String', '');
0245     set(H.freesurfer_xfm_edit, 'String', '');
0246     set(H.freesurfer_left_inflate_edit, 'String', '');
0247     set(H.freesurfer_right_inflate_edit, 'String', '');
0248     set(H.freesurfer_left_curve_edit, 'String', '');
0249     set(H.freesurfer_right_curv_edit, 'String', '');
0250 
0251     set(H.keyword_edit, 'String', '');
0252     set(H.comment_edit, 'String', '');
0253     set(H.save_dir_edit, 'String', '');
0254     set(H.brain_file_edit, 'String', '');
0255     set(H.area_file_edit, 'String', '');
0256     set(H.act_file_edit, 'String', '');
0257 
0258 function update_model_type(H)
0259 % This function update screen by model type
0260 % [IN]
0261 %    H : GUI component handles
0262 % [OUT]
0263 %    none
0264 
0265     bv_group = [H.brainvoyager_left_brain_label;
0266                 H.left_edit;
0267                 H.left_push;
0268                 H.brainvoyager_right_brain_label;
0269                 H.right_edit;
0270                 H.right_push;
0271                 H.brainvoyager_left_inf_label;
0272                 H.left_inflate_edit;
0273                 H.left_inflate_push;
0274                 H.brainvoyager_right_inf_label;
0275                 H.right_inflate_edit;
0276                 H.right_inflate_push];
0277 
0278     fs_group = [H.freesurfer_left_brain_label;
0279                 H.freesurfer_left_edit;
0280                 H.freesurfer_left_push;
0281                 H.freesurfer_right_brain_label;
0282                 H.freesurfer_right_edit;
0283                 H.freesurfer_right_push;
0284 %                H.freesurfer_xfm_label;
0285 %                H.freesurfer_xfm_edit;
0286 %                H.freesurfer_xml_push;
0287                 H.freesurfer_left_inflate_label;
0288                 H.freesurfer_left_inflate_edit;
0289                 H.freesurfer_left_inflate_push;
0290                 H.freesurfer_right_inflate_label;
0291                 H.freesurfer_right_inflate_edit;
0292                 H.freesurfer_right_inflate_push;
0293                 H.freesurfer_left_curv_label;
0294                 H.freesurfer_left_curve_edit;
0295                 H.freesurfer_left_curv_push;
0296                 H.freesurfer_right_curv_label;
0297                 H.freesurfer_right_curv_edit;
0298                 H.freesurfer_right_curv_push];
0299 
0300     model_type = 1; % 1 : BrainVoyager, 2:FreeSurfer
0301     if get(H.model_brainvoyager_radiobutton, 'Value')
0302         model_type = 1;
0303     elseif get(H.model_freesurfer_radiobutton, 'Value')
0304         model_type = 2;
0305     else
0306         error('model type error : pa_brain_util()');
0307     end
0308 
0309     switch(model_type)
0310     case 1
0311         set(bv_group, 'Visible', 'on');
0312         set(fs_group, 'Visible', 'off');
0313     case 2
0314         set(bv_group, 'Visible', 'off');
0315         set(fs_group, 'Visible', 'on');
0316     end

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005