Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LNDG
mMSE
Commits
b6f9a130
Commit
b6f9a130
authored
Jan 09, 2020
by
Julian Kosciessa
Browse files
implement Chebychev filter definition for bandpass version
parent
e241ced1
Changes
2
Show whitespace changes
Inline
Side-by-side
ft_entropyanalysis.m
View file @
b6f9a130
...
...
@@ -200,12 +200,21 @@ for s = 1:numel(timescales) % loop through timescales
case
'bp'
fs
=
data
.
fsample
;
nyquist
=
fs
/
2
;
fcLowPass
=
(
1.
/
sc
)
.*
nyquist
+
((
1.
/
sc
)
.*
nyquist
)
.
/
4
;
fcHighPass
=
(
1.
/
sc
)
.*
nyquist
-
((
1.
/
sc
)
.*
nyquist
)
.
/
4
;
fcLowPass
=
(
1.
/
sc
)
.*
nyquist
+
.
05
*
((
1.
/
sc
)
.*
nyquist
);
fcHighPass
=
(
1.
/(
sc
+
1
))
.*
nyquist
-
.
05
*
((
1.
/(
sc
+
1
))
.*
nyquist
);
if
sc
>
1
% don't define low-pass for first scale, as its upper frequency limit is specified anyway
[
B
,
A
]
=
butter
(
6
,
fcLowPass
/
nyquist
,
'low'
);
% define low-pass filter: https://de.mathworks.com/help/signal/ref/butter.html
if
fcLowPass
-
fcHighPass
>
.
05
*
nyquist
[
B
,
A
]
=
cheby1
(
4
,
1
,
fcLowPass
/
nyquist
,
'low'
);
% define low-pass filter: https://de.mathworks.com/help/signal/ref/butter.html
[
D
,
C
]
=
cheby1
(
4
,
1
,
fcHighPass
/
nyquist
,
'high'
);
% define high-pass filter
else
[
B
,
A
]
=
butter
(
10
,
fcLowPass
/
nyquist
,
'low'
);
% Lowpass
[
D
,
C
]
=
butter
(
10
,
fcHighPass
/
nyquist
,
'high'
);
% Highpass
end
else
[
D
,
C
]
=
butter
(
10
,
fcHighPass
/
nyquist
,
'high'
);
% use Butterworth highpass
fcLowPass
=
nyquist
;
end
[
D
,
C
]
=
butter
(
6
,
fcHighPass
/
nyquist
,
'high'
);
% define high-pass filter
cfg
.
freq
(
1
,
s
)
=
fcLowPass
;
cfg
.
freq
(
2
,
s
)
=
fcHighPass
;
...
...
@@ -314,7 +323,7 @@ for s = 1:numel(timescales) % loop through timescales
cg_data
=
{};
switch
coarsegrainmethod
case
'filtskip'
if
strcmp
(
filtmethod
,
'hp'
)
||
strcmp
(
filtmethod
,
'bp'
)
if
strcmp
(
filtmethod
,
'hp'
)
nloops
=
1
;
% keep original sampling rate
stepSize
=
1
;
else
...
...
ft_permentropyanalysis.m
View file @
b6f9a130
...
...
@@ -165,12 +165,21 @@ for s = 1:numel(timescales) % loop through timescales
case
'bp'
fs
=
data
.
fsample
;
nyquist
=
fs
/
2
;
fcLowPass
=
(
1.
/
sc
)
.*
nyquist
+
((
1.
/
sc
)
.*
nyquist
)
.
/
4
;
fcHighPass
=
(
1.
/
sc
)
.*
nyquist
-
((
1.
/
sc
)
.*
nyquist
)
.
/
4
;
fcLowPass
=
(
1.
/
sc
)
.*
nyquist
+
.
05
*
((
1.
/
sc
)
.*
nyquist
);
fcHighPass
=
(
1.
/(
sc
+
1
))
.*
nyquist
-
.
05
*
((
1.
/(
sc
+
1
))
.*
nyquist
);
if
sc
>
1
% don't define low-pass for first scale, as its upper frequency limit is specified anyway
[
B
,
A
]
=
butter
(
6
,
fcLowPass
/
nyquist
,
'low'
);
% define low-pass filter: https://de.mathworks.com/help/signal/ref/butter.html
if
fcLowPass
-
fcHighPass
>
.
05
*
nyquist
[
B
,
A
]
=
cheby1
(
4
,
1
,
fcLowPass
/
nyquist
,
'low'
);
% define low-pass filter: https://de.mathworks.com/help/signal/ref/butter.html
[
D
,
C
]
=
cheby1
(
4
,
1
,
fcHighPass
/
nyquist
,
'high'
);
% define high-pass filter
else
[
B
,
A
]
=
butter
(
10
,
fcLowPass
/
nyquist
,
'low'
);
% Lowpass
[
D
,
C
]
=
butter
(
10
,
fcHighPass
/
nyquist
,
'high'
);
% Highpass
end
else
[
D
,
C
]
=
butter
(
10
,
fcHighPass
/
nyquist
,
'high'
);
% use Butterworth highpass
fcLowPass
=
nyquist
;
end
[
D
,
C
]
=
butter
(
6
,
fcHighPass
/
nyquist
,
'high'
);
% define high-pass filter
cfg
.
freq
(
1
,
s
)
=
fcLowPass
;
cfg
.
freq
(
2
,
s
)
=
fcHighPass
;
...
...
@@ -239,7 +248,7 @@ for s = 1:numel(timescales) % loop through timescales
cg_data
=
{};
switch
coarsegrainmethod
case
'filtskip'
if
strcmp
(
filtmethod
,
'hp'
)
||
strcmp
(
filtmethod
,
'bp'
)
if
strcmp
(
filtmethod
,
'hp'
)
nloops
=
1
;
% keep original sampling rate for hp option
stepSize
=
1
;
else
...
...
@@ -253,7 +262,7 @@ for s = 1:numel(timescales) % loop through timescales
end
clear
resamp_x
;
case
'pointavg'
% original point averaging coarse graining, no loop over starting points
if
sc
==
1
||
strcmp
(
filtmethod
,
'hp'
)
% no coarse graining for native sampling rate
or high-pass entropy
if
sc
==
1
% no coarse graining for native sampling rate
cg_data
{
1
}
=
data_sel
.
trial
;
%only keep trial data
nloops
=
1
;
% no loop across starting points
else
% coarse-grain time series at this time scale
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment