Home > functions > gui > preAnalysis > biosemi_eeg > pa_biosemi_eeg_util.m

pa_biosemi_eeg_util

PURPOSE ^

This function is subcontracting function of biosemi eeg gui.

SYNOPSIS ^

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

DESCRIPTION ^

 This function is subcontracting function of biosemi eeg gui.
 [IN]
        fig : figure handle of biosemi 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_biosemi_eeg_util(fig, command, parm)
0002 % This function is subcontracting function of biosemi eeg gui.
0003 % [IN]
0004 %        fig : figure handle of biosemi 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_biosemi_eeg_create)
0030 data = guidata(fig);
0031 
0032 switch(command)
0033     case 'update_output_fname'
0034         update_output_fname(data.H);
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)
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.bdf_file_edit, 'String');
0057 %    [path, name, ext] = fileparts(fname);
0058     [fpath, fname, fext] = vb_get_file_parts(filename);
0059 
0060     keyword = get(H.keyword_edit, 'String');
0061     if length(keyword) ~= 0
0062         sep = '_';
0063     else
0064         sep = [];
0065     end
0066 
0067     % save directory
0068     save_dir = get(H.save_dir_edit, 'String');
0069     
0070 %     % binary directory
0071 %     binary_dir = get(H.binary_dir_edit, 'String');
0072 %     ix = find(binary_dir, filesep);
0073 %     if ~isempty(ix)
0074 %         ix = max(ix);
0075 %         binary_dir = binary_dir(ix:end);
0076 %     end
0077 %     if isempty(binary_dir) || strcmp(binary_dir, '.')
0078 %         binary_dir = 'bin_data';
0079 %     end
0080 %
0081 %     % relative path from save_dir to binary_dir.
0082 %     rel_path = vb_relativepath(binary_dir, save_dir);
0083 %
0084 %     % remove top '.' + filesep
0085 %     if strncmp(rel_path, ['.' filesep], 2), rel_path(1:2)=[]; end
0086 %
0087 %     % remove last filesep
0088 %     rel_path_len = length(rel_path);
0089 %     if rel_path_len > 0 && strcmp(rel_path(rel_path_len), filesep)
0090 %         rel_path(rel_path_len) = [];
0091 %     end
0092 %     set(H.binary_dir_edit, 'String', [save_dir, filesep, rel_path]);
0093 
0094     % save_dir/bdf_filename.eeg.mat
0095     eegmatfname = [save_dir filesep fname, sep, keyword define.EEG_EXTENSION];
0096     set(H.eegmat_file_edit, 'String', eegmatfname);
0097 
0098     % binary datadir name
0099     bin_dir = [ '.' filesep, fname '_bin' ];
0100     set(H.binary_dir_edit, 'String', bin_dir);
0101     
0102     update_exec_push_status(H);
0103 
0104 function update_exec_push_status(H)
0105 % This function changes Exec button status.(clickable or not)
0106 % [IN]
0107 %    H : GUI component handles
0108 % [OUT]
0109 %    none
0110 
0111 %       ~isempty(get(H.position_file_edit, 'String')) & ...
0112 
0113     if ~isempty(get(H.bdf_file_edit, 'String')) & ...
0114        ~isempty(get(H.save_dir_edit, 'String')) & ...
0115        ~isempty(get(H.eegmat_file_edit, 'String'))
0116         set(H.exec_push, 'Enable', 'on');
0117     else
0118         set(H.exec_push, 'Enable', 'off');
0119     end
0120 
0121 function H = exec(data)
0122 % This function execute vb_job_meg with set parameter.
0123 % [IN]
0124 %    data : data of biosemi eeg gui(@see pa_biosemi_eeg_create)
0125 % [OUT]
0126 %    none
0127 
0128     H = data.H; % component handles
0129 
0130     %%%%%%%%%%%%%%%%%%%%
0131     % Parameter setting
0132     %%%%%%%%%%%%%%%%%%%%
0133 
0134     % project root directory
0135     proj_root = get(H.project_root_edit, 'String');
0136 
0137     % device
0138 %     meg_parm.Measurement     = 'EEG';
0139 %     meg_parm.device          = 'BIOSEMI';
0140 
0141     % proj_root --- save_dir --- binary_dir
0142     %                         |- eeg_file
0143     save_dir   = get(H.save_dir_edit, 'String');
0144     binary_dir  = get(H.binary_dir_edit, 'String');
0145     eegmat_file  = get(H.eegmat_file_edit, 'String');
0146 
0147     
0148     % advanced parameters are set here.
0149     meg_parm = data.biosemi_eeg_parm;
0150     
0151     % BDF file.
0152     bdf_file = get(H.bdf_file_edit, 'String');
0153     meg_parm.measurement_file = bdf_file;
0154     
0155     % POS-MAT file.
0156     pos_file = get(H.position_file_edit, 'String');
0157     meg_parm.pos_file = pos_file;
0158 
0159     % EEG-MAT file.
0160     meg_parm.output_file   = eegmat_file;
0161 
0162     % Binary output directory
0163     meg_parm.bin_data_dir = binary_dir;
0164 
0165     % keyword
0166     meg_parm.keyword = get(H.keyword_edit, 'String');
0167 
0168     % comment
0169     meg_parm.comment = get(H.comment_edit, 'String');
0170 
0171     %%%%%%%%%%%%%%%%%%%%
0172     % execute job
0173     %%%%%%%%%%%%%%%%%%%%
0174     
0175     if exist(pos_file, 'file') == 2
0176         [ch_list_bdf] = vb_bdffile_get_info(bdf_file);
0177         [posinfo] = vb_posfile_get_posinfo(pos_file);
0178         ch_list_pos = posinfo.ChannelLabel;
0179 
0180         IsOK = vb_dlg_compare_list(ch_list_bdf, ...
0181                             ['BDF-file Channel list = ', num2str(length(ch_list_bdf))], ...
0182                             ch_list_pos, ...
0183                             ['POS-file Channel list = ', num2str(length(ch_list_pos))], ...
0184                             'Is channel list correct?');
0185         if ~IsOK, return; end
0186     end
0187     
0188     if exist([proj_root, '/', save_dir, '/', binary_dir], 'dir') == 7
0189         res = questdlg('binary directory already exists. Overwrite?', ...
0190                         'confirm', 'Yes', 'No', 'Yes');
0191         if strcmp(res, 'No'), return; end
0192     end
0193             
0194     str = get(H.exec_push, 'String');
0195     set(H.exec_push, 'String', 'Processing...');
0196     pause(0.01); % for update button string
0197 
0198     vb_job_meg(proj_root, meg_parm);
0199 
0200     set(H.exec_push, 'String', 'Exec');
0201 
0202 function data = reset_parameter(data)
0203 % This function resets biosemi eeg GUI.
0204 % [IN]
0205 %    H : GUI component handles
0206 % [OUT]
0207 %    none
0208 
0209     H = data.H;
0210     
0211     meg_parm = vb_set_meg_parm_biosemi;
0212     pa_biosemi_eeg_set_parm(H.figure, meg_parm);
0213     data = guidata(H.figure);
0214

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