Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix bug with removed SciPy function #171

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading