Home > vbmeg > 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, data.output_filename);
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, output_filename)
0046 % This function makes output filename and sets filename to GUI.
0047 % [IN]
0048 %                  H : GUI component handles
0049 %    output_filename : output filename
0050 % [OUT]
0051 %    none
0052 
0053     global vbmeg_inst;
0054     define = vbmeg_inst.const;
0055 
0056     filename = get(H.meg_file_edit, 'String');
0057     [fpath, fname, fext] = vb_get_file_parts(filename);
0058 
0059     if ~isempty(output_filename)
0060         fname = output_filename;
0061     end
0062     
0063     % save directory
0064     save_dir = get(H.save_dir_edit, 'String');
0065 
0066     % save_dir/yokogawa_filename.meg.mat
0067     megmatfname = [save_dir filesep fname, define.MEG2_EXTENSION];
0068     set(H.megmat_file_edit, 'String', megmatfname);
0069     
0070     % binary datadir name
0071     bin_dir = vb_device_make_data_dir(megmatfname, 0);
0072     if length(bin_dir) >= 2 && ...
0073        (strcmp(bin_dir(1:2), './') || strcmp(bin_dir(1:2), '.\'))
0074        bin_dir = fullfile(save_dir, bin_dir(3:end));
0075     end
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         set(H.exec_push, 'Enable', 'on');
0090     else
0091         set(H.exec_push, 'Enable', 'off');
0092     end
0093 
0094 function H = exec_meg(data)
0095 % This function execute vb_job_meg with set parameter.
0096 % [IN]
0097 %    data : data of yokogawa meg gui(@see pa_yokogawa_meg_create)
0098 % [OUT]
0099 %    none
0100 
0101     H = data.H; % component handles
0102 
0103     %%%%%%%%%%%%%%%%%%%%
0104     % Parameter setting
0105     %%%%%%%%%%%%%%%%%%%%
0106 
0107     % project root directory
0108     proj_root = get(H.project_root_edit, 'String');
0109 
0110     save_dir   = get(H.save_dir_edit, 'String');
0111     binary_dir  = get(H.binary_dir_edit, 'String');
0112     
0113     % advanced parameters are set here.
0114     meg_parm = data.yokogawa_meg_parm;
0115 
0116     % data file
0117     meg_parm.yokogawa_file = get(H.meg_file_edit, 'String');
0118 
0119     % device
0120     meg_parm.device   = 'YOKOGAWA'; 
0121 
0122     % position file
0123     meg_parm.pos_file = get(H.position_file_edit, 'String');
0124     
0125     % Ext channel gain is already set @
0126     % pa_yokogawa_meg_edit_extra_channel_gain()
0127 
0128     % MEG-MAT file(output)
0129     meg_parm.meg_file = get(H.megmat_file_edit, 'String');
0130 
0131     %%%%%%%%%%%%%%%%%%%%
0132     % execute job
0133     %%%%%%%%%%%%%%%%%%%%
0134     str = get(H.exec_push, 'String');
0135     set(H.exec_push, 'String', 'Processing...');
0136     pause(0.01); % for update button string
0137 
0138     vb_job_meg(proj_root, meg_parm);
0139 
0140     set(H.exec_push, 'String', 'Exec');
0141 
0142 function data = reset_parameter(data)
0143 % This function resets yokogawa meg GUI.
0144 % [IN]
0145 %    H : GUI component handles
0146 % [OUT]
0147 %    none
0148 
0149     H = data.H;
0150 
0151     % clear eeg_gain information
0152     data.yokogawa_meg_parm.eeg_gain = [];
0153     guidata(data.H.figure, data);
0154 
0155     meg_parm = vb_set_yokogawa_meg_parm;
0156     pa_yokogawa_meg_set_parm(H.figure, meg_parm);
0157     data = guidata(H.figure);

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