IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
peak_landmarks.m
Go to the documentation of this file.
1 %>@ingroup maths
2 %>@file
3 %>@brief Converts curves to their peaks/troughs locations
4 %>
5 %> @param X data matrix with curves as rows
6 %> @param map <code>[idxmin, idxmax, flag_min; ...]</code>
7 %> @param t_range for the final conversion of output values to the proper scale.
8 %> @return T
9 function T = peak_landmarks(X, map, t_range)
10 
11 [no, no_t] = size(X);
12 
13 if ~exist('t_range', 'var')
14  t_range = [1, no_t];
15 end;
16 
17 
18 no_peaks = size(map, 1);
19 T = zeros(no, no_peaks);
20 for i = 1:no
21  v = X(i, :);
22 
23  for j = 1:no_peaks
24  idxs = map(j, 1):map(j, 2);
25  flag_min = map(j, 3);
26 
27  if flag_min
28  [val, idx_peak] = min(v(idxs));
29  else
30  [val, idx_peak] = max(v(idxs));
31  end;
32  idx_peak = idx_peak+idxs(1)-1;
33 
34  T(i, j) = idx_peak;
35  end;
36 end;
37 
38 tf = t_range(2);
39 ti = t_range(1);
40 
41 T = (T-1)*(tf-ti)/(no_t-1)+ti; % Normalizes warping information to the original number of features
function peak_landmarks(in X, in map, in t_range)
Analysis Session (AS) base class.
Definition: as.m:6