-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBatchFilter.m
71 lines (61 loc) · 3.21 KB
/
BatchFilter.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function [m,s,mes1] = BatchFilter(SourceFolder,DestFolder,FilterObject,Patient,m,s,NumPatient,FilterName,H)
try
c = load(fullfile(SourceFolder,Patient));
indDot = findstr(Patient,'.');
if ~isempty(indDot),
Patient = Patient(1:indDot(end)-1);
end
arg2 = char(Patient);%
LeadName = fieldnames(c);
arg1 = c.(char(LeadName));
%---- Check the validity of the selected Data
%==cd(CurrentDir)
% [flag] = checkEKGstructformat(fieldnames(arg1));
Value = struct2cell(arg1); %%%%%***** Changed by Milind so as to be compatible with Dr. Hagan's "checkEKGstructformat.m" code
[flag] = checkEKGstructformat(fieldnames(arg1),Value);%%%%%***** Changed by Milind so as to be compatible with Dr. Hagan's "checkEKGstructformat.m" code
catch
flag =0;
end
if flag == 0,
%errordlg('You must select a valid structure signal','Error')
mes1 = ['Leads of patient ' arg2 ' are incomplete'];
% mesw{end+1} = mes1;
m = m+1;
if m==1
warndlg('Some files were bad. See the command window for details');
mes = ['Leads of some patients are incomplete'];
set(H.message,'string',char(mes));
end
else
mes1 = '';
%===cd(DestFolder)
LeadName = fieldnames(arg1);
clear cc
cc = struct2cell(arg1);
StdFieldName = {'i';'ii';'iii';'avl';'avr';'avf';'v1';'v2';'v3';...
'v4';'v5';'v6';'vx';'vy';'vz'};
%===cd(CurrentDir);
for i = 1:length(LeadName)
j = find(strcmp(LeadName{i},StdFieldName));
if ~isempty(j)
if isfield(FilterObject,'wavestr')
arg1_f.(char(LeadName(i)))= SAIDwfilter(FilterObject,cc{j});
else
arg1_f.(char(LeadName(i)))=filter(FilterObject,cc{j});
end
else
arg1_f.(char(LeadName(i)))=cc{i};
end
waitbar((s)/(length(LeadName)*NumPatient));
s=s+1;
end
cd(DestFolder)
arg1_f.Filter.Name = FilterName;
arg1_f.Filter.Date = datestr(now);
NewName = strcat(fieldnames(c),'_',FilterName);
NewName = NewName{1};
v = genvarname(NewName);
eval([v ' = arg1_f;']);
save(NewName,NewName);
end
% cd(CurrentDir);