0001 function [varargout] = pa_yokogawa_meg_util(fig, command, parm)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
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
0026
0027
0028
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
0043 guidata(fig, data);
0044
0045 function update_output_fname(H)
0046
0047
0048
0049
0050
0051
0052 global vbmeg_inst;
0053 define = vbmeg_inst.const;
0054
0055 filename = get(H.meg_file_edit, 'String');
0056
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
0067 save_dir = get(H.save_dir_edit, 'String');
0068
0069
0070 megmatfname = [save_dir filesep fname, sep, keyword, define.MEG2_EXTENSION];
0071
0072 set(H.megmat_file_edit, 'String', megmatfname);
0073
0074
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
0082
0083
0084
0085
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
0097
0098
0099
0100
0101
0102 H = data.H;
0103
0104
0105
0106
0107
0108
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
0115 meg_parm = data.yokogawa_meg_parm;
0116
0117
0118 meg_parm.yokogawa_file = get(H.meg_file_edit, 'String');
0119
0120
0121 meg_parm.device = 'YOKOGAWA';
0122
0123
0124 meg_parm.pos_file = get(H.position_file_edit, 'String');
0125
0126
0127
0128
0129
0130 meg_parm.keyword = get(H.keyword_edit, 'String');
0131
0132
0133 meg_parm.comment = get(H.comment_edit, 'String');
0134
0135
0136 meg_parm.saveman.data_dir = get(H.binary_dir_edit, 'String');
0137
0138
0139 meg_parm.meg_file = get(H.megmat_file_edit, 'String');
0140
0141
0142
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);
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
0159
0160
0161
0162
0163
0164 H = data.H;
0165
0166
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);