-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCullPulsesMulti.m
More file actions
84 lines (62 loc) · 2.69 KB
/
Copy pathCullPulsesMulti.m
File metadata and controls
84 lines (62 loc) · 2.69 KB
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
72
73
74
75
76
77
78
79
80
81
82
function CullPulsesMulti(folder,pulseInfo_name,Lik_name,Lik_type,minRange,maxRange)
%USAGE CullPulsesMulti(folder,pulseInfo_name,Lik_type,range)
%e.g.
%Lik_name = 'Lik_pulseInfo' or 'Lik_pulseInfo2'
%Lik_type = 'LLR_fh'
%minRange = 0
%maxRange = 'max'
pI_name = char(pulseInfo_name);
Lik_name = char(Lik_name);
Lik_type = char(Lik_type);
if strcmp(folder(end),'/') == 0
folder = [folder '/'];
end
dir_list = dir(folder);
file_num = length(dir_list);
for y = 1:file_num
file = dir_list(y).name; %pull out the file name
[~,root,ext] = fileparts(file);
path_file = [folder file];
TG = strcmp(ext,'.mat');
if TG == 1
fprintf([file '\n']);
W = who('-file',path_file);
varstruc =struct;
load(path_file);
for ii = 1:numel(W)
varstruc.(W{ii}) = eval(W{ii});
end
pIData = load(path_file,pI_name);
pI_data = pIData.(pI_name);
LikData = load(path_file,Lik_name);
a = fieldnames(LikData);
LikData = getfield(LikData,char(a));
Lik_data = LikData.(Lik_type);
if nargin < 6
maxRange = max(Lik_data) + 1;
end
culled_pulseInfo = ModelCullPulses(pI_data,Lik_data,[minRange maxRange]);
if strcmp(pI_name,'pulseInfo') == 1
varstruc.culled_pulseInfo = culled_pulseInfo;
varstruc.culled_pulseInfo.variables.pulseInfo_ver = pI_name;
varstruc.culled_pulseInfo.variables.Lik_ver = Lik_name;
varstruc.culled_pulseInfo.variables.range = [minRange maxRange];
varstruc.culled_pulseInfo.variables.date = date;
varstruc.culled_pulseInfo.variables.time = clock;
elseif strcmp(pI_name,'pulseInfo2') == 1
varstruc.culled_pulseInfo2 = culled_pulseInfo;
varstruc.culled_pulseInfo2.variables.pulseInfo_ver = pI_name;
varstruc.culled_pulseInfo2.variables.Lik_ver = Lik_name;
varstruc.culled_pulseInfo2.variables.range = [minRange maxRange];
varstruc.culled_pulseInfo2.variables.date = date;
varstruc.culled_pulseInfo2.variables.time = clock;
end
varstruc.culled_pulseInfo = culled_pulseInfo;
varstruc.culled_pulseInfo.variables.pulseInfo_ver = pI_name;
varstruc.culled_pulseInfo.variables.Lik_ver = Lik_name;
varstruc.culled_pulseInfo.variables.range = [minRange maxRange];
varstruc.culled_pulseInfo.variables.date = date;
varstruc.culled_pulseInfo.variables.time = clock;
save(path_file,'-struct','varstruc','-mat')%save all variables in original file
end
end