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 band energy (trial/baseline)
for the @b EEG signal.
19 %> @param EEGSignal: the @b EEG signal
21 %> @retval thetaBand: 1xN vector; N number of electrodes
22 %> @retval alphaBand: 1xN vector; N number of electrodes
23 %> @retval betaBand: 1xN vector; N number of electrodes
24 %> @retval slowAlpha: 1xN vector; N number of electrodes
25 %> @retval gammaBand: 1xN vector; N number of electrodes
27 %> @author Copyright Mohammad Soleymani 2009
28 %> @author Copyright Frank Villaro-Dixon, 2014
29 function [deltaBand, thetaBand, slowAlphaBand, alphaBand, betaBand, gammaBand] =
EEG_feat_bandENR(EEGSignal)
35 %
default is 15 seconds
long
36 welch_window_size = fs*15;
37 %get the signal length
40 n_electrodes = length(electrode_labels.EEG);
41 deltaBand = nan(1, n_electrodes);
42 thetaBand = nan(1, n_electrodes);
43 alphaBand = nan(1, n_electrodes);
44 betaBand = nan(1, n_electrodes);
45 slowAlphaBand = nan(1, n_electrodes);
46 gammaBand = nan(1, n_electrodes);
48 if sing_length< welch_window_size +fs
49 warning(
'singal too short for the welch size')
51 if sing_length< welch_window_size +1
52 warning('singal too
short for the welch size and this method will not work')
54 for iElec = 1:n_electrodes
57 %detrending the EEG signals
59 %Welch method to compute energy of the current electrode (trial + BL)
60 [PowerTrial, fTrial] = pwelch(data, welch_window_size , [], [], fs);
61 deltaBand(iElec) = log(sum(PowerTrial(fTrial>0 & fTrial<4)));
62 thetaBand(iElec) = log(sum(PowerTrial(4<=fTrial & fTrial<8)));
63 slowAlphaBand(iElec) = log(sum(PowerTrial(8<=fTrial & fTrial<10)));
64 alphaBand(iElec) = log(sum(PowerTrial(8<=fTrial & fTrial<12)));
65 betaBand(iElec) = log(sum(PowerTrial(12<=fTrial & fTrial<30)));
66 gammaBand(iElec) = log(sum(PowerTrial(30<fTrial)));