IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
pre_sigwindow.m
Go to the documentation of this file.
1 %> @brief Applies sigmoid window to curves
2 %>
3 %> Kills smoothly values above and below range.
4 %>
5 %> the x* values are relative to data vars x. They are converted to indexes.
6 %>
7 %> Applies a window for the coefficients to have smooth transition
8 %> between their current values and zero.
9 %> I chose the sigmoid function 1/(1+e^(k*x)) because it is easy to use.
10 %>
11 %> @sa sigwindow.m, uip_pre_sigwindow.m
12 classdef pre_sigwindow < pre
13  properties
14  %> beginning and terminus of window, given in data.fea_x units
15  range;
16  %> length for sigmoid to go from 0.5 to .995 or .005 given in data.fea_x units
17  width;
18  end;
19 
20  methods
21  function o = pre_sigwindow(o)
22  o.classtitle = 'Sigmoid Window';
23  o.flag_ui = 0;
24  end;
25  end;
26 
27  methods(Access=protected)
28 
29 
30  %> Applies block to dataset
31  function data = do_use(o, data)
32 
33  if isempty(o.range)
34  range_ = data.fea_x([1, end]);
35  else
36  range_ = o.range;
37  end;
38 
39 
40 
41  x_per_fea = abs((data.fea_x(end)-data.fea_x(1))/(data.nf-1)); % features may not be equally spaced along the x axis, this is a good average though
42  idxs_range = v_x2ind(range_, data.fea_x); % features not to be zeroed
43  scale = o.width/x_per_fea;
44 
45 
46  X = data.X;
47  X = sigwindowuni(X, idxs_range(1), scale);
48  X = sigwindowuni(X, idxs_range(2), -scale);
49  data.X = X;
50  end;
51  end;
52 end
function v_x2ind(in v, in x)
Pre-processing block base class.
Definition: pre.m:2
Base Block class.
Definition: block.m:2
function sigwindowuni(in X, in idxcentre, in scale)
Applies sigmoid window to curves.
Definition: pre_sigwindow.m:12