0001 function vb_eeg_tutorial(tut_code)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 if ~exist('tut_code', 'var'), tut_code = []; end
0027 [tut_code, data_root] = inner_solve_env(tut_code);
0028
0029
0030
0031
0032
0033 proj_root = './tutorial/EEG/vbmeg_data';
0034
0035
0036 FILE_BASE = 'sample_sako';
0037 EEG_EXT = '.eeg.mat';
0038
0039 switch tut_code
0040 case 1001
0041
0042 meg_parm.Measurement = 'EEG';
0043 meg_parm.device = 'BIOSEMI';
0044
0045 eeg_data_root = data_root;
0046 pos_data_root = data_root;
0047 meg_parm.measurement_file = [eeg_data_root '/' FILE_BASE '.bdf'];
0048 meg_parm.pos_file = [pos_data_root '/Takao_Sako.pos.mat'];
0049
0050 meg_parm.output_file = [FILE_BASE EEG_EXT];
0051 meg_parm.bin_data_dir = '';
0052
0053 vb_job_meg(proj_root, meg_parm);
0054
0055 case 1002
0056
0057
0058
0059 data_file = {FILE_BASE};
0060
0061
0062 onset_name = 'bit';
0063
0064
0065 parm.trig_type = 'bit';
0066 parm.slope = 'low_to_high';
0067 parm.condition = { 'bit'};
0068 parm.status_level = 2^4;
0069
0070 parm.status_ch = {'Status'};
0071 parm.status_mask = '11111111';
0072
0073
0074 parm.status_offset = - 6751232;
0075
0076
0077 parm.Pretrigger_ms = 1000;
0078 parm.Posttrigger_ms = 9000;
0079
0080 Nfile = length(data_file);
0081
0082
0083 for n=1:Nfile
0084
0085 parm.data_file = [data_file{n} EEG_EXT];
0086
0087
0088 parm.trig_file = [data_file{n} '_' onset_name '.trig.mat'];
0089
0090
0091 vb_job_trial_onset(proj_root, parm);
0092 end
0093 return;
0094
0095 case 1003
0096
0097
0098
0099 data_file = {FILE_BASE};
0100
0101
0102 parm.filt_suffix = '_filt';
0103 parm.bias_flg = 10;
0104 parm.highpass = 1;
0105 parm.lowpass = 100;
0106 parm.fsamp = [];
0107
0108 parm.highpass_online = 5;
0109 parm.lowpass_online = 5;
0110
0111
0112 parm.common_flg = [];
0113
0114 vb_fprint_filter_parm(parm);
0115
0116 proc_spec.parm = parm;
0117
0118 Nfile = length(data_file);
0119
0120 for n=1:Nfile
0121 tic
0122 eeg_file = [proj_root '/' data_file{n} EEG_EXT];
0123 proc_spec.new_eeg = [data_file{n} parm.filt_suffix EEG_EXT];
0124
0125 result = vb_eegfile_filter_ch_data(eeg_file, proc_spec);
0126
0127 vb_ptime(toc)
0128 end
0129 return;
0130
0131 case 1004
0132
0133
0134
0135 data_base = {FILE_BASE};
0136
0137
0138 onset = {'_bit'};
0139
0140
0141 filt_suffix = '_filt';
0142
0143 epoch_suffix = '_epoch';
0144
0145
0146 parm.Pretrigger_ms = 0;
0147 parm.Posttrigger_ms = 10000;
0148
0149 proc_spec.proc_parm = parm;
0150 proc_spec.root_dir = proj_root;
0151
0152 Nfile = length(data_base);
0153 Ncond = length(onset);
0154
0155 for n=1:Nfile
0156 for m=1:Ncond
0157
0158 proc_spec.trig_file = [data_base{n} onset{m} '.trig.mat'];
0159
0160
0161 if ~isempty(filt_suffix)
0162 data_file = [data_base{n} filt_suffix EEG_EXT];
0163 proc_spec.proc_parm.data_file = data_file;
0164 end
0165
0166
0167 proc_spec.new_file = ...
0168 [proj_root '/' data_base{n} onset{m} epoch_suffix EEG_EXT];
0169
0170 tic
0171 [data, ch_info] = vb_msrmnt_make_trial_data(proc_spec);
0172 vb_ptime(toc)
0173 end
0174 end
0175 return;
0176
0177 case 1005
0178
0179 eeg_file = [FILE_BASE '_bit_epoch.eeg.mat'];
0180 basis_parm = make_basis_parm(0, eeg_file);
0181
0182 vb_job_leadfield(proj_root, basis_parm);
0183
0184 case 1006
0185
0186 bayes_parm = make_bayes_parm(proj_root);
0187
0188 vb_job_vb(proj_root, bayes_parm);
0189
0190 case 1007
0191
0192 curr_parm = make_curr_parm;
0193 vb_job_current(proj_root, curr_parm);
0194
0195 case 1008
0196
0197 data_dir = proj_root;
0198 currfile = [data_dir '/' FILE_BASE '.curr.mat'];
0199 brainfile = [data_dir '/SKbrain.brain.mat'];
0200 job_plot_currentmap(currfile, brainfile);
0201
0202 case 2001
0203
0204 eeg_file = [proj_root '/' FILE_BASE '_bit_epoch.eeg.mat'];
0205 [eeg_data, ch_info] = vb_load_meg_data(eeg_file);
0206 fprintf('sizeof(eeg_data) = [%d x %d x %d]\n', ...
0207 size(eeg_data,1), size(eeg_data,2), size(eeg_data,3));
0208 n_ch = size(ch_info.Name);
0209 for i_ch = 1:n_ch
0210 fprintf('[%02d] %s\n', i_ch, ch_info.Name{i_ch});
0211 end
0212 end
0213
0214
0215
0216
0217
0218
0219 function [tut_code, data_root] = inner_solve_env(tut_code)
0220
0221
0222
0223
0224 data_root = '\\Cbi-data1\cbi-data1\sakot\sample_data\eeg';
0225
0226 if isempty(tut_code)
0227 tut_code = 1001;
0228 end
0229 return;
0230
0231