IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
report_soitem_merger_merger_fhg.m
Go to the documentation of this file.
1 %> @brief
3  properties
6  %> @ref biocomparer object
8 
10  %> Cell of subsetsprocessors to perform biomarkers comparisons using different subsetsprocessors. If used, the comparison will be per stab
11  %> Note that this property does not have a corresponding GUI input at the moment.
12  subsetsprocessors;
13 
14  flag_draw_stability = 1;
15 
16  flag_biocomp_per_clssr = 1;
17  flag_biocomp_per_stab = 1;
18  flag_biocomp_all = 1;
19  %> Biomarkers comparison per subsetsprocessor
20  flag_biocomp_per_ssp = 1;
21  %> Whether to show the nf4grades statistics
22  flag_nf4grades = 1;
23  %> =10. Stabilization number to be used in the "all" comparison
24  stab4all = 10;
25 
26  %> Whether to generate a table where the varying element will be the nf4grades of a fixed-nf4grades subsetsprocessor
27  flag_biocomp_nf4grades = 1;
28  end;
29 
30  methods
32  o.classtitle = 'Biomarker comparison tables';
33  o.inputclass = 'soitem_merger_merger_fhg';
34  o.flag_params = 1;
35  end;
36  end;
37 
38  methods(Access=protected)
39  function out = do_use(o, item)
40  out = log_html();
41  if o. flag_biocomp_per_clssr || o.flag_biocomp_per_stab || o.flag_biocomp_all || o.flag_nf4grades
42  item = item.calculate_stabilities(def_subsetsprocessor(o.subsetsprocessor));
43  end;
44 
45  s = o.get_standardheader(item);
46 
47  out.html = [s, o.get_html_graphics(item)];
48  out.title = item.get_description();
49  end;
50  end;
51 
52 
53  methods
54  %> Generates a table with the best in each architecture, with its respective time and confidence interval
55  %> @param item a soitem_merger_merger_fhg object
56  function s = get_html_graphics(o, item)
57  s = '';
58 
59  if o.flag_biocomp_per_clssr
60 
61  % Finds out methodologies with more than one variation ("stabilizations")
62  groupidxs = item.find_methodologygroups();
63  n = numel(groupidxs);
64 
65  % Generates sub-reports for these groups separately
66  for i = 1:n
67  if i > 1; s = cat(2, s, '<hr />', 10); end;
68  s = cat(2, s, sprintf('<h1>FHG setup: "%s"</h1>\n', item.items(1).s_methodologies{groupidxs{i}(1)}), o.get_html_biocomparison(item, groupidxs{i}));
69  end;
70 
71  s = cat(2, s, '<h1>FHG setups table merge</h1>', item.html_biocomparisontable_stab(def_subsetsprocessor(o.subsetsprocessor), o.peakdetector, o.biocomparer));
72 
73  s = cat(2, s, '<hr />', 10);
74  end;
75 
76  if o.flag_biocomp_per_stab
77  stabs = unique(item.items(1).stabs);
78  stabs(stabs < 0) = [];
79  for i = 1:numel(stabs)
80  [s_temp, M(:, :, :, i), titles_temp] = o.get_html_biocomparison(item, item.find_stab(stabs(i))); %#ok<AGROW>
81  s = cat(2, s, sprintf('<h1>Stabilization: "stab%02d"</h1>\n', stabs(i)), s_temp);
82 
83  if i == 1
84  titles = titles_temp;
85  end;
86  end;
87 
88  s = cat(2, s, o.get_html_stab_x_coherence(M, titles));
89  s = cat(2, s, '<hr />', 10);
90  end;
91 
92  if o.flag_biocomp_all
93  idxs = item.find_stab(o.stab4all); % Picks one representant from each group
94  idxs = idxs(:)'; % makes 10, 20, 10, 20, ...
95  idxs = [idxs, item.find_single()];
96  s = cat(2, s, '<h1>Comparison of Methodologies</h1>', 10, o.get_html_biocomparison(item, idxs));
97  % Generates one report for comparison among ALL different methodologies
98  s = cat(2, s, '<hr />', 10);
99  end;
100 
101  if o.flag_biocomp_nf4grades
102  s = cat(2, s, '<h1>Comparison of nf4grades</h1>', 10);
103  stabs = unique(item.items(1).stabs);
104  stabs(stabs < 0) = [];
105  for i = 1:numel(stabs)
106  s = cat(2, s, sprintf('<h2>Comparison of nf4grades - stab%02d</h2>\n', stabs(i)));
107  s = cat(2, s, o.get_html_biocomp_nf4grades(item, item.items(1).find_stab(stabs(i))));
108  end;
109 
110  s = cat(2, s, sprintf('<h2>Comparison of nf4grades - stab-all</h2>\n'));
111  s = cat(2, s, o.get_html_biocomp_nf4grades(item, find(item.items(1).stabs >= 0))); %#ok<FNDSB>
112  s = cat(2, s, '<hr />', 10);
113  end;
114 
115  if o.flag_biocomp_per_ssp
116  s = cat(2, s, '<h1>Comparison of subsetsprocessors</h1>', 10);
117 
118  stabs = unique(item.items(1).stabs);
119  stabs(stabs < 0) = [];
120  for i = 1:numel(stabs)
121  s = cat(2, s, sprintf('<h2>Comparison of subsetsprocessors - stab%02d</h2>\n', stabs(i)));
122  s = cat(2, s, o.get_html_biocomp_ssps(item, item.items(1).find_stab(stabs(i))));
123  end;
124 
125  s = cat(2, s, sprintf('<h2>Comparison of subsetsprocessors - stab-all</h2>\n'));
126  s = cat(2, s, o.get_html_biocomp_ssps(item, find(item.items(1).stabs >= 0))); %#ok<FNDSB>
127  s = cat(2, s, '<hr />', 10);
128  end;
129 
130 
131 
132  % Average stability curves
133  if o.flag_draw_stability
134  idxs = find(item.items(1).stabs >= 0);
135  n = numel(idxs);
136  ni = numel(item.items);
137  k = 0;
138  for i = 1:n
139  for j = 1:ni
140  k = k+1;
141  log_rep = item.items(j).logs(idxs(i));
142  ds_stab(i) = log_rep.extract_dataset_stabilities(); %#ok<AGROW>
143  ds_stab(i).classlabels = {sprintf('stab%02d', item.items(j).stabs(idxs(i)))}; %#ok<AGROW>
144  end;
145  end;
146  ds = o.merge_ds_stab(ds_stab);
147  ov = vis_hachures();
148  figure;
149  ov.use(ds);
150  maximize_window([], 1.8);
151  s = cat(2, s, o.save_n_close([], 0), '<hr />', 10);
152  end;
153 
154 
155 
156  if o.flag_nf4grades
157  %-----> nf for grades table
158  s = cat(2, s, o.get_html_nf4grades(item, 1:numel(item.items(1).logs)));
159  s = cat(2, s, '<hr />', 10);
160  end;
161 
162  % Reports the objects used
163  s = cat(2, s, '<h2>Setup of some objects used</h2>');
164  a = {def_subsetsprocessor(o.subsetsprocessor), def_peakdetector(o.peakdetector), def_biocomparer(o.biocomparer)};
165  for i = 1:numel(a)
166  obj = a{i};
167  s = cat(2, s, '<p><b>', obj.get_description, '</b></p>', 10, '<pre>', obj.get_report(), '</pre>', 10);
168  end;
169 
170  if o.flag_biocomp_per_ssp
171  a = o.get_ssps();
172  for i = 1:numel(a)
173  obj = a{i};
174  s = cat(2, s, '<p><b>', obj.get_description, '</b></p>', 10, '<pre>', obj.get_report(), '</pre>', 10);
175  end;
176  end;
177  s = cat(2, s, '<hr />', 10);
178  end;
179 
180 
181  function s = get_html_biocomp_nf4grades(o, item, idxs)
182  s = '';
183  [temp, M, titles] = item.html_biocomparisontable_nf4grades(idxs, def_subsetsprocessor(o.subsetsprocessor), o.peakdetector, o.biocomparer);
184  s = cat(2, s, temp);
185 
186  % Draws as image as well, easier to perceive
187  figure;
188  means = mean(M, 3);
189  imagesc(means);
190  xtick = 1:size(M, 1);
191  set(gca(), 'xtick', xtick, 'ytick', xtick, 'xticklabel', titles, 'yticklabel', titles);
192  hcb = colorbar();
193  format_frank([], [], hcb);
194  s = cat(2, s, o.save_n_close([], 0));
195  end;
196 
197 
198  function ssps = get_ssps(o)
199  if isempty(o.subsetsprocessors)
200  ssps = report_log_fselrepeater_histcomp.get_defaultsubsetsprocessors();
201  else
202  ssps = o.subsetsprocessors;
203  end;
204  end;
205 
206  function s = get_html_biocomp_ssps(o, item, idxs)
207  s = '';
208  [temp, M, titles] = item.html_biocomparisontable_ssps(idxs, o.get_ssps(), o.peakdetector, o.biocomparer); %#ok<NASGU,ASGLU>
209  s = cat(2, s, temp);
210  end;
211 
212 
213 
214 
215  function [s, M, titles] = get_html_biocomparison(o, item, idxs)
216  ssp = def_subsetsprocessor(o.subsetsprocessor);
217 
218  [s_temp, M, titles] = item.html_biocomparisontable(idxs, ssp, o.peakdetector, o.biocomparer);
219  s = cat(2, s_temp);
220  end;
221 
222 
223 
224 
225 
226  %> nf4grades table
227  function s = get_html_nf4grades(o, item, idxs)
228  ssp = subsetsprocessor(); %#ok<CPROP,PROP>
229  ssp.nf4gradesmode = 'stability';
230  s = '';
231  s = cat(2, s, '<h2>Number of informative features</h2>', 10, item.html_nf4grades(idxs, ssp));
232  end;
233 
234 
235  % creates a log_celldata to represent better what is in the table
236  function s = get_html_stab_x_coherence(o, M, titles)
237  ds = o.get_dataset_stab_x_coherence(M, titles);
238  a = vis_hachures();
239  figure;
240  a.use(ds);
241  maximize_window([], 1.8);
242  s = o.save_n_close([], 0);
243  end;
244 
245 
246  %> Returns a dataset containing (stabilization) x (coherence index) information
247  function ds = get_dataset_stab_x_coherence(o, M, titles)
248  ds = irdata;
249  [nor, dummy, no_datasets, no_stabs] = size(M); %#ok<ASGLU>
250 
251  no = nor*(nor-1)/2*no_datasets;
252  ds.X = zeros(no, no_stabs);
253  ds.classes = zeros(no, 1);
254 
255  k = 1;
256  l = 0;
257  for i = 2:nor % These for's iterate through the upper triangle of M
258  for j = 1:i-1
259  ds.X(k:k+no_datasets-1, :) = M(i, j, :, :);
260  ds.classes(k:k+no_datasets-1, :) = l;
261  ds.classlabels{l+1} = sprintf('%s vs. %s', titles{i}, titles{j});
262  k = k+no_datasets;
263  l = l+1;
264  end;
265  end;
266 
267  ds.title = [o.title, ' - stabilization curves'];
268  ds.xname = 'Stabilization';
269  ds.yname = 'Coherence';
270  ds.xunit = '';
271  ds.yunit = '';
272  ds = ds.assert_fix();
273  end;
274  end;
275 
276  methods(Access=protected)
277  %> Merges datasets but first makes sure they all have same number of features
278  function ds = merge_ds_stab(o, daa) %#ok<MANU>
279  nf = max([daa.nf]);
280  for i = 1:numel(daa)
281  if daa(i).nf < nf
282  temp = daa(i).X;
283  [ro, co] = size(temp);
284  daa(i).X = NaN(ro, nf);
285  daa(i).X(1:ro, 1:co) = temp;
286  daa(i).fea_x = 1:nf;
287  daa(i) = daa(i).assert_fix(); % just in case
288  end;
289  end;
290  ds = data_merge_rows(daa);
291  end;
292  end;
293 end
Peak Detector.
Definition: peakdetector.m:6
Pre-processing block base class.
Definition: pre.m:2
Generated by irreport, carries HTML contents.
Definition: log_html.m:2
function def_subsetsprocessor(in out)
static function get_defaultsubsetsprocessors()
Processor of a set of subsets of features.
Base for all reports that operate on a soitem object.
Definition: report_soitem.m:2
function data_merge_rows(in datasets)