def test_as_trials(signal): signal.epochs = signal.trial_epochs_from_occurrences(occurrences=10) result = signal.extract_epoch('trial') assert result.shape == (10, 3, 20) with pytest.raises(ValueError): signal.epochs = signal.trial_epochs_from_occurrences(occurrences=11)
def test_jackknifes_by_epoch(signal): signal.epochs = signal.trial_epochs_from_occurrences(occurrences=50) for est, val in signal.jackknifes_by_epoch(10, 'trial'): print(np.nansum(est.as_continuous()[:]), np.nansum(val.as_continuous()[:]),) # This is not much of a test -- I'm just running the generator fn! assert(True)
def test_jackknife_by_epoch(signal): signal.epochs = signal.trial_epochs_from_occurrences(occurrences=50) s1 = signal.jackknife_by_epoch(10, 0, 'trial', tiled=False, invert=True) epoch_indices = signal.get_epoch_bounds('trial') subset_sig = signal.select_times(epoch_indices[:10]) jack1 = subset_sig.jackknife_by_epoch(10, 0, 'trial', tiled=False, invert=False) assert s1.as_continuous().shape == (3, 200) # shape shouldn't change assert(1770.0 == np.nansum(s1.as_continuous()[:])) # Should nan 10% of subsetted data - not 10% of non-subset data assert(sum(~np.isnan(jack1.as_continuous().flatten()))/jack1.as_continuous().size ==0.9)
def test_jackknife_by_epoch(signal): signal.epochs = signal.trial_epochs_from_occurrences(occurrences=50) s1 = signal.jackknife_by_epoch(10, 0, 'trial', tiled=False, invert=True) assert s1.as_continuous().shape == (3, 200) # shape shouldn't change assert (1770.0 == np.nansum(s1.as_continuous()[:]))
def test_as_average_trial(signal): signal.epochs = signal.trial_epochs_from_occurrences(occurrences=10) result = signal.average_epoch('trial') assert result.shape == (3, 20)