@@ -178,7 +178,7 @@ def __init__(self, peak_width_limits=(0.5, 12.0), max_n_peaks=np.inf, min_peak_h
178178 self ._bw_std_edge = 1.0
179179 # Degree of overlap between gaussians for one to be dropped
180180 # This is defined in units of gaussian standard deviation
181- self ._gauss_overlap_thresh = 1.5
181+ self ._gauss_overlap_thresh = 0.75
182182 # Parameter bounds for center frequency when fitting gaussians, in terms of +/- std dev
183183 self ._cf_bound = 1.5
184184 # The maximum number of calls to the curve fitting function
@@ -817,7 +817,7 @@ def _fit_peaks(self, flat_iter):
817817 max_ind = np .argmax (flat_iter )
818818 max_height = flat_iter [max_ind ]
819819
820- # Stop searching for peaks peaks once drops below height threshold
820+ # Stop searching for peaks once height drops below height threshold
821821 if max_height <= self .peak_threshold * np .std (flat_iter ):
822822 break
823823
@@ -1030,14 +1030,18 @@ def _drop_peak_overlap(self, guess):
10301030 the lowest height guess guassian is dropped.
10311031 """
10321032
1033- # Sort the peak guesses, so can check overlap of adjacent peaks
1033+ # Sort the peak guesses by increasing frequency, so adjacenent peaks can
1034+ # be compared from right to left.
10341035 guess = sorted (guess , key = lambda x : float (x [0 ]))
10351036
10361037 # Calculate standard deviation bounds for checking amount of overlap
1037- bounds = [[peak [0 ] - peak [2 ] * self ._gauss_overlap_thresh , peak [0 ],
1038+ # The bounds are the gaussian frequncy +/- gaussian standard deviation
1039+ bounds = [[peak [0 ] - peak [2 ] * self ._gauss_overlap_thresh ,
10381040 peak [0 ] + peak [2 ] * self ._gauss_overlap_thresh ] for peak in guess ]
10391041
10401042 # Loop through peak bounds, comparing current bound to that of next peak
1043+ # If the left peak's upper bound extends pass the right peaks lower bound,
1044+ # Then drop the guassian with the lower height.
10411045 drop_inds = []
10421046 for ind , b_0 in enumerate (bounds [:- 1 ]):
10431047 b_1 = bounds [ind + 1 ]
@@ -1165,7 +1169,7 @@ def _prepare_data(freqs, power_spectrum, freq_range, spectra_dim=1, verbose=True
11651169 freqs , power_spectrum = trim_spectrum (freqs , power_spectrum , freq_range )
11661170
11671171 # Check if freqs start at 0 and move up one value if so
1168- # Aperiodic fit gets an inf is freq of 0 is included, which leads to an error
1172+ # Aperiodic fit gets an inf if freq of 0 is included, which leads to an error
11691173 if freqs [0 ] == 0.0 :
11701174 freqs , power_spectrum = trim_spectrum (freqs , power_spectrum , [freqs [1 ], freqs .max ()])
11711175 if verbose :
0 commit comments