Switch to unified view

a b/featurebased-approach/subfunctions/lib/Teager-Kaiser/TKEO.m
1
function [TKenergy]=TKEO(x)
2
%
3
%% Utility function to calculate measures based on the nonlinear energy operator
4
%
5
% Function to estimate the TKEO of input data, follows the classical rule
6
% of Teager and Kaiser
7
%
8
% Inputs:  x            -> any time-series signal (vector)
9
%
10
% =========================================================================
11
% Output:  TKenergy     -> (nonlinear) Teager-Kaiser Energy Operator (TKEO)
12
% =========================================================================
13
%
14
% Part of the "Speech Disorders" Toolbox
15
%
16
% -----------------------------------------------------------------------
17
% Useful references:
18
% 
19
% 1) J. Kaiser: On a simple algorithm to calculate the 'energy' of a
20
%    signal, Proc. IEEE International Conference on Acoustics, Speech, and 
21
%    Signal Processing (ICASSP '90), pp. 381-384, Albuquerque, NM, USA, 
22
%    April 1990
23
%
24
% -----------------------------------------------------------------------
25
%
26
% Last modified on 24 August 2014
27
%
28
% Copyright (c) Athanasios Tsanas, 2014
29
%
30
% ********************************************************************
31
% If you use this program please cite:
32
%
33
% 1) A. Tsanas: "Accurate telemonitoring of Parkinson's disease symptom
34
%    severity using nonlinear speech signal processing and statistical
35
%    machine learning", D.Phil. thesis, University of Oxford, 2012
36
% ********************************************************************
37
%
38
% For any question, to report bugs, or just to say this was useful, email
39
% tsanasthanasis@gmail.com
40
41
%% Algorithm computation
42
43
% The algorithm is computed using the instantaneous value squared minus the
44
% previous step value times the next step value:[x_n]^2-[x_(n-1)]*(x_(n+1)]
45
%
46
%
47
% This program is free software; you can redistribute it and/or modify it
48
% under the terms of the GNU General Public License as published by the
49
% Free Software Foundation; either version 2 of the License, or (at your
50
% option) any later version.
51
% This program is distributed in the hope that it will be useful, but
52
% WITHOUT ANY WARRANTY; without even the implied warranty of
53
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
54
% Public License for more details.
55
56
% This program is free software; you can redistribute it and/or modify it
57
% under the terms of the GNU General Public License as published by the
58
% Free Software Foundation; either version 2 of the License, or (at your
59
% option) any later version.
60
% This program is distributed in the hope that it will be useful, but
61
% WITHOUT ANY WARRANTY; without even the implied warranty of
62
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
63
% Public License for more details.
64
%
65
66
data_length=length(x);
67
TKenergy=zeros(data_length,1);
68
69
TKenergy(1)=(x(1))^2; % first sample
70
71
for n=2:data_length-1
72
    TKenergy(n)=(x(n))^2-x(n-1)*x(n+1);
73
end
74
75
%  TKenergy(2:data_length-1) = x(2:data_length-1).^2 - x(1:data_length-2).*x(3:data_length); % alternative, vectorized version
76
77
TKenergy(data_length)=(x(data_length))^2; % last sample