-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
645fb85
commit e51ffac
Showing
32 changed files
with
424 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
% Electroencephalogram (EEG) Feature Extraction toolbox | ||
|
||
%---Input------------------------------------------------------------- | ||
% X : EEG signal (1 x samples) | ||
% opts : parameter settings | ||
% | ||
|
||
%---Output------------------------------------------------------------ | ||
% feat: Feature vector | ||
%--------------------------------------------------------------------- | ||
|
||
|
||
%% Generate a sample random signal X | ||
fs = 500; % Sampling frequency | ||
Ts = 1 / fs; % Period | ||
t = 0 : Ts : 0.5; | ||
X = 0.01 * (sin(2 * pi * fs * t) + randn(1, length(t))); | ||
|
||
% Plot sample signal | ||
plot(t,X); grid on | ||
xlabel('Number of samples'); | ||
ylabel('Amplitude'); | ||
|
||
|
||
%% Example 1 : Extract 3 normal features ( without parameter ) | ||
% Generate a sample random signal X | ||
fs = 500; % Sampling frequency | ||
Ts = 1 / fs; % Period | ||
t = 0 : Ts : 0.5; | ||
X = 0.01 * (sin(2 * pi * fs * t) + randn(1, length(t))); | ||
|
||
% Hjorth Activity | ||
f1 = jfeeg('ha', X); | ||
% Hjorth Mobility | ||
f2 = jfeeg('hm', X); | ||
% Hjorth Complexity | ||
f3 = jfeeg('hc', X); | ||
|
||
% Feature vector | ||
feat = [f1, f2, f3]; | ||
|
||
|
||
%% Example 2 : Extract 2 features with parameter | ||
% Generate a sample random signal X | ||
fs = 500; % Sampling frequency | ||
Ts = 1 / fs; % Period | ||
t = 0 : Ts : 0.5; | ||
X = 0.01 * (sin(2 * pi * fs * t) + randn(1, length(t))); | ||
|
||
% Band Power Alpha | ||
opts.fs = 500; | ||
f1 = jfeeg('bpa', X, opts); | ||
% Tsallis Entropy | ||
opts.alpha = 2; | ||
f2 = jfeeg('te', X, opts); | ||
|
||
% Feature vector | ||
feat = [f1, f2]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%[2014]-"A Comparative Study on Classification of Sleep Stage Based on | ||
%EEG Signals Using Feature Selection and Classification Algorithms" (4) | ||
|
||
function AM = jArithmeticMean(X,~) | ||
AM = mean(X); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
%[2012]-"Classification of EMG signals using combined features and | ||
%soft computing techniques" (1-2) | ||
|
||
function AR = jAutoRegressiveModel(X,opts) | ||
% Parameter | ||
order = 4; % order | ||
|
||
if isfield(opts,'order'), order = opts.order; end | ||
|
||
Y = arburg(X,order); | ||
% First index is meaningless | ||
AR = Y(2 : order + 1); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
function BPA = jBandPowerAlpha(X,opts) | ||
% Parameters | ||
f_low = 8; % 8 Hz | ||
f_high = 12; % 12 Hz | ||
|
||
% sampling frequency | ||
if isfield(opts,'fs'), fs = opts.fs; end | ||
|
||
% Band power | ||
BPA = bandpower(X, fs, [f_low f_high]); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
function BPB = jBandPowerBeta(X,opts) | ||
% Parameters | ||
f_low = 12; % 12 Hz | ||
f_high = 30; % 30 Hz | ||
|
||
% sampling frequency | ||
if isfield(opts,'fs'), fs = opts.fs; end | ||
|
||
% Band power | ||
BPB = bandpower(X, fs, [f_low f_high]); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
function BPD = jBandPowerDelta(X,opts) | ||
% Parameters | ||
f_low = 1; % 1 Hz | ||
f_high = 4; % 4 Hz | ||
|
||
% sampling frequency | ||
if isfield(opts,'fs'), fs = opts.fs; end | ||
|
||
% Band power | ||
BPD = bandpower(X, fs, [f_low f_high]); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
function BPG = jBandPowerGamma(X,opts) | ||
% Parameters | ||
f_low = 30; % 30 Hz | ||
f_high = 64; % 64 Hz | ||
|
||
% sampling frequency | ||
if isfield(opts,'fs'), fs = opts.fs; end | ||
|
||
% Band power | ||
BPG = bandpower(X, fs, [f_low f_high]); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
function BPT = jBandPowerTheta(X,opts) | ||
% Parameters | ||
f_low = 4; % 4 Hz | ||
f_high = 8; % 8 Hz | ||
|
||
% sampling frequency | ||
if isfield(opts,'fs'), fs = opts.fs; end | ||
|
||
% Band power | ||
BPT = bandpower(X, fs, [f_low f_high]); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
%[2014]-"Feature Extraction and Selection for Emotion Recognition from | ||
%EEG" | ||
|
||
function FD = jFirstDifference(X,~) | ||
T = length(X); | ||
Y = 0; | ||
for t = 1 : T - 1 | ||
Y = Y + abs(X(t+1) - X(t)); | ||
end | ||
FD = (1 / (T - 1)) * Y; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%[2018]-"A Novel Multi-Class EEG-Based Sleep Stage Classification System" | ||
%(3) | ||
|
||
function HA = jHjorthActivity(X,~) | ||
sd = std(X); | ||
HA = sd ^ 2; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
%[2018]-"A Novel Multi-Class EEG-Based Sleep Stage Classification System" | ||
%(5) | ||
|
||
function HC = jHjorthComplexity(X,~) | ||
% First & second derivative | ||
x0 = X(:); | ||
x1 = diff([0; x0]); | ||
x2 = diff([0; x1]); | ||
% Standard deviation of first & second derivative | ||
sd0 = std(x0); | ||
sd1 = std(x1); | ||
sd2 = std(x2); | ||
% Complexity | ||
HC = (sd2 / sd1) / (sd1 / sd0); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
%[2018]-"A Novel Multi-Class EEG-Based Sleep Stage Classification System" | ||
%(4) | ||
|
||
function HM = jHjorthMobility(X,~) | ||
% First derivative | ||
x0 = X(:); | ||
x1 = diff([0; x0]); | ||
% Standard deviation | ||
sd0 = std(x0); | ||
sd1 = std(x1); | ||
HM = sd1 / sd0; | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
function KURT = jKurtosis(X,~) | ||
% Kurtosis | ||
KURT = kurtosis(X); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
%[2017]-"Automated detection of focal EEG signals using features | ||
%extracted from flexible analytic wavelet transform" (8) | ||
|
||
function LogEn = jLogEnergyEntropy(X,~) | ||
% Entropy | ||
LogEn = sum(log(X .^ 2)); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
%[2018]-"A Novel Multi-Class EEG-Based Sleep Stage Classification | ||
%System" (11) | ||
|
||
function LRSSV = jLogRootSumOfSequentialVariation(X,~) | ||
N = length(X); | ||
Y = zeros(1, N-1); | ||
for i = 2:N | ||
Y(i-1) = (X(i) - X(i-1)) ^ 2; | ||
end | ||
LRSSV = log10(sqrt(sum(Y))); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%[2014]-"A Comparative Study on Classification of Sleep Stage Based on EEG | ||
%Signals Using Feature Selection and Classification Algorithms" (2) | ||
|
||
function X_max = jMaximum(X,~) | ||
X_max = max(X); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
%[2014]-"A Comparative Study on Classification of Sleep Stage Based on | ||
%EEG Signals Using Feature Selection and Classification Algorithms" (13) | ||
|
||
function MCL = jMeanCurveLength(X,~) | ||
N = length(X); | ||
Y = 0; | ||
for m = 2:N | ||
Y = Y + abs(X(m) - X(m-1)); | ||
end | ||
MCL = (1 / N) * Y; | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
%[2014]-"A Comparative Study on Classification of Sleep Stage Based on | ||
%EEG Signals Using Feature Selection and Classification Algorithms" (12) | ||
|
||
function ME = jMeanEnergy(X,~) | ||
ME = mean(X .^ 2); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
%[2014]-"A Comparative Study on Classification of Sleep Stage Based on | ||
%EEG Signals Using Feature Selection and Classification Algorithms" (11) | ||
|
||
function MTE = jMeanTeagerEnergy(X,~) | ||
N = length(X); | ||
Y = 0; | ||
for m = 3:N | ||
Y = Y + ((X(m-1) ^ 2) - X(m) * X(m-2)); | ||
end | ||
MTE = (1 / N) * Y; | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%[2014]-"A Comparative Study on Classification of Sleep Stage Based on | ||
%EEG Signals Using Feature Selection and Classification Algorithms" (8-9) | ||
|
||
function X_med = jMedian(X,~) | ||
X_med = median(X); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%[2014]-"A Comparative Study on Classification of Sleep Stage Based on EEG | ||
%Signals Using Feature Selection and Classification Algorithms" (1) | ||
|
||
function X_min = jMinimum(X,~) | ||
X_min = min(X); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
%[2014]-"Feature Extraction and Selection for Emotion Recognition from | ||
%EEG" | ||
|
||
function NFD=jNormalizedFirstDifference(X,~) | ||
T = length(X); | ||
Y = 0; | ||
for t = 1 : T - 1 | ||
Y = Y + abs(X(t+1) - X(t)); | ||
end | ||
FD = (1 / (T - 1)) * Y; | ||
NFD = FD / std(X); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
%[2014]-"Feature Extraction and Selection for Emotion Recognition from | ||
%EEG" | ||
|
||
function NSD = jNormalizedSecondDifference(X,~) | ||
T = length(X); | ||
Y = 0; | ||
for t = 1 : T - 2 | ||
Y = Y + abs(X(t+2) - X(t)); | ||
end | ||
SD = (1 / (T - 2)) * Y; | ||
NSD = SD / std(X); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
function RBA = jRatioBandPowerAlphaBeta(X,opts) | ||
% Parameters | ||
f_low1 = 8; % 8 Hz | ||
f_high1 = 12; % 12 Hz | ||
|
||
f_low2 = 12; % 12 Hz | ||
f_high2 = 30; % 30 Hz | ||
|
||
% sampling frequency | ||
if isfield(opts,'fs'), fs = opts.fs; end | ||
|
||
% Band power alpha | ||
BPA = bandpower(X, fs, [f_low1 f_high1]); | ||
% Band power beta | ||
BPB = bandpower(X, fs, [f_low2 f_high2]); | ||
% Ratio beta/alpha | ||
RBA = BPB / BPA; | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
%[2018]-"Improved binary dragonfly optimization algorithm and wavelet | ||
%packet based non-linear features for infant cry classification" (4) | ||
|
||
function ReEn = jRenyiEntropy(X,opts) | ||
% Parameter | ||
alpha = 2; % alpha | ||
|
||
if isfield(opts,'alpha'), alpha = opts.alpha; end | ||
|
||
% Convert probability using energy | ||
P = (X .^ 2) ./ sum(X .^ 2); | ||
% Entropy | ||
En = P .^ alpha; | ||
ReEn = (1 / (1 - alpha)) * log2(sum(En)); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
%[2014]-"Feature Extraction and Selection for Emotion Recognition from | ||
%EEG" | ||
|
||
function SD = jSecondDifference(X,~) | ||
T = length(X); | ||
Y = 0; | ||
for t = 1 : T - 2 | ||
Y = Y + abs(X(t+2) - X(t)); | ||
end | ||
SD = (1 / (T - 2)) * Y; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
%[2018]-"Improved binary dragonfly optimization algorithm and wavelet | ||
%packet based non-linear features for infant cry classification" (3) | ||
|
||
function ShEn = jShannonEntropy(X,~) | ||
% Convert probability using energy | ||
P = (X .^ 2) ./ sum(X .^ 2); | ||
% Entropy | ||
En = P .* log2(P); | ||
ShEn = -sum(En); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
function SKEW = jSkewness(X,~) | ||
SKEW = skewness(X); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
function SD = jStandardDeviation(X,~) | ||
N = length(X); | ||
mu = mean(X); | ||
SD = sqrt((1 / (N - 1)) * sum((X - mu) .^ 2)); | ||
end | ||
|
Oops, something went wrong.