elephant.unitary_event_analysis.jointJ_window_analysis(spiketrains, bin_size=array(5.) * ms, win_size=array(100.) * ms, win_step=array(5.) * ms, pattern_hash=None, method='analytic_TrialByTrial', t_start=None, t_stop=None, binary=True, n_surrogates=100)[source]

Calculates the joint surprise in a sliding window fashion.

Implementation is based on [ue1].

A list of spike trains (neo.SpikeTrain objects) in different trials:
  • 0-axis –> Trials
  • 1-axis –> Neurons
  • 2-axis –> Spike times
bin_sizepq.Quantity, optional

The size of bins for discretizing spike trains. Default: 5 ms

win_sizepq.Quantity, optional

The size of the window of analysis. Default: 100 ms

win_steppq.Quantity, optional

The size of the window step. Default: 5 ms

pattern_hashint or list of int or None, optional

A list of interested patterns in hash values (see hash_from_pattern and inverse_hash_from_pattern functions). If None, all neurons are participated. Default: None

methodstr, optional
The method with which to compute the unitary events:
  • ‘analytic_TrialByTrial’: calculate the analytical expectancy on each trial, then sum over all trials;
  • ‘analytic_TrialAverage’: calculate the expectancy by averaging over trials (cf. Gruen et al. 2003);
  • ‘surrogate_TrialByTrial’: calculate the distribution of expected coincidences by spike time randomization in each trial and sum over trials.

Default: ‘analytic_trialByTrial’

t_start, t_stopfloat or pq.Quantity, optional

The start and stop times to use for the time points. If not specified, retrieved from the t_start and t_stop attributes of the input spiketrains.

binarybool, optional

Binarize the binned spike train objects (True) or not. Only the binary matrices are supported at the moment. Default: True

n_surrogatesint, optional

The number of surrogates to be used. Default: 100


The values of the following keys have the shape of

  • different window –> 0-axis
  • different pattern hash –> 1-axis
‘Js’: list of float

JointSurprise of different given patterns within each window.

‘indices’: list of list of int

A list of indices of pattern within each window.

‘n_emp’: list of int

The empirical number of each observed pattern.

‘n_exp’: list of float

The expected number of each pattern.

‘rate_avg’: list of float

The average firing rate of each neuron.

Additionally, ‘input_parameters’ key stores the input parameters.


If data is not in the format, specified above.


If binary is not True. The method works only with binary matrices at the moment.


The ratio between winsize or winstep and bin_size is not an integer.