vb_test_filter_data High/lowpass filtering of continuous raw MEG/EEG data and make new external channel-wise binary data files New file is saved in the same directory with the original data --- Usage for MEG vb_megfile_filter_ch_data(meg_file, proc_spec); --- Input meg_file : path name of '.meg.mat' file with channel-wise binary data proc_spec.new_meg : output file name of filtered data --- Usage for EEG vb_eegfile_filter_ch_data(eeg_file, proc_spec); --- Input eeg_file : path name of '.eeg.mat' file with channel-wise binary data proc_spec.new_eeg : output file name of filtered data --- Common preprocess parameter proc_spec.parm .bias_flg : Bias correction flag (= 0/1/2 : OFF/Bias/Linear) = N > 5: Bias correction by first N sample .common_flg : Common reference flag (= 1/0 : ON/OFF) .highpass : Highpass filter cutoff frequency [Hz] .lowpass : Lowpass filter cutoff frequency [Hz] .fsamp : Down sampling frequency [Hz] --- If these fields are empty, corresponding process are not applied --- Type of filter specification .highpass_online : filter order of IIR highpass filter = 0: FIR highpass filter (eegfilt) = 1: online highpass filter (exponential) > 1: Butterworth highpass filter (filtfilt) < 0: Butterworth highpass filter (online) .lowpass_online : filter order of IIR lowpass filter = 0: FIR lowpass filter (eegfilt) = 1: online lowpass filter (exponential) > 1: Butterworth lowpass filter (filtfilt) < 0: Butterworth lowpass filter (online) 2009-8-10 Masa-aki Sato Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 % vb_test_filter_data 0002 % High/lowpass filtering of continuous raw MEG/EEG data 0003 % and make new external channel-wise binary data files 0004 % New file is saved in the same directory with the original data 0005 % 0006 % --- Usage for MEG 0007 % vb_megfile_filter_ch_data(meg_file, proc_spec); 0008 % --- Input 0009 % meg_file : path name of '.meg.mat' file with channel-wise binary data 0010 % proc_spec.new_meg : output file name of filtered data 0011 % 0012 % --- Usage for EEG 0013 % vb_eegfile_filter_ch_data(eeg_file, proc_spec); 0014 % --- Input 0015 % eeg_file : path name of '.eeg.mat' file with channel-wise binary data 0016 % proc_spec.new_eeg : output file name of filtered data 0017 % 0018 % --- Common preprocess parameter 0019 % proc_spec.parm 0020 % .bias_flg : Bias correction flag (= 0/1/2 : OFF/Bias/Linear) 0021 % = N > 5: Bias correction by first N sample 0022 % .common_flg : Common reference flag (= 1/0 : ON/OFF) 0023 % .highpass : Highpass filter cutoff frequency [Hz] 0024 % .lowpass : Lowpass filter cutoff frequency [Hz] 0025 % .fsamp : Down sampling frequency [Hz] 0026 % --- If these fields are empty, 0027 % corresponding process are not applied 0028 % --- Type of filter specification 0029 % .highpass_online : filter order of IIR highpass filter 0030 % = 0: FIR highpass filter (eegfilt) 0031 % = 1: online highpass filter (exponential) 0032 % > 1: Butterworth highpass filter (filtfilt) 0033 % < 0: Butterworth highpass filter (online) 0034 % 0035 % .lowpass_online : filter order of IIR lowpass filter 0036 % = 0: FIR lowpass filter (eegfilt) 0037 % = 1: online lowpass filter (exponential) 0038 % > 1: Butterworth lowpass filter (filtfilt) 0039 % < 0: Butterworth lowpass filter (online) 0040 % 0041 % 2009-8-10 Masa-aki Sato 0042 % 0043 % Copyright (C) 2011, ATR All Rights Reserved. 0044 % License : New BSD License(see VBMEG_LICENSE.txt) 0045 0046 data_mode = 'eeg'; 0047 0048 switch data_mode 0049 case 'meg' 0050 % root directry 0051 root_dir = [getenv('MATHOME') '/Sekiyama']; 0052 % --- List of data file names (base name without extension) 0053 data_file = {'AM090311a'}; 0054 ext = '.meg.mat'; 0055 case 'eeg' 0056 % root directry 0057 root_dir = [getenv('MATHOME') '/BCI_Tmp/eeg_data']; 0058 % --- EEG file names (base name without extension) 0059 data_file = {'Sako_20080903_1', 'Sako_20080903_2'}; 0060 ext = '.eeg.mat'; 0061 end 0062 0063 % --- preprocess parameter 0064 parm.filt_suffix = '_filt'; % suffix of filtered data 0065 parm.bias_flg = 10; % Bias correction (=0/1/2: OFF/Bias/Linear) 0066 parm.highpass = [1]; % Highpass filter cutoff frequency [Hz] 0067 parm.lowpass = [100]; % Lowpass filter cutoff frequency [Hz] 0068 parm.fsamp = [];% down sampling frequency [Hz] 0069 0070 parm.highpass_online = [5]; % order of online highpass filter 0071 parm.lowpass_online = [5]; % order of online lowpass filter 0072 0073 % Common reference should be done after bad channel removal 0074 parm.common_flg = [];% Common reference flag (=1/0 : ON/OFF) 0075 0076 vb_fprint_filter_parm(parm); 0077 0078 proc_spec.parm = parm; 0079 0080 Nfile = length(data_file); 0081 %Nfile = 1; 0082 0083 for n=1:Nfile 0084 tic 0085 switch data_mode 0086 case 'meg' 0087 meg_file = [root_dir '/' data_file{n} ext]; 0088 proc_spec.new_meg = [data_file{n} parm.filt_suffix ext]; 0089 0090 result = vb_megfile_filter_ch_data(meg_file, proc_spec); 0091 case 'eeg' 0092 eeg_file = [root_dir '/' data_file{n} ext]; 0093 proc_spec.new_eeg = [data_file{n} parm.filt_suffix ext]; 0094 0095 result = vb_eegfile_filter_ch_data(eeg_file, proc_spec); 0096 end 0097 vb_ptime(toc) 0098 end 0099 0100 0101 return 0102