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, 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
0043 guidata(fig, data);
0044
0045 function update_output_fname(H, output_filename)
0046
0047
0048
0049
0050
0051
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
0064 save_dir = get(H.save_dir_edit, 'String');
0065
0066
0067 megmatfname = [save_dir filesep fname, define.MEG2_EXTENSION];
0068 set(H.megmat_file_edit, 'String', megmatfname);
0069
0070
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
0082
0083
0084
0085
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
0096
0097
0098
0099
0100
0101 H = data.H;
0102
0103
0104
0105
0106
0107
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
0114 meg_parm = data.yokogawa_meg_parm;
0115
0116
0117 meg_parm.yokogawa_file = get(H.meg_file_edit, 'String');
0118
0119
0120 meg_parm.device = 'YOKOGAWA';
0121
0122
0123 meg_parm.pos_file = get(H.position_file_edit, 'String');
0124
0125
0126
0127
0128
0129 meg_parm.meg_file = get(H.megmat_file_edit, 'String');
0130
0131
0132
0133
0134 str = get(H.exec_push, 'String');
0135 set(H.exec_push, 'String', 'Processing...');
0136 pause(0.01);
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
0144
0145
0146
0147
0148
0149 H = data.H;
0150
0151
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);