Skip to content

Commit fec33e4

Browse files
authored
Merge pull request #189 from arokem/gh188
BF: degrees of freedom need to be an integer value.
2 parents 5d44b0b + 9235bb1 commit fec33e4

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

nitime/analysis/coherence.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def eigs(self):
304304
@desc.setattr_on_read
305305
def df(self):
306306
# The degrees of freedom:
307-
return 2 * self.NW - 1
307+
return int(2 * self.NW - 1)
308308

309309
@desc.setattr_on_read
310310
def spectra(self):
@@ -328,9 +328,9 @@ def weights(self):
328328
else:
329329
wshape = [1] * len(self.spectra.shape)
330330
wshape[0] = channel_n
331-
wshape[-2] = int(self.df)
331+
wshape[-2] = self.df
332332
pre_w = np.sqrt(self.eigs) + np.zeros((wshape[0],
333-
self.eigs.shape[0]))
333+
self.eigs.shape[0]))
334334

335335
w = pre_w.reshape(*wshape)
336336

nitime/tests/test_analysis.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,15 @@ def test_MorletWaveletAnalyzer():
314314
npt.assert_almost_equal(np.sin(HL.phase.data[10:-10]),
315315
np.sin(WL.phase.data[10:-10]),
316316
decimal=0)
317+
318+
319+
def test_MTCoherenceAnalyzer():
320+
"""
321+
Based on gh-188
322+
"""
323+
my_signal = np.random.randn(10, int(np.round(30.02*89)))
324+
multitaper_bandwidth = 0.1 # [Hz]
325+
TS = ts.TimeSeries(my_signal, sampling_rate=30.02)
326+
# T.metadata['roi'] = vessel_names
327+
C2 = nta.MTCoherenceAnalyzer(TS, bandwidth=multitaper_bandwidth)
328+
npt.assert_equal(C2.coherence.shape, (10, 10, 1337))

0 commit comments

Comments
 (0)