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

FIX: Fix interpolation of dpss_windows #140

Merged
merged 1 commit into from Feb 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions nitime/algorithms/spectral.py
Expand Up @@ -419,8 +419,7 @@ def dpss_windows(N, NW, Kmax, interp_from=None, interp_kind='linear'):
for this_d in d:
x = np.arange(this_d.shape[-1])
I = interpolate.interp1d(x, this_d, kind=interp_kind)
d_temp = I(np.arange(0, this_d.shape[-1] - 1,
float(this_d.shape[-1] - 1) / N))
d_temp = I(np.linspace(0, this_d.shape[-1] - 1, N, endpoint=False))

# Rescale:
d_temp = d_temp / np.sqrt(np.sum(d_temp ** 2))
Expand Down
7 changes: 6 additions & 1 deletion nitime/algorithms/tests/test_spectral.py
Expand Up @@ -157,7 +157,7 @@ def test_periodogram_csd():


def test_dpss_windows():
""" Test a funky corner case of DPSS_windows """
""" Test a couple of funky corner cases of DPSS_windows """

N = 1024
NW = 0 # Setting NW to 0 triggers the weird corner case in which some of
Expand All @@ -169,6 +169,11 @@ def test_dpss_windows():
for this_d in d[0::2]:
npt.assert_equal(this_d.sum(axis=-1) < 0, False)

# Make sure we interpolate to the proper number of points
d, w = tsa.dpss_windows(245411, 4, 8, 1000)
npt.assert_equal(d.shape[-1], 245411)


def test_dpss_properties():
""" Test conventions of Slepian eigenvectors """

Expand Down