API documentation: | spikes | analysis | benchmark | parameters | stgen | utilities | facets |
NeuroTools.spikes
Data
__name__ = "NeuroTools.spikes"
Functions
_test()
loadAnalogSignalList(filename, id_list, dt=None, t_start=None, t_stop=None)
Returns a SpikeList object from the tmp file saved by PyNN-NEST.
The input is the filename where pyNN stored the spike list and the discretization step dt. it returns the spike list represented as a list of events. Events are tuples (relative time since last event, neuron_id); neuron_id and time are integers
All times in seconds.
The PyNN-NEST format (with compatible_output=True) is: * a line commented, * then one line per event: absolute time in ms, GID (see function printSpikes in nest1.py)
loadSpikeList(filename, id_list, dt=None, t_start=None, t_stop=None)
Returns a SpikeList object from the tmp file saved by PyNN-NEST.
The input is the filename where pyNN stored the spike list and the discretization step dt. it returns the spike list represented as a list of events. Events are tuples (relative time since last event, neuron_id); neuron_id and time are integers
All times in milliseconds.
The PyNN-NEST format (with compatible_output=True) is: * a line commented, * then one line per event: absolute time in ms, GID (see function printSpikes in nest1.py)
population2spikelist(output, N, dt, t_start, t_stop)
TODO sl2pynn
readFile(filename, sepchar='\t', skipchar='#')
Classes
AnalogSignal
__init__(self, signal, dt, t_start=None, t_stop=None)
__len__(self)
AnalogSignalList
__getitem__(self, i)
__init__(self, spikes, id_list, dt=None, t_start=None, t_stop=None)
__len__(self)
__setitem__(self, i, val)
append(self, id, signal)
plot_signals(self, id_list)
time_axis(self)
SpikeList
A SpikeList object is a list of SpikeTrain objects.
>>> sl = SpikeList(3, [(0, 0.1), (1, 0.1), (0, 0.2)]) >>> type( sl.spiketrains[0] ) <type SpikeTrain> >>> sl.spiketrains[0].spike_times array([ 0.1, 0.2]) >>> sl.as_ids_times() (array([0,0,1]), array([0.1,0.2,0.1])) >>> sl.as_ids_times(relative=True) (array([0,1,0]), array([0.1,0.0,0.1])) >>> sl.as_ids_times(quantized=0.01) (array([0,0,1]), array([10,20,10])) >>> sl.as_list_id_time() [(0,0.1), (0,0.2), (1,0.1)] >>> sl.as_id_list_times() [(0, array([0.1, 0.2])), (1, array([0.1]))] >>> sl.as_time_list_ids() [(0.1, [0,1]), (0.2, [0])] >>> sl.as_2byN_array() >>> array([[0,0,1],[0.1,0.2,0.1]])
ActivityMap(self, dimensions, display=False)
__getitem__(self, i)
__init__(self, spikes, id_list, dt=None, t_start=None, t_stop=None)
spikes is a list/tuple of (id,t) tuples (id in id_list) id_list is the list of ids of all recorded cells (needed for silent cells) If dtis specified, the time values should be ints, and will be multiplied by dt, otherwise time values should be floats. If t_start and t_stop are not specified, they are inferred from the data.
dt, t_start and t_stop are shared for all SpikeTrains
__len__(self)
__setitem__(self, i, val)
append(self, id, spiketrain)
as_2byN_array(self, relative=False, quantized=False)
as_id_list_times(self, relative=False, quantized=False)
as_ids_times(self, relative=False, quantized=False)
as_list_id_list_time(self, relative=False, quantized=False)
Returns (list of ids, list of times).
as_list_id_time(self, relative=False, quantized=False)
Returns a list/tuple of (id,t) tuples (id in range(0,N)).
as_pyNN_SpikeArray(self)
to use in conjonction with SpikeSourceArray neurons
>>> pop = Population((10,),!SpikeSourceArray, {'spike_times': sl.as_pyNN_SpikeArray() })
as_spikematrix(self)
Returns a list giving for each neuron how many spikes per time bin, usually zero everywhere, one if a spike. Useful for plots etc.
as_time_list_ids(self, relative=False, quantized=False)
concatenate(SpikeList_list)
cv_isi(self, nbins=100, display=False)
fano_factor(self, binwidth)
firing_rate(self, binwidth, display=False)
Calculate firing rate traces (in Hz) from arrays of spike times.
Spike times and binwidth should are in milliseconds. Returns a tuple (list_of_firing_rate_traces,bins)
>>> pylab.plot(output[0].time_axis(dt),sum(output.firing_rate(dt)))
id2position(id, dims)
idsubSpikeList(self, id_list)
isi(self, nbins=100, display=False)
mean_rate(self)
pairwise_correlation(self)
pw_corr_pearson(self, edge, bins, number_of_neurons)
TODO: document/test this function
rate_distribution(self, nbins=100, normalize=True, display=False)
spike_histogram(self, binwidth, normalized=False, display=False)
time_axis(self, binwidth)
timesubSpikeList(self, t_start, t_stop)
returns a new SpikeList
SpikeTrain
This class defines a spike train as a list of the events times.
Event times are given in a list (sparse representation) in milliseconds.
>>> s1 = !SpikeTrain([0.0, 0.1, 0.2, 0.5]) >>> s2 = !SpikeTrain(numpy.array([0, 1, 2, 5]), dt=0.1) >>> assert all(s1.spike_times == s2.spike_times) >>> print s1.format(relative=True) [ 0. 0.1 0.1 0.3] >>> s1.isi() array([ 0.1, 0.1, 0.3]) >>> s1.mean_firing_rate() 8.0 >>> s1.cv_isi() 0.565685424949
__init__(self, spike_times, dt=None, t_start=None, t_stop=None)
spike_times is a list/numpy array of spike times (in milliseconds)
TODO: We proposed initially that : If dtis specified, the time values should be ints, and will be multiplied by dt, otherwise time values should be floats. Markus suggested that the internal representation should be integer and that analysis methods also.
If t_start and t_stop are not specified, they are inferred from the data.
the format adopted for the representation is relative=False, quantized=False
__len__(self)
cv_isi(self)
cv_isi is the ratio between the standard deviation and the mean of the ISI
The irregularity of individual spike trains is measured by the squared coefficient of variation of the corresponding inter-spike interval (ISI) distribution normalized by the square of its mean. In point processes, low values reflect more regular spiking, a clock-like pattern yields CV2= 0. On the other hand, CV2 = 1 indicates Poisson-type behavior. As a measure for irregularity in the network one can use the average irregularity across all neurons.
TODO: is it useful to get the std of CV?
format(self, relative=False, quantized=False)
a function to format a spike train from one format to another. outputs a numpy array
isi(self)
mean_firing_rate(self)
subSpikeTrain(self, t_start, t_stop)
time_axis(self, binwidth)
time_histogram(self, binwidth, normalized=True)
Bin the spikes with the specified bin width. The first and last bins are calculated from self.t_start and self.t_stop. If normalized is True, the bin values are scaled so as to represent firing rates in spikes/second, otherwise.
tuning_curve(self, var_array, normalized=False, method='sum')
Calculate a firing-rate tuning curve with respect to some variable. Assumes that some variable, such as stimulus orientation, varies throughout the recording. The values taken by this variable should be supplied in a numpy array var_array. The spike train is binned according to the number of values in var_array, e.g., if there are N values, the spikes are binned with a bin width (self.t_stop-self.t_start)/N so that each bin is associated with a particular value of the variable in var_array.
The return value is a dictionary whose keys are the distinct values in val_array. The values in the dict depend on the arguments method and normalized.
If normalized is False, the responses (bin values) are spike counts, if True, they are firing rates. If method == "max", each value is the maximum response for a given value of the variable. If method == "sum", each value is the summed response... If method == "mean", ... you get the idea.
(If someone can rewrite this more clearly, please do so!)
