Skip to content

Commit

Permalink
Fix setting csd.tmin/csd.tmax for csd_morlet
Browse files Browse the repository at this point in the history
  • Loading branch information
wmvanvliet authored and larsoner committed May 3, 2018
1 parent eefc3fd commit a9a8027
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions mne/time_frequency/csd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,7 @@ def csd_array_morlet(X, sfreq, frequencies, t0=0, tmin=None, tmax=None,
csd_tstart = None if tmin is None else np.searchsorted(times, tmin - 1e-10)
csd_tstop = None if tmax is None else np.searchsorted(times, tmax + 1e-10)
csd_tslice = slice(csd_tstart, csd_tstop)
times = times[csd_tslice]

# Compute the CSD
return _execute_csd_function(X, times, frequencies, _csd_morlet,
Expand Down
12 changes: 12 additions & 0 deletions mne/time_frequency/tests/test_csd.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ def test_csd_fourier():
else:
csd = csd_fourier(epochs, fmin=9, fmax=23, tmin=tmin, tmax=tmax)

if tmin is None and tmax is None:
assert csd.tmin == 0 and csd.tmax == 9.98
else:
assert csd.tmin == tmin and csd.tmax == tmax
csd = csd.mean([9.9, 14.9, 21.9], [10.1, 15.1, 22.1])
_test_csd_matrix(csd)

Expand Down Expand Up @@ -457,6 +461,10 @@ def test_csd_multitaper():
else:
csd = csd_multitaper(epochs, adaptive=adaptive, fmin=9, fmax=23,
tmin=tmin, tmax=tmax)
if tmin is None and tmax is None:
assert csd.tmin == 0 and csd.tmax == 9.98
else:
assert csd.tmin == tmin and csd.tmax == tmax
csd = csd.mean([9.9, 14.9, 21.9], [10.1, 15.1, 22.1])
_test_csd_matrix(csd)

Expand Down Expand Up @@ -510,6 +518,10 @@ def test_csd_morlet():
else:
csd = csd_morlet(epochs, frequencies=freqs, n_cycles=n_cycles,
tmin=tmin, tmax=tmax)
if tmin is None and tmax is None:
assert csd.tmin == 0 and csd.tmax == 9.98
else:
assert csd.tmin == tmin and csd.tmax == tmax
_test_csd_matrix(csd)

# CSD diagonals should contain PSD
Expand Down

0 comments on commit a9a8027

Please sign in to comment.