IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
interactive_wden.m
Go to the documentation of this file.
1 %>@brief Helps find thresholds for wavelet de-noising
2 %>@ingroup interactive
3 %>@file
4 %>
5 %> <h3>References</h3>
6 %> [1] M. Misiti, Y. Misiti, G. Oppenheim, and J.-M. Poggi, Wavelet Toolbox User’s Guide R2012b. Mathworks, 2012.
7 
8 disp('*** Helps find thresholds for wavelet de-noising ***');
9 varname = input('Enter dataset variable name [Demo Raman dataset]: ', 's');
10 
11 if isempty(varname)
12  dataset = load_data_raman_sample();
13 else
14  dataset = eval([varname ';']);
15 end;
16 no = size(dataset.X, 1);
17 
18 
19 
20 idx = input(sprintf('Enter index of spectrum to use (between 1 and %d) [1]: ', no));
21 
22 if isempty(idx) || idx <= 0
23  idx = 1;
24 end;
25 
26 dataset = dataset.map_rows(idx);
27 
28 
29 thresholds = [0, 0, 0, 1000, 1000, 1000];
30 no_levels = 6;
31 
32 k = 1;
33 while 1
34  no_levels_ = input(sprintf('Enter no_levels [%g]: ', no_levels));
35  if ~isempty(no_levels_)
36  no_levels = no_levels_;
37  end;
38 
39  thresholds_ = input(sprintf('Enter thresholds [%s]: ', mat2str(thresholds)));
40  if ~isempty(thresholds_)
41  thresholds = thresholds_;
42  end;
43 
44 
45  dataset2 = dataset;
46  dataset2.X = wden(dataset.X, no_levels, thresholds, 'haar');
47 
48  figure;
49  k = k+1;
50  hold off;
51  plot(dataset.fea_x, dataset.X, 'r', 'LineWidth', 2);
52  hold on;
53  plot(dataset.fea_x, dataset2.X, 'b', 'LineWidth', 2);
54  plot(dataset.fea_x, dataset.X-dataset2.X, 'k', 'LineWidth', 2);
55  legend({'Before', 'After', 'Difference'});
56  format_xaxis(dataset);
57  format_frank();
58 
59 % s_happy = input(sprintf('Are you happy with thresholds = %d and no_levels = %g [y/N]? ', thresholds, no_levels), 's');
60  s_happy = input(sprintf('Are you happy [y/N]? '), 's');
61  if ~isempty(intersect({s_happy}, {'y', 'Y'}))
62  break;
63  end;
64 end;
65 
66 
function wden(in X, in no_levels, in thresholds, in waveletname)
function format_frank(in F, in scale, in handles)
function format_xaxis(in par)
function load_data_raman_sample()