0001 function [varargout] = pa_biosemi_eeg_util(fig, command, parm)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
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
0027
0028
0029
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
0044 guidata(fig, data);
0045
0046 function update_output_fname(H, output_filename)
0047
0048
0049
0050
0051
0052
0053 global vbmeg_inst;
0054 define = vbmeg_inst.const;
0055
0056 filename = get(H.bdf_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
0064 save_dir = get(H.save_dir_edit, 'String');
0065
0066
0067 eegmatfname = [save_dir filesep fname, define.EEG_EXTENSION];
0068 set(H.eegmat_file_edit, 'String', eegmatfname);
0069
0070
0071 bin_dir = vb_device_make_data_dir(eegmatfname, 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
0082
0083
0084
0085
0086
0087
0088
0089 if ~isempty(get(H.bdf_file_edit, 'String')) & ...
0090 ~isempty(get(H.save_dir_edit, 'String')) & ...
0091 ~isempty(get(H.eegmat_file_edit, 'String'))
0092 set(H.exec_push, 'Enable', 'on');
0093 else
0094 set(H.exec_push, 'Enable', 'off');
0095 end
0096
0097 function H = exec(data)
0098
0099
0100
0101
0102
0103
0104 H = data.H;
0105
0106
0107
0108
0109
0110
0111 proj_root = get(H.project_root_edit, 'String');
0112
0113
0114
0115
0116
0117
0118
0119 save_dir = get(H.save_dir_edit, 'String');
0120 eegmat_file = get(H.eegmat_file_edit, 'String');
0121
0122
0123
0124 meg_parm = data.biosemi_eeg_parm;
0125
0126
0127 bdf_file = get(H.bdf_file_edit, 'String');
0128 meg_parm.measurement_file = bdf_file;
0129
0130
0131 pos_file = get(H.position_file_edit, 'String');
0132 meg_parm.pos_file = pos_file;
0133
0134
0135 meg_parm.output_file = eegmat_file;
0136
0137
0138
0139
0140
0141 if exist(pos_file, 'file') == 2
0142 [ch_list_bdf] = vb_bdffile_get_info(bdf_file);
0143 [posinfo] = vb_posfile_get_posinfo(pos_file);
0144 ch_list_pos = posinfo.ChannelLabel;
0145
0146 IsOK = vb_dlg_compare_list(ch_list_bdf, ...
0147 ['BDF-file Channel list = ', num2str(length(ch_list_bdf))], ...
0148 ch_list_pos, ...
0149 ['POS-file Channel list = ', num2str(length(ch_list_pos))], ...
0150 'Is channel list correct?');
0151 if ~IsOK, return; end
0152 end
0153
0154 str = get(H.exec_push, 'String');
0155 set(H.exec_push, 'String', 'Processing...');
0156 pause(0.01);
0157
0158 vb_job_meg(proj_root, meg_parm);
0159
0160 set(H.exec_push, 'String', 'Exec');
0161
0162 function data = reset_parameter(data)
0163
0164
0165
0166
0167
0168
0169 H = data.H;
0170
0171 meg_parm = vb_set_meg_parm_biosemi;
0172 pa_biosemi_eeg_set_parm(H.figure, meg_parm);
0173 data = guidata(H.figure);
0174