Skip to content

Commit

Permalink
Merge pull request #140 from Eric89GXL/fix-dpss
Browse files Browse the repository at this point in the history
FIX: Fix interpolation of dpss_windows
  • Loading branch information
arokem committed Feb 23, 2016
2 parents d4860e5 + 8ec7cfb commit 267e64b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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

0 comments on commit 267e64b

Please sign in to comment.