Skip to content

Commit

Permalink
BUG: Fix bug with removed SciPy function (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner authored Jul 4, 2024
1 parent 5200696 commit b1e866c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions yasa/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
import pandas as pd
from scipy import signal
from scipy.integrate import simps
from scipy.integrate import simpson
from scipy.interpolate import RectBivariateSpline
from .io import set_log_level

Expand Down Expand Up @@ -232,7 +232,7 @@ def bandpower_from_psd(
ch_names = ["CHAN" + str(i).zfill(3) for i in range(nchan)]
bp = np.zeros((nchan, len(bands)), dtype=np.float64)
psd = psd[:, idx_good_freq]
total_power = simps(psd, dx=res)
total_power = simpson(psd, dx=res)
total_power = total_power[..., np.newaxis]

# Check if there are negative values in PSD
Expand All @@ -251,7 +251,7 @@ def bandpower_from_psd(
b0, b1, la = band
labels.append(la)
idx_band = np.logical_and(freqs >= b0, freqs <= b1)
bp[:, i] = simps(psd[:, idx_band], dx=res)
bp[:, i] = simpson(psd[:, idx_band], dx=res)

if relative:
bp /= total_power
Expand Down Expand Up @@ -340,7 +340,7 @@ def bandpower_from_psd_ndarray(
logger.warning(msg)

# Calculate total power
total_power = simps(psd, dx=res, axis=-1)
total_power = simpson(psd, dx=res, axis=-1)
total_power = total_power[np.newaxis, ...]

# Initialize empty array
Expand All @@ -352,7 +352,7 @@ def bandpower_from_psd_ndarray(
b0, b1, la = band
labels.append(la)
idx_band = np.logical_and(freqs >= b0, freqs <= b1)
bp[i] = simps(psd[..., idx_band], dx=res, axis=-1)
bp[i] = simpson(psd[..., idx_band], dx=res, axis=-1)

if relative:
bp /= total_power
Expand Down

0 comments on commit b1e866c

Please sign in to comment.