IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
blmisc_rowsout_multistage.m
Go to the documentation of this file.
1 %> @brief Multi-Stage Complex Outlier Removal
2 %>
3 %> Uses a sequence of ( @c block , @c blmisc_rowsout ) pairs to output two datasets as any @c blmisc_rowsout block.
4 %>
5 %> Not published in UI
7  properties
8  %> ={}. Processors blocks.
9  processors = {};
10  %> ={}. @c blmisc_rowsout blocks
11  removers = {};
12  %> =0 (cascade). Possibilities:
13  %> @arg 0 - "cascade". Runs step on output of previous step.
14  %> @arg 1 - "intersection". Removes only the outliers yielded by all the stages.
15  %> @arg 2 - "union". Removes the outliers yielded by any of the stages.
16  mode = 0;
17 
18  log;
19  end;
20 
21  methods
22  function o = blmisc_rowsout_multistage()
23  o.classtitle = 'Multi-Stage';
24  end;
25  end;
26 
27  methods
28  function o = calculate_map(o, data)
30  o.log.mode = o.mode;
31  o.log.inputno = data.no;
32 
33  ns = length(o.processors);
34 
35  datai = data; % working dataset
36  ipro = progress2_open('BLMISC_ROWSOUT_MULTISTAGE', [], 0, ns);
37  for i = 1:ns
38  if ~isempty(o.processors{i}) % data does not necessarily need to be processed before outlier removal
39  o.processors{i} = o.processors{i}.boot();
40  o.processors{i} = o.processors{i}.train(datai);
41  datao = o.processors{i}.use(datai);
42  else
43  datao = datai; % bypass
44  end;
45  o.removers{i} = o.removers{i}.train(datao);
46  map = o.removers{i}.map;
47  maps{i} = map;
48 
49  o.log.stagesno(i) = numel(map);
50 
51  if o.mode == 0
52  datai = datai.map_rows(map);
53  end;
54 
55  ipro = progress2_change(ipro, [], [], i);
56  end;
57  progress2_close(ipro);
58 
59 
60  if o.mode > 0
61  map = maps{i};
62  for i = 2:ns
63  if o.mode == 1 % intersection
64  map = intersect(map, maps{i});
65  elseif o.mode == 2 % union
66  map = union(map, maps{i});
67  else
68  irerror(sprintf('Invalid mode: %d', o.mode));
69  end;
70  end;
71  o.map = map;
72  else
73  map = maps{1};
74  for i = 2:ns
75  map = map(maps{i});
76  end;
77  o.map = map;
78  end;
79 
80  o.log.maps = maps;
81  o.log.map = o.map;
82  end;
83  end;
84 end
85 
Outlier Removal base class.
function progress2_change(in prgrss, in title, in perc, in i, in n)
function progress2_open(in title, in perc, in i, in n)
function irerror(in s)
Log for the blmisc_rowsout_multistage block activity.
Base Block class.
Definition: block.m:2
function progress2_close(in prgrss)
Property classtitle
Class Title. Should have a descriptive name, as short as possible.
Definition: irobj.m:50
Multi-Stage Complex Outlier Removal.
Analysis Session (AS) base class.
Definition: as.m:6