1 %This file is part of TEAP.
3 %TEAP is free software: you can redistribute it and/or modify
4 %it under the terms of the GNU General Public License as published by
5 %the Free Software Foundation, either version 3 of the License, or
6 %(at your option) any later version.
8 %TEAP is distributed in the hope that it will be useful,
9 %but WITHOUT ANY WARRANTY; without even the implied warranty of
10 %MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 %GNU General Public License
for more details.
13 %You should have received a copy of the GNU General Public License
14 %along with TEAP. If not, see <http://www.gnu.org/licenses/>.
17 %> @brief Computes the standard deviation of a given signal
18 %> @author Copyright Mohammad Soleymani, 2015
21 %> @param bands a 2 x n dimenional array including the bands lower and upper
23 %> @retval band energy:it calculates energy in different bands
33 %signals should be in columns
for pwelch to work
for a multi-channel
case
34 %like when we have more than one EMG signal
35 if size(raw,1)<size(raw,2)
38 welch_window_size = fs* 10;
40 % to check the first band limit after 0
41 bands_flat = bands(:);
43 min_f = bands_flat(find(bands_flat>0,1,'first'));
45 min_f = min(bands_flat);
48 if 1/min_f> welch_window_size/fs
49 warning('This welch window size is too small for your bands and the results are incorrect- consider increasing it');
52 powerBands = nan(min(size(raw)),size(bands,1));
54 if size(raw,1)< welch_window_size +fs
55 warning('singal too
short for the welch size');
57 if size(raw,1)< welch_window_size +1
58 warning('singal too
short for the welch size and this method will not work')
62 [P(:,i),f] = pwelch(raw(:,i),welch_window_size,[],[],fs);
65 %features for every band
67 for i = 1:size(bands,1)
68 powerBands(j,i) = log(sum(P(f> bands(i,1)& f<=bands(i,2),j))+eps);