Skip to content

Commit

Permalink
fix - unit problem in bin_shuffling (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbouss authored Sep 28, 2020
1 parent 48fc9b0 commit 5d43e0a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions elephant/spike_train_surrogates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,7 @@ def _trial_shifting_of_concatenated_spiketrain(
t_stop = spiketrain.t_stop.simplified.magnitude
trial_length = trial_length.simplified.magnitude
trial_separation = trial_separation.simplified.magnitude
dither = dither.simplified.magnitude
n_trials = int((t_stop - t_start) // (trial_length + trial_separation))
t_starts = t_start + \
np.arange(n_trials) * (trial_length + trial_separation)
Expand Down Expand Up @@ -1348,17 +1349,15 @@ def surrogates(
return _trial_shifting_of_concatenated_spiketrain(
spiketrain, dither=dt, n_surrogates=n_surrogates, **kwargs)
if method is bin_shuffling:
bin_size = kwargs['bin_size']
binned_spiketrain = conv.BinnedSpikeTrain(
spiketrain, bin_size=bin_size)
bin_grid = binned_spiketrain.bin_centers.magnitude
spiketrain, bin_size=kwargs['bin_size'])
bin_grid = binned_spiketrain.bin_centers.simplified.magnitude
max_displacement = int(
dt.rescale(pq.ms).magnitude / bin_size.rescale(pq.ms).magnitude)
dt.simplified.magnitude / kwargs['bin_size'].simplified.magnitude)
binned_surrogates = method(
binned_spiketrain, max_displacement, n_surrogates=n_surrogates)
surrogate_spiketrains = [neo.SpikeTrain(
bin_grid[binned_surrogate.to_bool_array()[0]]
+ spiketrain.t_start.magnitude,
bin_grid[binned_surrogate.to_bool_array()[0]] * pq.s,
t_start=spiketrain.t_start,
t_stop=spiketrain.t_stop,
units=spiketrain.units)
Expand Down

0 comments on commit 5d43e0a

Please sign in to comment.