original_docstring:  Calculates the van Rossum multi-unit distance.
  
      The single-unit distance is defined as Euclidean distance of the spike
      trains convolved with a causal decaying exponential smoothing filter.
      A detailed description can be found in *Rossum, M. C. W. (2001). A novel
      spike distance. Neural Computation, 13(4), 751-763.* This implementation is
      normalized to yield a distance of 1.0 for the distance between an empty
      spike train and a spike train with a single spike. Divide the result by
      sqrt(2.0) to get the normalization used in the cited paper.
  
      Given the :math:`p`- and :math:`q`-th spike train of `a` and respectively
      `b` let :math:`R_{pq}` be the squared single-unit distance between these
      two spike trains. Then the multi-unit distance is :math:`\\sqrt{\\sum_p
      (R_{pp} + c \\cdot \\sum_{q \\neq p} R_{pq})}` with :math:`c` being
      equal to `weighting`. The weighting parameter controls the interpolation
      between a labeled line and a summed population coding.
  
      More information can be found in
      *Houghton, C., & Kreuz, T. (2012). On the efficient calculation of van
      Rossum distances. Network: Computation in Neural Systems, 23(1-2), 48-58.*
  
      Given :math:`N` spike trains in total with :math:`n` spikes on average the
      run-time complexity of this function is :math:`O(N^2 n^2)` and :math:`O(N^2
      + Nn^2)` memory will be needed.
  
      If `pymuvr` is installed, this function will use the faster C++
      implementation contained in the package.
  
      :param dict units: Dictionary of sequences with each sequence containing
          the trials of one unit. Each trial should be
          a :class:`neo.core.SpikeTrain` and all units should have the same
          number of trials.
      :param float weighting: Controls the interpolation between a labeled line
          and a summed population coding.
      :param tau: Decay rate of the exponential function as time scalar. Controls
          for which time scale the metric will be sensitive. This parameter will
          be ignored if `kernel` is not `None`. May also be :const:`scipy.inf`
          which will lead to only measuring differences in spike count.
      :type tau: Quantity scalar
      :param kernel: Kernel to use in the calculation of the distance. This is not
          the smoothing filter, but its autocorrelation. If `kernel` is `None`, an
          unnormalized Laplacian kernel with a size of `tau` will be used.
      :type kernel: :class:`.signal_processing.Kernel`
      :returns: A 2D array with the multi-unit distance for each pair of trials.
      :rtype: 2D arrary
      
docstring: Calculates the van Rossum multi-unit distance.
  The single-unit distance is defined as Euclidean distance of the spike
  trains convolved with a causal decaying exponential smoothing filter.
  A detailed description can be found in *Rossum, M. C. W.
  
  
  
  More information can be found in
  Houghton, C., & Kreuz, T.
  
  
  
  If `pymuvr` is installed, this function will use the faster C
  implementation contained in the package.
docstring_tokens: Calculates the van Rossum multi - unit distance . The single - unit distance is defined as Euclidean distance of the spike trains convolved with a causal decaying exponential smoothing filter . A detailed description can be found in * Rossum M . C . W . More information can be found in Houghton C . & Kreuz T . If ` pymuvr ` is installed this function will use the faster C implementation contained in the package .
code: def van_rossum_multiunit_dist(units, weighting, tau=1.0 * pq.s, kernel=None):
      """ Calculates the van Rossum multi-unit distance.
  
      The single-unit distance is defined as Euclidean distance of the spike
      trains convolved with a causal decaying exponential smoothing filter.
      A detailed description can be found in *Rossum, M. C. W. (2001). A novel
      spike distance. Neural Computation, 13(4), 751-763.* This implementation is
      normalized to yield a distance of 1.0 for the distance between an empty
      spike train and a spike train with a single spike. Divide the result by
      sqrt(2.0) to get the normalization used in the cited paper.
  
      Given the :math:`p`- and :math:`q`-th spike train of `a` and respectively
      `b` let :math:`R_{pq}` be the squared single-unit distance between these
      two spike trains. Then the multi-unit distance is :math:`\\sqrt{\\sum_p
      (R_{pp} + c \\cdot \\sum_{q \\neq p} R_{pq})}` with :math:`c` being
      equal to `weighting`. The weighting parameter controls the interpolation
      between a labeled line and a summed population coding.
  
      More information can be found in
      *Houghton, C., & Kreuz, T. (2012). On the efficient calculation of van
      Rossum distances. Network: Computation in Neural Systems, 23(1-2), 48-58.*
  
      Given :math:`N` spike trains in total with :math:`n` spikes on average the
      run-time complexity of this function is :math:`O(N^2 n^2)` and :math:`O(N^2
      + Nn^2)` memory will be needed.
  
      If `pymuvr` is installed, this function will use the faster C++
      implementation contained in the package.
  
      :param dict units: Dictionary of sequences with each sequence containing
          the trials of one unit. Each trial should be
          a :class:`neo.core.SpikeTrain` and all units should have the same
          number of trials.
      :param float weighting: Controls the interpolation between a labeled line
          and a summed population coding.
      :param tau: Decay rate of the exponential function as time scalar. Controls
          for which time scale the metric will be sensitive. This parameter will
          be ignored if `kernel` is not `None`. May also be :const:`scipy.inf`
          which will lead to only measuring differences in spike count.
      :type tau: Quantity scalar
      :param kernel: Kernel to use in the calculation of the distance. This is not
          the smoothing filter, but its autocorrelation. If `kernel` is `None`, an
          unnormalized Laplacian kernel with a size of `tau` will be used.
      :type kernel: :class:`.signal_processing.Kernel`
      :returns: A 2D array with the multi-unit distance for each pair of trials.
      :rtype: 2D arrary
      """
  
      if kernel is None and tau != sp.inf:
          kernel = sigproc.LaplacianKernel(tau, normalize=False)
  
      if PYMUVR_AVAILABLE and tau != sp.inf:
          rescaled_trains = []
          n_trials = len(units.itervalues().next())
  
          for i in xrange(n_trials):
              trial_trains = []
              for u, tr in units.iteritems():
                  trial_trains.append(list(tr[i].rescale(pq.s).magnitude))
              rescaled_trains.append(trial_trains)
          t = tau.rescale(pq.s).magnitude
          r = pymuvr.square_distance_matrix(rescaled_trains, weighting, t)
          print r
          #print rescaled_trains, weighting, t
          print _calc_multiunit_dist_matrix_from_single_trials(
              units, _van_rossum_multiunit_dist_for_trial_pair, weighting=weighting,
              tau=tau, kernel=kernel)
          return r
  
      return _calc_multiunit_dist_matrix_from_single_trials(
          units, _van_rossum_multiunit_dist_for_trial_pair, weighting=weighting,
          tau=tau, kernel=kernel)
code_tokens: def van_rossum_multiunit_dist ( units , weighting , tau = 1.0 * pq . s , kernel = None ) : if kernel is None and tau != sp . inf : kernel = sigproc . LaplacianKernel ( tau , normalize = False ) if PYMUVR_AVAILABLE and tau != sp . inf : rescaled_trains = [ ] n_trials = len ( units . itervalues ( ) . next ( ) ) for i in xrange ( n_trials ) : trial_trains = [ ] for u , tr in units . iteritems ( ) : trial_trains . append ( list ( tr [ i ] . rescale ( pq . s ) . magnitude ) ) rescaled_trains . append ( trial_trains ) t = tau . rescale ( pq . s ) . magnitude r = pymuvr . square_distance_matrix ( rescaled_trains , weighting , t ) print r print _calc_multiunit_dist_matrix_from_single_trials ( units , _van_rossum_multiunit_dist_for_trial_pair , weighting = weighting , tau = tau , kernel = kernel ) return r return _calc_multiunit_dist_matrix_from_single_trials ( units , _van_rossum_multiunit_dist_for_trial_pair , weighting = weighting , tau = tau , kernel = kernel )
short_docstring: Calculates the van Rossum multi-unit distance.
short_docstring_tokens: Calculates the van Rossum multi - unit distance .
comment: """ Calculates the van Rossum multi-unit distance.
  
      The single-unit distance is defined as Euclidean distance of the spike
      trains convolved with a causal decaying exponential smoothing filter.
      A detailed description can be found in *Rossum, M. C. W. (2001). A novel
      spike distance. Neural Computation, 13(4), 751-763.* This implementation is
      normalized to yield a distance of 1.0 for the distance between an empty
      spike train and a spike train with a single spike. Divide the result by
      sqrt(2.0) to get the normalization used in the cited paper.
  
      Given the :math:`p`- and :math:`q`-th spike train of `a` and respectively
      `b` let :math:`R_{pq}` be the squared single-unit distance between these
      two spike trains. Then the multi-unit distance is :math:`\\sqrt{\\sum_p
      (R_{pp} + c \\cdot \\sum_{q \\neq p} R_{pq})}` with :math:`c` being
      equal to `weighting`. The weighting parameter controls the interpolation
      between a labeled line and a summed population coding.
  
      More information can be found in
      *Houghton, C., & Kreuz, T. (2012). On the efficient calculation of van
      Rossum distances. Network: Computation in Neural Systems, 23(1-2), 48-58.*
  
      Given :math:`N` spike trains in total with :math:`n` spikes on average the
      run-time complexity of this function is :math:`O(N^2 n^2)` and :math:`O(N^2
      + Nn^2)` memory will be needed.
  
      If `pymuvr` is installed, this function will use the faster C++
      implementation contained in the package.
  
      :param dict units: Dictionary of sequences with each sequence containing
          the trials of one unit. Each trial should be
          a :class:`neo.core.SpikeTrain` and all units should have the same
          number of trials.
      :param float weighting: Controls the interpolation between a labeled line
          and a summed population coding.
      :param tau: Decay rate of the exponential function as time scalar. Controls
          for which time scale the metric will be sensitive. This parameter will
          be ignored if `kernel` is not `None`. May also be :const:`scipy.inf`
          which will lead to only measuring differences in spike count.
      :type tau: Quantity scalar
      :param kernel: Kernel to use in the calculation of the distance. This is not
          the smoothing filter, but its autocorrelation. If `kernel` is `None`, an
          unnormalized Laplacian kernel with a size of `tau` will be used.
      :type kernel: :class:`.signal_processing.Kernel`
      :returns: A 2D array with the multi-unit distance for each pair of trials.
      :rtype: 2D arrary
      """$SEP$#print rescaled_trains, weighting, t