diff --git a/mne/time_frequency/csd.py b/mne/time_frequency/csd.py index b7ac394ffc9..94ba920fba6 100644 --- a/mne/time_frequency/csd.py +++ b/mne/time_frequency/csd.py @@ -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, diff --git a/mne/time_frequency/tests/test_csd.py b/mne/time_frequency/tests/test_csd.py index e444a8ac342..b6bbe25a6ee 100644 --- a/mne/time_frequency/tests/test_csd.py +++ b/mne/time_frequency/tests/test_csd.py @@ -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) @@ -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) @@ -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