def test_stockwell_api(): """Test stockwell functions.""" raw = read_raw_fif(raw_fname) event_id, tmin, tmax = 1, -0.2, 0.5 event_name = op.join(base_dir, 'test-eve.fif') events = read_events(event_name) epochs = Epochs(raw, events, # XXX pick 2 has epochs of zeros. event_id, tmin, tmax, picks=[0, 1, 3]) for fmin, fmax in [(None, 50), (5, 50), (5, None)]: with warnings.catch_warnings(record=True): # zero papdding power, itc = tfr_stockwell(epochs, fmin=fmin, fmax=fmax, return_itc=True) if fmax is not None: assert_true(power.freqs.max() <= fmax) with warnings.catch_warnings(record=True): # padding power_evoked = tfr_stockwell(epochs.average(), fmin=fmin, fmax=fmax, return_itc=False) # for multitaper these don't necessarily match, but they seem to # for stockwell... if this fails, this maybe could be changed # just to check the shape assert_array_almost_equal(power_evoked.data, power.data) assert_true(isinstance(power, AverageTFR)) assert_true(isinstance(itc, AverageTFR)) assert_equal(power.data.shape, itc.data.shape) assert_true(itc.data.min() >= 0.0) assert_true(itc.data.max() <= 1.0) assert_true(np.log(power.data.max()) * 20 <= 0.0) assert_true(np.log(power.data.max()) * 20 <= 0.0)
def test_stockwell_api(): """Test stockwell functions.""" raw = read_raw_fif(raw_fname) event_id, tmin, tmax = 1, -0.2, 0.5 event_name = op.join(base_dir, 'test-eve.fif') events = read_events(event_name) epochs = Epochs(raw, events, # XXX pick 2 has epochs of zeros. event_id, tmin, tmax, picks=[0, 1, 3]) for fmin, fmax in [(None, 50), (5, 50), (5, None)]: with warnings.catch_warnings(record=True): # zero papdding power, itc = tfr_stockwell(epochs, fmin=fmin, fmax=fmax, return_itc=True) if fmax is not None: assert (power.freqs.max() <= fmax) with warnings.catch_warnings(record=True): # padding power_evoked = tfr_stockwell(epochs.average(), fmin=fmin, fmax=fmax, return_itc=False) # for multitaper these don't necessarily match, but they seem to # for stockwell... if this fails, this maybe could be changed # just to check the shape assert_array_almost_equal(power_evoked.data, power.data) assert (isinstance(power, AverageTFR)) assert (isinstance(itc, AverageTFR)) assert_equal(power.data.shape, itc.data.shape) assert (itc.data.min() >= 0.0) assert (itc.data.max() <= 1.0) assert (np.log(power.data.max()) * 20 <= 0.0) assert (np.log(power.data.max()) * 20 <= 0.0)
def test_stockwell_api(): """Test stockwell functions""" epochs = Epochs( raw, events, # XXX pick 2 has epochs of zeros. event_id, tmin, tmax, picks=[0, 1, 3], baseline=(None, 0)) for fmin, fmax in [(None, 50), (5, 50), (5, None)]: power, itc = tfr_stockwell(epochs, fmin=fmin, fmax=fmax, return_itc=True) if fmax is not None: assert_true(power.freqs.max() <= fmax) power_evoked = tfr_stockwell(epochs.average(), fmin=fmin, fmax=fmax, return_itc=False) # for multitaper these don't necessarily match, but they seem to # for stockwell... if this fails, this maybe could be changed # just to check the shape assert_array_almost_equal(power_evoked.data, power.data) assert_true(isinstance(power, AverageTFR)) assert_true(isinstance(itc, AverageTFR)) assert_equal(power.data.shape, itc.data.shape) assert_true(itc.data.min() >= 0.0) assert_true(itc.data.max() <= 1.0) assert_true(np.log(power.data.max()) * 20 <= 0.0) assert_true(np.log(power.data.max()) * 20 <= 0.0)
def test_stockwell_ctf(): """Test that Stockwell can be calculated on CTF data.""" raw = read_raw_fif(raw_ctf_fname) raw.apply_gradient_compensation(3) events = make_fixed_length_events(raw, duration=0.5) evoked = Epochs(raw, events, tmin=-0.2, tmax=0.3, decim=10, preload=True, verbose='error').average() tfr_stockwell(evoked, verbose='error') # smoke test
def test_stockwell_ctf(): """Test that Stockwell can be calculated on CTF data.""" raw = read_raw_fif(raw_ctf_fname) raw.apply_gradient_compensation(3) events = make_fixed_length_events(raw, duration=0.5) evoked = Epochs(raw, events, tmin=-0.2, tmax=0.3, decim=10, preload=True, verbose='error').average() tfr_stockwell(evoked, verbose='error') # smoke test
def test_stockwell_api(): """Test stockwell functions.""" raw = read_raw_fif(raw_fname) event_id, tmin, tmax = 1, -0.2, 0.5 event_name = op.join(base_dir, 'test-eve.fif') events = read_events(event_name) epochs = Epochs( raw, events, # XXX pick 2 has epochs of zeros. event_id, tmin, tmax, picks=[0, 1, 3]) for fmin, fmax in [(None, 50), (5, 50), (5, None)]: with pytest.warns(RuntimeWarning, match='padding'): power, itc = tfr_stockwell(epochs, fmin=fmin, fmax=fmax, return_itc=True) if fmax is not None: assert (power.freqs.max() <= fmax) with pytest.warns(RuntimeWarning, match='padding'): power_evoked = tfr_stockwell(epochs.average(), fmin=fmin, fmax=fmax, return_itc=False) # for multitaper these don't necessarily match, but they seem to # for stockwell... if this fails, this maybe could be changed # just to check the shape assert_array_almost_equal(power_evoked.data, power.data) assert (isinstance(power, AverageTFR)) assert (isinstance(itc, AverageTFR)) assert_equal(power.data.shape, itc.data.shape) assert (itc.data.min() >= 0.0) assert (itc.data.max() <= 1.0) assert (np.log(power.data.max()) * 20 <= 0.0) assert (np.log(power.data.max()) * 20 <= 0.0) with pytest.raises(TypeError, match='ndarray'): tfr_array_stockwell('foo', 1000.) data = np.random.RandomState(0).randn(1, 1024) with pytest.raises(ValueError, match='3D with shape'): tfr_array_stockwell(data, 1000.) data = data[np.newaxis] power, itc, freqs = tfr_array_stockwell(data, 1000., return_itc=True) assert_allclose(itc, np.ones_like(itc)) assert power.shape == (1, len(freqs), data.shape[-1]) assert_array_less(0, power)
def test_stockwell_api(): """Test stockwell functions""" epochs = Epochs(raw, events, # XXX pick 2 has epochs of zeros. event_id, tmin, tmax, picks=[0, 1, 3], baseline=(None, 0)) for fmin, fmax in [(None, 50), (5, 50), (5, None)]: power, itc = tfr_stockwell(epochs, fmin=fmin, fmax=fmax, return_itc=True) if fmax is not None: assert_true(power.freqs.max() <= fmax) power_evoked = tfr_stockwell(epochs.average(), fmin=fmin, fmax=fmax, return_itc=False) # for multitaper these don't necessarily match, but they seem to # for stockwell... if this fails, this maybe could be changed # just to check the shape assert_array_almost_equal(power_evoked.data, power.data) assert_true(isinstance(power, AverageTFR)) assert_true(isinstance(itc, AverageTFR)) assert_equal(power.data.shape, itc.data.shape) assert_true(itc.data.min() >= 0.0) assert_true(itc.data.max() <= 1.0) assert_true(np.log(power.data.max()) * 20 <= 0.0) assert_true(np.log(power.data.max()) * 20 <= 0.0)
def test_stockwell_api(): """test stockwell functions""" epochs = Epochs(raw, events, # XXX pick 2 has epochs of zeros. event_id, tmin, tmax, picks=[0, 1, 3], baseline=(None, 0)) for fmin, fmax in [(None, 50), (5, 50), (5, None)]: power, itc = tfr_stockwell(epochs, fmin=fmin, fmax=fmax, return_itc=True) if fmax is not None: assert_true(power.freqs.max() <= fmax) assert_true(isinstance(power, AverageTFR)) assert_true(isinstance(itc, AverageTFR)) assert_equals(power.data.shape, itc.data.shape) assert_true(itc.data.min() >= 0.0) assert_true(itc.data.max() <= 1.0) assert_true(np.log(power.data.max()) * 20 <= 0.0) assert_true(np.log(power.data.max()) * 20 <= 0.0)