IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
vis_image_cat.m
Go to the documentation of this file.
1 %> @brief Image map for non-ordered, discrete features (e.g. from clustering)
2 %>
3 %> @sa uip_vis_image_cat.m
4 classdef vis_image_cat < vis
5  properties
6  %> =0. 0: feature; 1: class
7  mode = 0;
8  %> =1. Index of feature in case @c mode is 0.
9  idx_fea = 1;
10  %> Whether to stretch the image to occupy the whole figure area
11  flag_set_position = 1;
12  % Minimum number of points per category
13  min_ppc;
14  % Maximum num,ber of categories
15  max_c;
16  end;
17 
18  methods
19  function o = vis_image_cat(o)
20  o.classtitle = 'Image map - Cluster data';
21  o.inputclass = 'irdata_clus';
22  end;
23  end;
24 
25  methods(Access=protected)
26 
27  function Z = get_Z(o, data)
28  if o.mode == 0
29  Z = data.X(:, o.idx_fea)';
30  elseif o.mode == 1
31  error('Not implemented for "class" mode yet, sorry');
32  else
33  irerror(sprintf('Invalid mode: %d', o.mode));
34  end;
35  end;
36 
37 
38  function data = implement_min_ppc(o, data)
39  Z = o.get_Z(data);
40 
41  nums = unique(Z);
42 
43  counts = diff(find([1, diff(sort(Z)), 1])); % Finds how many times each number appears
44 
45  idxs = find(counts < o.min_ppc);
46 
47 % feanew = numel(counts)-numel(idxs)+1;
48  feanew = 2*(numel(counts)-numel(idxs));
49 
50  if ~isempty(idxs)
51 % ZZ = Z+1;
52  ZZ = Z;
53 
54  for i = 1:numel(idxs)
55  ZZ(Z == nums(idxs(i))) = feanew; %1;
56  end;
57  if o.mode == 0
58  data.X(:, o.idx_fea) = ZZ';
59  elseif o.mode == 1
60  % ...
61  end;
62  end;
63 
64  end;
65 
66 
67  function out = do_use(o, obj)
68  out = [];
69  if isempty(obj.height) || obj.height < 1
70  irerror('Dataset has no defined image dimensions!');
71  end;
72 
73  % Makes a dataset sorted by number of occurences in the last column
74  if o.mode == 0
75  Z = obj.X(:, o.idx_fea);
76  classlabels = [];
77  elseif o.mode == 1
78  Z = obj.classes;
79  classlabels = obj.classlabels;
80  else
81  irerror(sprintf('Invalid mode: %d', o.mode));
82  end;
83 
84  Z = renumber_vector_idooo(Z);
85 
86  draw_indexedimage(Z, obj.height, obj.direction, classlabels);
87  set_title(o.classtitle, obj);
88 
89  if o.flag_set_position
90  set(gca, 'Position', [0, 0, 1, 1]);
91  end;
92 
93  end;
94  end;
95 end
Dataset class - cluster data.
Definition: irdata_clus.m:6
function irerror(in s)
Visualization base class.
Definition: vis.m:4
function renumber_vector_idooo(in y)
function set_title(in s, in obj)
function draw_indexedimage(in Y, in height, in direction, in classlabels)
Image map for non-ordered, discrete features (e.g. from clustering)
Definition: vis_image_cat.m:4