Skip to content

Commit 9b39897

Browse files
authored
Merge pull request #369 from fooof-tools/skewg
[MNT] - Update skewed_gaussian mode (for consistency)
2 parents 14b9e54 + f8f9e5a commit 9b39897

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

specparam/modes/definitions.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
from specparam.modes.mode import Mode
66
from specparam.modes.params import ParamDefinition
77
from specparam.modes.funcs import (expo_function, expo_nk_function, double_expo_function,
8-
gaussian_function, skewnorm_function, cauchy_function)
8+
gaussian_function, skewed_gaussian_function, cauchy_function)
99
from specparam.modes.jacobians import jacobian_gauss
1010

1111
###################################################################################################
1212
## APERIODIC MODES
1313

14-
# Fixed
14+
## AP - Fixed Mode
15+
1516
params_fixed = ParamDefinition(OrderedDict({
1617
'offset' : 'Offset of the aperiodic component.',
1718
'exponent' : 'Exponent of the aperiodic component.',
@@ -30,7 +31,8 @@
3031
)
3132

3233

33-
# Knee
34+
## AP - Knee Mode
35+
3436
params_knee = ParamDefinition(OrderedDict({
3537
'offset' : 'Offset of the aperiodic component.',
3638
'knee' : 'Knee of the aperiodic component.',
@@ -50,8 +52,9 @@
5052
)
5153

5254

53-
# Double exponent
54-
params_double_exp = ParamDefinition(OrderedDict({
55+
## AP - Double Exponent Mode
56+
57+
params_doublexp = ParamDefinition(OrderedDict({
5558
'offset' : 'Offset of the aperiodic component.',
5659
'exponent0' : 'Exponent of the aperiodic component, before the knee.',
5760
'knee' : 'Knee of the aperiodic component.',
@@ -64,7 +67,7 @@
6467
description='Fit an function with 2 exponents and a knee.',
6568
func=double_expo_function,
6669
jacobian=None,
67-
params=params_double_exp,
70+
params=params_doublexp,
6871
ndim=1,
6972
freq_space='linear',
7073
powers_space='log10',
@@ -81,7 +84,8 @@
8184
###################################################################################################
8285
## PERIODIC MODES
8386

84-
# Gaussian
87+
## PE - Gaussian Mode
88+
8589
params_gauss = ParamDefinition(OrderedDict({
8690
'cf' : 'Center frequency of the peak.',
8791
'pw' : 'Power of the peak, over and above the aperiodic component.',
@@ -101,28 +105,30 @@
101105
)
102106

103107

104-
# Skewed Gaussian
105-
params_skew = ParamDefinition(OrderedDict({
108+
## PE - Skewed Gaussian Mode
109+
110+
params_skewed_gaussian = ParamDefinition(OrderedDict({
106111
'cf' : 'Center frequency of the peak.',
107112
'pw' : 'Power of the peak, over and above the aperiodic component.',
108113
'bw' : 'Bandwidth of the peak.',
109114
'skew' : 'Skewness of the peak.',
110115
}))
111116

112-
pe_skewnorm = Mode(
113-
name='skewnorm',
117+
pe_skewed_gaussian = Mode(
118+
name='skewed_gaussian',
114119
component='periodic',
115120
description='Skewed Gaussian peak fit function.',
116-
func=skewnorm_function,
121+
func=skewed_gaussian_function,
117122
jacobian=None,
118-
params=params_skew,
123+
params=params_skewed_gaussian,
119124
ndim=2,
120125
freq_space='linear',
121126
powers_space='log10',
122127
)
123128

124129

125-
# Cauchy
130+
## PE - Cauchy Mode
131+
126132
params_cauchy = ParamDefinition(OrderedDict({
127133
'cf' : 'Center frequency of the peak.',
128134
'pw' : 'Power of the peak, over and above the aperiodic component.',
@@ -145,7 +151,7 @@
145151
# Collect available periodic modes
146152
PE_MODES = {
147153
'gaussian' : pe_gaussian,
148-
'skewed_gaussian' : pe_skewnorm,
154+
'skewed_gaussian' : pe_skewed_gaussian,
149155
'cauchy' : pe_cauchy,
150156
}
151157

specparam/modes/funcs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def gaussian_function(xs, *params):
3535
return ys
3636

3737

38-
def skewnorm_function(xs, *params):
39-
"""Skewed normal distribution fitting function.
38+
def skewed_gaussian_function(xs, *params):
39+
"""Skewed gaussian fitting function.
4040
4141
Parameters
4242
----------

specparam/tests/modes/test_funcs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ def test_gaussian_function():
2424
assert max(ys) == hgt
2525
assert np.allclose([ii/sum(ys) for ii in ys], norm.pdf(xs, ctr, wid))
2626

27-
def test_skewnorm_function():
27+
def test_skewed_gaussian_function():
2828

2929
# Check that with no skew, approximate gaussian
3030
ctr, hgt, wid, skew = 50, 5, 10, 1
3131
xs = np.arange(1, 100)
3232
ys_gaus = gaussian_function(xs, ctr, hgt, wid)
33-
ys_skew = skewnorm_function(xs, ctr, hgt, wid, skew)
33+
ys_skew = skewed_gaussian_function(xs, ctr, hgt, wid, skew)
3434
np.allclose(ys_gaus, ys_skew, atol=0.001)
3535

3636
# Check with some skew - right skew (more density after center)
3737
skew1 = 2
38-
ys_skew1 = skewnorm_function(xs, ctr, hgt, wid, skew1)
38+
ys_skew1 = skewed_gaussian_function(xs, ctr, hgt, wid, skew1)
3939
assert sum(ys_skew1[xs<ctr]) < sum(ys_skew1[xs>ctr])
4040

4141
# Check with some skew - left skew (more density before center)
4242
skew2 = -2
43-
ys_skew2 = skewnorm_function(xs, ctr, hgt, wid, skew2)
43+
ys_skew2 = skewed_gaussian_function(xs, ctr, hgt, wid, skew2)
4444
assert sum(ys_skew2[xs<ctr]) > sum(ys_skew2[xs>ctr])
4545

4646
def test_cauchy_function():

0 commit comments

Comments
 (0)