def test_rasterized_signal_subset(signal): subset = signal.select_times([(0, 0.2), (0.3, 2)]) assert subset.as_continuous().shape == (3, 95) epoch_subset = subset.extract_epoch('pupil_closed') assert epoch_subset.shape == (1, 3, 45) assert np.all(epoch_subset[0] == signal.extract_epoch('pupil_closed')[0]) with pytest.raises(IndexError): epoch_subset = subset.extract_epoch('trial') assert subset.average_epoch('pupil_closed').shape == (3, 45)
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)