def test_bin_shuffling_output_format(self): self.bin_size = 3 * pq.ms self.max_displacement = 10 spiketrain = neo.SpikeTrain([90, 93, 97, 100, 105, 150, 180, 350] * pq.ms, t_stop=.5 * pq.s) binned_spiketrain = conv.BinnedSpikeTrain(spiketrain, self.bin_size) n_surrogates = 2 for sliding in (True, False): surrogate_trains = surr.bin_shuffling( binned_spiketrain, max_displacement=self.max_displacement, n_surrogates=n_surrogates, sliding=sliding) self.assertIsInstance(surrogate_trains, list) self.assertEqual(len(surrogate_trains), n_surrogates) self.assertIsInstance(surrogate_trains[0], conv.BinnedSpikeTrain) for surrogate_train in surrogate_trains: self.assertEqual(surrogate_train.t_start, binned_spiketrain.t_start) self.assertEqual(surrogate_train.t_stop, binned_spiketrain.t_stop) self.assertEqual(surrogate_train.n_bins, binned_spiketrain.n_bins) self.assertEqual(surrogate_train.bin_size, binned_spiketrain.bin_size)
def test_bin_shuffling_empty_train(self): self.bin_size = 3 * pq.ms self.max_displacement = 10 empty_spiketrain = neo.SpikeTrain([] * pq.ms, t_stop=500 * pq.ms) binned_spiketrain = conv.BinnedSpikeTrain(empty_spiketrain, self.bin_size) surrogate_train = surr.bin_shuffling( binned_spiketrain, max_displacement=self.max_displacement, n_surrogates=1)[0] self.assertEqual(np.sum(surrogate_train.to_bool_array()), 0)