Home > functions > gui > preAnalysis > yokogawa_meg > pa_yokogawa_meg_util.m

pa_yokogawa_meg_util

PURPOSE ^

This function is subcontracting function of yokogawa meg gui.

SYNOPSIS ^

function [varargout] = pa_yokogawa_meg_util(fig, command, parm)

DESCRIPTION ^

 This function is subcontracting function of yokogawa meg gui.
 [IN]
        fig : figure handle of yokogawa meg gui.
    command : utility type
       parm : other parameters
 [OUT]
    varargout{n}: return value
        @command : 'get_eeg_gain' ==> gain

 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 [varargout] = pa_yokogawa_meg_util(fig, command, parm)
0002 % This function is subcontracting function of yokogawa meg gui.
0003 % [IN]
0004 %        fig : figure handle of yokogawa meg gui.
0005 %    command : utility type
0006 %       parm : other parameters
0007 % [OUT]
0008 %    varargout{n}: return value
0009 %        @command : 'get_eeg_gain' ==> gain
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 was specified.');
0019 end
0020 if ~exist('command', 'var') || isempty(command)
0021     error('invalid command was specified.');
0022 end
0023 
0024 %
0025 % --- Main Procedure
0026 %
0027 
0028 % load data(@see pa_yokogawa_meg_create)
0029 data = guidata(fig);
0030 
0031 switch(command)
0032     case 'update_output_fname'
0033         update_output_fname(data.H);
0034     case 'update_exec_push_status'
0035         update_exec_push_status(data.H);
0036     case 'exec_meg'
0037         exec_meg(data);
0038     case 'reset_parameter'
0039         reset_parameter(data);
0040 end
0041 
0042 % save data
0043 guidata(fig, data);
0044 
0045 function update_output_fname(H)
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     filename = get(H.meg_file_edit, 'String');
0056 %    [path, name, ext] = fileparts(fname);
0057     [fpath, fname, fext] = vb_get_file_parts(filename);
0058 
0059     keyword = get(H.keyword_edit, 'String');
0060     if length(keyword) ~= 0
0061         sep = '_';
0062     else
0063         sep = [];
0064     end
0065 
0066     % save directory
0067     save_dir = get(H.save_dir_edit, 'String');
0068 
0069     % save_dir/yokogawa_filename.meg.mat
0070     megmatfname = [save_dir filesep fname, sep, keyword, define.MEG2_EXTENSION];
0071     
0072     set(H.megmat_file_edit, 'String', megmatfname);
0073     
0074     % binary datadir name
0075     bin_dir = [ '.' filesep, fname sep, keyword, '_bin' ];
0076     set(H.binary_dir_edit, 'String', bin_dir);
0077     
0078     update_exec_push_status(H);
0079 
0080 function update_exec_push_status(H)
0081 % This function changes Exec button status.(clickable or not)
0082 % [IN]
0083 %    H : GUI component handles
0084 % [OUT]
0085 %    none
0086 
0087     if ~isempty(get(H.meg_file_edit, 'String')) & ...
0088        ~isempty(get(H.save_dir_edit, 'String')) & ...
0089        ~isempty(get(H.binary_dir_edit, 'String'))
0090         set(H.exec_push, 'Enable', 'on');
0091     else
0092         set(H.exec_push, 'Enable', 'off');
0093     end
0094 
0095 function H = exec_meg(data)
0096 % This function execute vb_job_meg with set parameter.
0097 % [IN]
0098 %    data : data of yokogawa meg gui(@see pa_yokogawa_meg_create)
0099 % [OUT]
0100 %    none
0101 
0102     H = data.H; % component handles
0103 
0104     %%%%%%%%%%%%%%%%%%%%
0105     % Parameter setting
0106     %%%%%%%%%%%%%%%%%%%%
0107 
0108     % project root directory
0109     proj_root = get(H.project_root_edit, 'String');
0110 
0111     save_dir   = get(H.save_dir_edit, 'String');
0112     binary_dir  = get(H.binary_dir_edit, 'String');
0113     
0114     % advanced parameters are set here.
0115     meg_parm = data.yokogawa_meg_parm;
0116 
0117     % data file
0118     meg_parm.yokogawa_file = get(H.meg_file_edit, 'String');
0119 
0120     % device
0121     meg_parm.device   = 'YOKOGAWA'; 
0122 
0123     % position file
0124     meg_parm.pos_file = get(H.position_file_edit, 'String');
0125     
0126     % Ext channel gain is already set @
0127     % pa_yokogawa_meg_edit_extra_channel_gain()
0128 
0129     % keyword
0130     meg_parm.keyword = get(H.keyword_edit, 'String');
0131 
0132     % comment
0133     meg_parm.comment = get(H.comment_edit, 'String');
0134     
0135     % saveman
0136     meg_parm.saveman.data_dir = get(H.binary_dir_edit, 'String');
0137 
0138     % MEG-MAT file(output)
0139     meg_parm.meg_file = get(H.megmat_file_edit, 'String');
0140 
0141     %%%%%%%%%%%%%%%%%%%%
0142     % execute job
0143     %%%%%%%%%%%%%%%%%%%%
0144     if exist([proj_root, '/', save_dir, '/', binary_dir], 'dir') == 7
0145         res = questdlg('binary directory already exists. Overwrite?', ...
0146                         'confirm', 'Yes', 'No', 'Yes');
0147         if strcmp(res, 'No'), return; end
0148     end
0149     str = get(H.exec_push, 'String');
0150     set(H.exec_push, 'String', 'Processing...');
0151     pause(0.01); % for update button string
0152 
0153     vb_job_meg(proj_root, meg_parm);
0154 
0155     set(H.exec_push, 'String', 'Exec');
0156 
0157 function data = reset_parameter(data)
0158 % This function resets yokogawa meg GUI.
0159 % [IN]
0160 %    H : GUI component handles
0161 % [OUT]
0162 %    none
0163 
0164     H = data.H;
0165 
0166     % clear eeg_gain information
0167     data.yokogawa_meg_parm.eeg_gain = [];
0168     guidata(data.H.figure, data);
0169 
0170     meg_parm = vb_set_yokogawa_meg_parm;
0171     pa_yokogawa_meg_set_parm(H.figure, meg_parm);
0172     data = guidata(H.figure);

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