Home > vbmeg > functions > gui > preAnalysis > brainamp_eeg > pa_brainamp_eeg_util.m

pa_brainamp_eeg_util

PURPOSE ^

This function is subcontracting function of brainamp eeg gui.

SYNOPSIS ^

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

DESCRIPTION ^

 This function is subcontracting function of brainamp eeg gui.
 [IN]
        fig : figure handle of brainamp eeg 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_brainamp_eeg_util(fig, command, parm)
0002 % This function is subcontracting function of brainamp eeg gui.
0003 % [IN]
0004 %        fig : figure handle of brainamp eeg gui.
0005 %    command : utility type
0006 %       parm : other parameters
0007 % [OUT]
0008 %    varargout{n}: return value
0009 %        @command : 'get_eeg_gain' ==> gain
0010 %
0011 %
0012 % Copyright (C) 2011, ATR All Rights Reserved.
0013 % License : New BSD License(see VBMEG_LICENSE.txt)
0014 
0015 %
0016 % --- Previous check
0017 %
0018 if ~exist('fig', 'var') || isempty(fig) || ~ishandle(fig)
0019     error('invalid figure was specified.');
0020 end
0021 if ~exist('command', 'var') || isempty(command)
0022     error('invalid command was specified.');
0023 end
0024 
0025 %
0026 % --- Main Procedure
0027 %
0028 
0029 % load data(@see pa_brainamp_eeg_create)
0030 data = guidata(fig);
0031 
0032 switch(command)
0033     case 'update_output_fname'
0034         update_output_fname(data.H, data.output_filename);
0035     case 'update_exec_push_status'
0036         update_exec_push_status(data.H);
0037     case 'execute'
0038         exec(data);
0039     case 'reset_parameter'
0040         reset_parameter(data);
0041 end
0042 
0043 % save data
0044 guidata(fig, data);
0045 
0046 function update_output_fname(H, output_filename)
0047 % This function makes output filename and sets filename to GUI.
0048 % [IN]
0049 %    H : GUI component handles
0050 % [OUT]
0051 %    none
0052 
0053     global vbmeg_inst;
0054     define = vbmeg_inst.const;
0055 
0056     filename = get(H.brainamp_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/bdf_filename.eeg.mat
0067     eegmatfname = [save_dir filesep fname, define.EEG_EXTENSION];
0068     set(H.eegmat_file_edit, 'String', eegmatfname);
0069 
0070     % binary datadir name
0071     bin_dir = [ '.' filesep, fname '_bin' ];
0072     set(H.binary_dir_edit, 'String', bin_dir);
0073     
0074     update_exec_push_status(H);
0075 
0076 function update_exec_push_status(H)
0077 % This function changes Exec button status.(clickable or not)
0078 % [IN]
0079 %    H : GUI component handles
0080 % [OUT]
0081 %    none
0082 
0083 %       ~isempty(get(H.position_file_edit, 'String')) & ...
0084 
0085     if ~isempty(get(H.brainamp_file_edit, 'String')) & ...
0086        ~isempty(get(H.save_dir_edit, 'String')) & ...
0087        ~isempty(get(H.eegmat_file_edit, 'String'))
0088         set(H.exec_push, 'Enable', 'on');
0089     else
0090         set(H.exec_push, 'Enable', 'off');
0091     end
0092 
0093 function H = exec(data)
0094 % This function execute vb_job_meg with set parameter.
0095 % [IN]
0096 %    data : data of brainamp eeg gui(@see pa_brainamp_eeg_create)
0097 % [OUT]
0098 %    none
0099 
0100     H = data.H; % component handles
0101 
0102     %%%%%%%%%%%%%%%%%%%%
0103     % Parameter setting
0104     %%%%%%%%%%%%%%%%%%%%
0105 
0106     % project root directory
0107     proj_root = get(H.project_root_edit, 'String');
0108 
0109     % device
0110 %     meg_parm.Measurement     = 'EEG';
0111 %     meg_parm.device          = 'BRAINAMP';
0112 
0113     % proj_root --- save_dir --- binary_dir
0114     %                         |- eeg_file
0115     save_dir   = get(H.save_dir_edit, 'String');
0116     binary_dir  = get(H.binary_dir_edit, 'String');
0117     eegmat_file  = get(H.eegmat_file_edit, 'String');
0118 
0119     
0120     % advanced parameters are set here.
0121     meg_parm = data.brainamp_eeg_parm;
0122     
0123     % BDF file.
0124     brainamp_file = get(H.brainamp_file_edit, 'String');
0125     meg_parm.measurement_file = brainamp_file;
0126     
0127     % POS-MAT file.
0128     pos_file = get(H.position_file_edit, 'String');
0129     meg_parm.pos_file = pos_file;
0130 
0131     % EEG-MAT file.
0132     meg_parm.output_file   = eegmat_file;
0133 
0134     %%%%%%%%%%%%%%%%%%%%
0135     % execute job
0136     %%%%%%%%%%%%%%%%%%%%
0137     
0138     if exist(pos_file, 'file') == 2
0139         [ch_list_brainamp] = vb_brainamp_get_info(brainamp_file);
0140         [posinfo] = vb_posfile_get_posinfo(pos_file);
0141         ch_list_pos = posinfo.ChannelLabel;
0142 
0143         IsOK = vb_dlg_compare_list(ch_list_brainamp, ...
0144                             ['Brainamp-file Channel list = ', num2str(length(ch_list_brainamp))], ...
0145                             ch_list_pos, ...
0146                             ['POS-file Channel list = ', num2str(length(ch_list_pos))], ...
0147                             'Is channel list correct?');
0148         if ~IsOK, return; end
0149     end
0150     
0151 %     if exist([proj_root, '/', save_dir, '/', binary_dir], 'dir') == 7
0152 %         res = questdlg('binary directory already exists. Overwrite?', ...
0153 %                         'confirm', 'Yes', 'No', 'Yes');
0154 %         if strcmp(res, 'No'), return; end
0155 %     end
0156             
0157     str = get(H.exec_push, 'String');
0158     set(H.exec_push, 'String', 'Processing...');
0159     pause(0.01); % for update button string
0160 
0161     vb_job_meg(proj_root, meg_parm);
0162 
0163     set(H.exec_push, 'String', 'Exec');
0164 
0165 function data = reset_parameter(data)
0166 % This function resets brainamp eeg GUI.
0167 % [IN]
0168 %    H : GUI component handles
0169 % [OUT]
0170 %    none
0171 
0172     H = data.H;
0173     
0174     meg_parm = vb_set_meg_parm_brainamp;
0175     pa_brainamp_eeg_set_parm(H.figure, meg_parm);
0176     data = guidata(H.figure);
0177

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