A collection of analysis functions that may be used by NeuroTools.signals or other packages.
TuningCurve([D]) | Class to facilitate working with tuning curves. |
ccf | Fast cross correlation function based on fft. |
crosscorrelate | Cross-correlation between two series of discrete events (e.g. |
make_kernel | Creates kernel functions for convolution. |
simple_frequency_spectrum | Simple frequency spectrum. |
Class to facilitate working with tuning curves.
Fast cross correlation function based on fft.
Computes the cross-correlation function of two series. Note that the computations are performed on anomalies (deviations from average). Returns the values of the cross-correlation at different lags.
>>> z = arange(5)
>>> ccf(z,z)
array([ 3.90798505e-16, -4.00000000e-01, -4.00000000e-01,
-1.00000000e-01, 4.00000000e-01, 1.00000000e+00,
4.00000000e-01, -1.00000000e-01, -4.00000000e-01,
-4.00000000e-01])
Cross-correlation between two series of discrete events (e.g. spikes).
Calculates the cross-correlation between two vectors containing event times. Returns (differeces, pred, norm). See below for details.
Adapted from original script written by Martin P. Nawrot for the FIND MATLAB toolbox [1]_.
>> crosscorrelate(np_array1, np_array2) >> crosscorrelate(spike_train1, spike_train2) >> crosscorrelate(spike_train1, spike_train2, lag = 150.0) >> crosscorrelate(spike_train1, spike_train2, display=True,
kwargs={‘bins’:100})
ccf
[1] | Meier R, Egert U, Aertsen A, Nawrot MP, “FIND - a unified framework for neural data analysis”; Neural Netw. 2008 Oct; 21(8):1085-93. |
Creates kernel functions for convolution.
Constructs a numeric linear convolution kernel of basic shape to be used for data smoothing (linear low pass filtering) and firing rate estimation from single trial or trial-averaged spike trains.
Exponential and alpha kernels may also be used to represent postynaptic currents / potentials in a linear (current-based) model.
Adapted from original script written by Martin P. Nawrot for the FIND MATLAB toolbox [1]_ [2].
- form : {‘BOX’, ‘TRI’, ‘GAU’, ‘EPA’, ‘EXP’, ‘ALP’}
- Kernel form. Currently implemented forms are BOX (boxcar), TRI (triangle), GAU (gaussian), EPA (epanechnikov), EXP (exponential), ALP (alpha function). EXP and ALP are aymmetric kernel forms and assume optional parameter direction.
- sigma : float
- Standard deviation of the distribution associated with kernel shape. This parameter defines the time resolution (in ms) of the kernel estimate and makes different kernels comparable (cf. [1] for symetric kernels). This is used here as an alternative definition to the cut-off frequency of the associated linear filter.
- time_stamp_resolution : float
- Temporal resolution of input and output in ms.
- direction : {-1, 1}
- Asymmetric kernels have two possible directions. The values are -1 or 1, default is 1. The definition here is that for direction = 1 the kernel represents the impulse response function of the linear filter. Default value is 1.
- kernel : array_like
- Array of kernel. The length of this array is always an odd number to represent symmetric kernels such that the center bin coincides with the median of the numeric array, i.e for a triangle, the maximum will be at the center bin with equal number of bins to the right and to the left.
For rate estimates. The kernel vector is normalized such that the sum of all entries equals unity sum(kernel)=1. When estimating rate functions from discrete spike data (0/1) the additional parameter norm allows for the normalization to rate in spikes per second.
For example: rate = norm * scipy.signal.lfilter(kernel, 1, spike_data)
To obtain single trial rate function of trial one should use:
r = norm * scipy.signal.fftconvolve(sua, kernel)
To obtain trial-averaged spike train one should use:
r_avg = norm * scipy.signal.fftconvolve(sua, np.mean(X,1))
where X is an array of shape (l,n), n is the number of trials and l is the length of each trial.
SpikeTrain.instantaneous_rate SpikeList.averaged_instantaneous_rate
[1] | Meier R, Egert U, Aertsen A, Nawrot MP, “FIND - a unified framework for neural data analysis”; Neural Netw. 2008 Oct; 21(8):1085-93. |
[2] | Nawrot M, Aertsen A, Rotter S, “Single-trial estimation of neuronal firing rates - from single neuron spike trains to population activity”; J. Neurosci Meth 94: 81-92; 1999. |
Simple frequency spectrum.
Very simple calculation of frequency spectrum with no detrending, windowing, etc, just the first half (positive frequency components) of abs(fft(x))