Skip to content

Commit

Permalink
[BUG] - Technical Audit: Spectral (#202)
Browse files Browse the repository at this point in the history
* Updates to spectral from the technical review. 

Co-authored-by: Eric Lybrand <elybrand@ucsd.edu>
  • Loading branch information
elybrand and elybrand authored Jul 7, 2020
1 parent d57ed33 commit ab07e5b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions neurodsp/spectral/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ def compute_spectrum_wavelet(sig, fs, freqs, avg_type='mean', **kwargs):
freqs = create_freqs(*freqs)

mwt = compute_wavelet_transform(sig, fs, freqs, **kwargs)
spectrum = get_avg_func(avg_type)(abs(mwt)**2, axis=1)
# Convert the wavelet coefficient outputs to power
mwt_power = abs(mwt)**2
# Create the power spectrum by averaging across the time dimension
spectrum = get_avg_func(avg_type)(mwt_power, axis=1)

return freqs, spectrum

Expand Down Expand Up @@ -214,7 +217,7 @@ def compute_spectrum_medfilt(sig, fs, filt_len=1., f_range=None):
freqs = np.fft.fftfreq(len(sig), 1. / fs)[:int(np.ceil(len(sig) / 2.))]

# Convert median filter length from Hz to samples, and make sure it is odd
filt_len_samp = int(int(filt_len / (freqs[1] - freqs[0])))
filt_len_samp = int(filt_len / (freqs[1] - freqs[0]))
if filt_len_samp % 2 == 0:
filt_len_samp += 1

Expand Down

0 comments on commit ab07e5b

Please sign in to comment.