IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
log_hist.m
Go to the documentation of this file.
1 %>@brief Generated by @ref subsetsprocessor, carries a histogram
2 classdef log_hist < log_grades
3  properties
4  %> [number of selected features]x[nf (total number of features dataset)]. Individual hits.
5  hitss;
6  %> Number of selected features used to compose @c grades
7  nf4grades;
8  end;
9 
10  methods
11  function o = log_hist()
12  o.classtitle = 'Histogram';
13  o.yname = 'Hits';
14  o.yunit = '';
15  o.flag_ui = 0;
16  end;
17  end;
18 
19  %======> DRAWING
20  methods
21  %>@brief Draws histograms
22  %>
23  %> Will generate subplots if @c idxs has more than one element
24  %>
25  %> @param idxs=all Indexes of feature orders to plot
26  function o = draw_hists(o, idxs, data_hint, flag_group)
27  if isempty(idxs)
28  idxs = 1:size(o.hitss, 1);
29  end;
30  if any(idxs > size(o.hitss, 1))
31  irverbose('Info: histograms index was trimmed');
32 
33  idxs(idxs > size(o.hitss, 1)) = [];
34  end;
35 
36  if ~exist('flag_group', 'var')
37  flag_group = 0;
38  end;
39 
40  if nargin < 3 || isempty(data_hint)
41  xhint = [];
42  yhint = [];
43  else
44  xhint = data_hint.fea_x;
45  yhint = mean(data_hint.X, 1);
46  end;
47 
48  [nor, nf] = size(o.hitss); %#ok<NASGU>
49  if nargin < 2
50  idxs = 1:nor;
51  end;
52 
53  if ~flag_group
54  ni = numel(idxs);
55  for i = 1:ni
56  idx = idxs(i);
57 
58  if ni > 1
59  subplot(ni, 1, i);
60  end;
61 
62  draw_loadings(o.fea_x, o.hitss(idx, :), xhint, yhint, [], 0, [], 0, 0, 0, 1, [], {find_color_stackedhist(idx)});
63  ylabel(sprintf('%s', int2ord(idx)));
64  if i < ni
65  set(gca, 'xtick', []);
66  end;
67  make_box();
68  end;
69  else
70  v = sum(o.hitss(idxs, :), 1);
71  draw_loadings(o.fea_x, v, xhint, yhint, [], 0, [], 0, 0, 0, 1);
72  make_box();
73  title(sprintf('Histograms taken: %s', mat2str(idxs)));
74  end;
75  end;
76 
77 
78  %>@brief Draws histograms Using stacked bars
79  %>
80  %> Note that this will work for Forward Feature Selection only
81  %>
82  %> @param data_hint Hint dataset
83  %> @param no_inside Number of histograms that are considered "informative"
84  %> @param colors =(default colors). Either a cell of 2 elements or 4 elements. If it is a cell of two elements,
85  %> the non-informative and informative histograms will have gradients
86  %> @param peakdetector Use it to mark peaks in the histogram
87  %> @param flag_trace_minalt =~isempty(peakd) Whether to draw the threshold line. Only works if the peak detector is passed.
88 
89  function draw_stackedhists(o, data_hint, colors, peakdetector, flag_trace_minalt)
90  if nargin < 2 || isempty(data_hint)
91  xhint = [];
92  yhint = [];
93  else
94  xhint = data_hint.fea_x;
95  yhint = mean(data_hint.X, 1);
96  end;
97 
98  if nargin < 3
99  colors = [];
100  end;
101 
102  if nargin < 4
103  peakdetector = [];
104  end;
105  if ~exist('flag_trace_minalt', 'var') || isempty(flag_trace_minalt)
106  flag_trace_minalt = ~isempty(peakdetector);
107  end;
108 
109  draw_stacked(o.fea_x, o.hitss, o.nf4grades, colors, xhint, yhint, peakdetector, flag_trace_minalt, 1, 1, 1);
110  format_xaxis(o);
111  format_yaxis(o);
112  make_box();
113  end;
114 
115  %> Draws each per-feature-position histogram as a line
116  function draw_as_lines(o)
117  for i = 1:size(o.hitss, 1);
118  plot(o.fea_x, o.hitss(i, :), 'LineWidth', scaled(2), 'Color', find_color_stackedhist(i));
119  hold on;
120  end;
121  set(gca, 'Ylim', [0, max(o.hitss(:))*1.025]);
122  format_xaxis(o);
123  format_yaxis(o);
124  format_frank();
125  make_box();
126  end;
127  end;
128 end
function irverbose(in s, in level)
Generated by subsetsprocessor, carries a histogram.
Definition: log_hist.m:2
function make_box()
Generated by a as_grades object, carries a "grades" vector; usually.
Definition: log_grades.m:2
Peak Detector.
Definition: peakdetector.m:6
function scaled(in i)
function draw_loadings(in x, in L, in x_hint, in hint, in legends, in flag_abs, in peakd, in flag_trace_minalt, in flag_draw_peaks, in flag_print_peaks, in flag_histogram, in flag_envelope, in colors)
function int2ord(in idx)
function format_yaxis(in par)
Processor of a set of subsets of features.
function format_frank(in F, in scale, in handles)
Analysis Session (AS) base class.
Definition: as.m:6
function find_color_stackedhist(in i)
function draw_stacked(in x, in histss, in no_informative, in colors, in x_hint, in hint, in peakd, in flag_trace_minalt, in flag_draw_peaks, in flag_print_peaks, in flag_text)
function format_xaxis(in par)