forked from Temporo-spatial/IntrinsicNeuralTimescales-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_50Hz.m
40 lines (26 loc) · 1.14 KB
/
filter_50Hz.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
directory_name = uigetdir;
cd(directory_name);
eeglab
%%%%Let's select the relevant files,
files = dir(fullfile(directory_name, '*.set'));
% EEG = pop_mffimport('fileindex');
%EEG = pop_readegimff ('EEG', 'auto', 'files');
%EEG = pop_mffimport('filename', {'classid'});
fileindex = find(~[files.isdir]);
%%%%Loop through all the files
for i = 1:length(fileindex)
filename = files(fileindex(i)).name;
[PATH, NAME, EXT] = fileparts(filename);
NAME = [NAME, EXT];
%load the data set
EEG = pop_loadset( 'filename', filename, 'filepath', directory_name);
EEG.data=EEG.data';
% Load the filter
load('FIRFilter_order1000_notch59.8-60.2_Hamming_fs250hz.mat') %('FIRFilter_order1000_notch59.8-60.2_Hamming.mat')
% Apply the filter to your signal
EEG.data=filtfilt(Num,Den,double(EEG.data));
% YOUR_EEG must be a matriz where the rows are the samples and the columns are the channel. IE: size(YOR_EEG) must be 75001 x channels
EEG.data=EEG.data';
% Finally, save the new file that has been cleaned:
EEG = pop_saveset( EEG, 'filename',[filename, '_filt.set'],'filepath',[directory_name '\filt']);
end;