signals
- signals
- Data
-
Functions
- _test()
- check_dependency(name)
- check_numpy_version()
- get_display(display)
- load(user_file, datatype)
- load_conductancelist(user_file, id_list=None, dt=None, t_start=None, …
- load_currentlist(user_file, id_list=None, dt=None, t_start=None, …
- load_spikelist(user_file, id_list=None, t_start=None, t_stop=None, …
- load_vmlist(user_file, id_list=None, dt=None, t_start=None, t_stop=None, …
- set_axis_limits(subplot, xmin, xmax, ymin, ymax)
- set_labels(subplot, xlabel, ylabel)
- Classes
- AnalogSignal
- __getslice__(self, i, j)
- __init__(self, signal, dt, t_start=None, t_stop=None)
- __len__(self)
- copy(self)
- duration(self)
- event_triggered_average(self, events, average=True, t_min=0, t_max=100, …
- max(self)
- mean(self)
- min(self)
- plot(self, ylabel='Analog Signal', display=True, kwargs={})
- slice_by_events(self, events, t_min=100, t_max=100)
- threshold_detection(self, threshold=None, format=None)
- time_axis(self, normalized=False)
- time_offset(self, offset)
- time_parameters(self)
- time_slice(self, t_start, t_stop)
- AnalogSignalList
- __getitem__(self, id)
- __init__(self, signals, id_list, dt, t_start=None, t_stop=None, …
- __iter__(self)
- __len__(self)
- __setitem__(self, i, val)
- append(self, id, signal)
- convert(self, format='[values, ids]')
- copy(self)
- event_triggered_average(self, eventdict, events_ids=None, …
- id_list(self)
- id_offset(self, offset)
- id_slice(self, id_list)
- mean(self)
- raw_data(self)
- save(self, user_file)
- select_ids(self, criteria=None)
- std(self)
- time_axis(self)
- time_slice(self, t_start, t_stop)
- ConductanceList
- __getitem__(self, id)
- __init__(self, signals, id_list, dt, t_start=None, t_stop=None, …
- __iter__(self)
- __len__(self)
- __setitem__(self, i, val)
- append(self, id, signal)
- convert(self, format='[values, ids]')
- copy(self)
- event_triggered_average(self, eventdict, events_ids=None, …
- id_list(self)
- id_offset(self, offset)
- id_slice(self, id_list)
- mean(self)
- plot(self, id_list=None, v_thresh=None, display=True, kwargs={})
- raw_data(self)
- save(self, user_file)
- select_ids(self, criteria=None)
- std(self)
- time_axis(self)
- time_slice(self, t_start, t_stop)
- CurrentList
- __getitem__(self, id)
- __init__(self, signals, id_list, dt, t_start=None, t_stop=None, …
- __iter__(self)
- __len__(self)
- __setitem__(self, i, val)
- append(self, id, signal)
- convert(self, format='[values, ids]')
- copy(self)
- event_triggered_average(self, eventdict, events_ids=None, …
- id_list(self)
- id_offset(self, offset)
- id_slice(self, id_list)
- mean(self)
- plot(self, id_list=None, v_thresh=None, display=True, kwargs={})
- raw_data(self)
- save(self, user_file)
- select_ids(self, criteria=None)
- std(self)
- time_axis(self)
- time_slice(self, t_start, t_stop)
- DataHandler
- FileHandler
- SimpleMultiplot
- SpikeList
- __getitem__(self, id)
- __getslice__(self, i, j)
- __init__(self, spikes, id_list, t_start=None, t_stop=None, dims=None)
- __iter__(self)
- __len__(self)
- __select_with_pairs__(self, pairs, spk1, spk2)
- __setitem__(self, id, spktrain)
- activity_map(self, t_start=None, t_stop=None, float_positions=None, …
- activity_movie(self, time_bin=10, t_start=None, t_stop=None, …
- append(self, id, spktrain)
- concatenate(self, spklists)
- convert(self, format='[times, ids]', relative=False, quantized=False)
- copy(self)
- cv_isi(self, float_only=False)
- cv_isi_hist(self, bins=50, display=False, kwargs={})
- cv_kl(self, bins=50, float_only=False)
- cv_local(self, t_start=None, t_stop=None, length=12, step=6)
- distance_kreuz(self, pairs, spklist=None, dt=0.1)
- distance_victorpurpura(self, pairs, spklist=None, cost=0.5)
- f1f0_ratios(self, time_bin, f_stim)
- fano_factor(self, time_bin)
- fano_factors_isi(self)
- firing_rate(self, time_bin, display=False, kwargs={})
- first_spike_time(self)
- id2position(self, id)
- id_list(self)
- id_offset(self, offset)
- id_slice(self, id_list)
- isi(self)
- isi_hist(self, bins=50, display=False, kwargs={})
- last_spike_time(self)
- mean_rate(self, t_start=None, t_stop=None)
- mean_rate_covariance(self, spikelist, time_bin)
- mean_rate_std(self, t_start=None, t_stop=None)
- mean_rate_variance(self, time_bin)
- mean_rates(self, t_start=None, t_stop=None)
- merge(self, spikelist, relative=False)
- pairwise_cc(self, pairs, spklist=None, time_bin=1.0, averaged=False, …
- pairwise_cc_zero(self, pairs, spklist=None, time_bin=1.0, …
- pairwise_pearson_corrcoeff(self, pairs, spklist=None, time_bin=1.0)
- raster_plot(self, id_list=None, t_start=None, t_stop=None, display=True, …
- rate_distribution(self, nbins=25, normalize=True, display=False, …
- raw_data(self)
- save(self, user_file)
- select_ids(self, criteria=None)
- spike_histogram(self, time_bin, normalized=False, display=False, …
- time_axis(self, time_bin)
- time_offset(self, offset)
- time_parameters(self)
- time_slice(self, t_start, t_stop)
- SpikeTrain
- __getslice__(self, i, j)
- __init__(self, spike_times, t_start=None, t_stop=None)
- __len__(self)
- copy(self)
- cv_isi(self)
- cv_kl(self, bins=100)
- distance_kreuz(self, spktrain, dt=0.1)
- distance_victorpurpura(self, spktrain, cost)
- duration(self)
- f1f0_ratio(self, time_bin, f_stim)
- fano_factor_isi(self)
- format(self, relative=False, quantized=False)
- frequency_spectrum(self, time_bin)
- is_equal(self, spktrain)
- isi(self)
- mean_rate(self, t_start=None, t_stop=None)
- merge(self, spiketrain)
- raster_plot(self, t_start=None, t_stop=None, display=True, kwargs={})
- relative_times(self)
- time_axis(self, time_bin=10)
- time_histogram(self, time_bin=10, normalized=True)
- time_offset(self, offset)
- time_parameters(self)
- time_slice(self, t_start, t_stop)
- tuning_curve(self, var_array, normalized=False, method='sum')
- StandardPickleFile
- StandardTextFile
- VmList
- __getitem__(self, id)
- __init__(self, signals, id_list, dt, t_start=None, t_stop=None, …
- __iter__(self)
- __len__(self)
- __setitem__(self, i, val)
- append(self, id, signal)
- convert(self, format='[values, ids]')
- copy(self)
- event_triggered_average(self, eventdict, events_ids=None, …
- id_list(self)
- id_offset(self, offset)
- id_slice(self, id_list)
- mean(self)
- plot(self, id_list=None, v_thresh=None, display=True, kwargs={})
- raw_data(self)
- save(self, user_file)
- select_ids(self, criteria=None)
- std(self)
- time_axis(self)
- time_slice(self, t_start, t_stop)
- AnalogSignal
Data
DEFAULT_BUFFER_SIZE = 10000
ENABLE_PLOTS = True
__name__ = NeuroTools.signals
newnum = False
Functions
_test()
check_dependency(name)
check_numpy_version()
get_display(display)
Returns a pylab object with a plot() function to draw the plots.
Inputs: display - if True, a new figure is created. Otherwise, if display is a subplot object, this object is returned.
load(user_file, datatype)
Convenient data loader for results produced by pyNN. Return the corresponding NeuroTools object. Datatype argument may become optionnal in the future, but for now it is necessary to specify the type of the recorded data. To have a better control on the parameters of the NeuroTools objects, see the load_*** functions.
Inputs: user_file - the user_file object with read/write methods. By defaults, if a string is provided, a StandardTextFile object is created datatype - A string to specify the type od the data in 's' : spikes 'g' : conductances 'v' : membrane traces 'c' : currents
Examples:
load("simulation.dat",'v') load("spikes.dat",'s') load(StandardPickleFile("simulation.dat"), 'g') load(StandardTextFile("test.dat"), 's')
See also: load_spikelist, load_conductancelist, load_vmlist, load_currentlist
load_conductancelist(user_file, id_list=None, dt=None, t_start=None, t_stop=None, dims=None)
Returns TWO ConductanceList objects from a file. One for the excitatory and the other for the inhibitory conductance. If the file has been generated by PyNN, a header should be found with following parameters: ---> dims, dt, id of the first cell, id of the last cell. They must be specified otherwise. Then the classical PyNN format for text file is: ---> one line per event: data value, GID
Inputs: user_file - the user_file object with read/write methods. By defaults, if a string is provided, a StandardTextFile object is created id_list - the list of the recorded ids. Can be an int (meaning cells in the range (0,..,N)), or a list. dims - if the cells were aranged on a 2/3D grid, a tuple with the dimensions dt - the discretization step, in ms t_start - begining of the simulation, in ms. t_stop - end of the simulation, in ms
If dims, dt, t_start, t_stop or id_list are None, they will be infered from either the data or from the header. All times are in milliseconds. The format of the file (text, pickle or hdf5) will be inferred automatically
Examples:
gexc, ginh = load_conductancelist("mydata.dat")
load_currentlist(user_file, id_list=None, dt=None, t_start=None, t_stop=None, dims=None)
Returns a CurrentList object from a file. If the file has been generated by PyNN, a header should be found with following parameters: ---> dims, dt, id of the first cell, id of the last cell. They must be specified otherwise. Then the classical PyNN format for text file is: ---> one line per event: data value, GID
Inputs: user_file - the user_file object with read/write methods. By defaults, if a string is provided, a StandardTextFile object is created id_list - the list of the recorded ids. Can be an int (meaning cells in the range (0,..,N)), or a list. dims - if the cells were aranged on a 2/3D grid, a tuple with the dimensions dt - the discretization step, in ms t_start - begining of the simulation, in ms. t_stop - end of the simulation, in ms
If dims, dt, t_start, t_stop or id_list are None, they will be infered from either the data or from the header. All times are in milliseconds. The format of the file (text, pickle or hdf5) will be inferred automatically
load_spikelist(user_file, id_list=None, t_start=None, t_stop=None, dims=None)
Returns a SpikeList object from a file. If the file has been generated by PyNN, a header should be found with following parameters: ---> dims, dt, id of the first cell, id of the last cell. They must be specified otherwise. Then the classical PyNN format for text file is: ---> one line per event: absolute time in ms, GID
Inputs: user_file - the user_file object with read/write methods. By defaults, if a string is provided, a StandardTextFile object is created id_list - the list of the recorded ids. Can be an int (meaning cells in the range (0,..,N)), or a list. dims - if the cells were aranged on a 2/3D grid, a tuple with the dimensions t_start - begining of the simulation, in ms. t_stop - end of the simulation, in ms
If dims, t_start, t_stop or id_list are None, they will be infered from either the data or from the header. All times are in milliseconds. The format of the file (text, pickle) will be inferred automatically
load_vmlist(user_file, id_list=None, dt=None, t_start=None, t_stop=None, dims=None)
Returns a VmList object from a file. If the file has been generated by PyNN, a header should be found with following parameters: ---> dims, dt, id of the first cell, id of the last cell. They must be specified otherwise. Then the classical PyNN format for text file is: ---> one line per event: data value, GID
Inputs: user_file - the user_file object with read/write methods. By defaults, if a string is provided, a StandardTextFile object is created id_list - the list of the recorded ids. Can be an int (meaning cells in the range (0,..,N)), or a list. dims - if the cells were aranged on a 2/3D grid, a tuple with the dimensions dt - the discretization step, in ms t_start - begining of the simulation, in ms. t_stop - end of the simulation, in ms
If dims, dt, t_start, t_stop or id_list are None, they will be infered from either the data or from the header. All times are in milliseconds. The format of the file (text, pickle or hdf5) will be inferred automatically
set_axis_limits(subplot, xmin, xmax, ymin, ymax)
Defines the axis limits of a plot.
Inputs: subplot - the targeted plot xmin, xmax - the limits of the x axis ymin, ymax - the limits of the y axis
Example:
x = range(10) y = [] for i in x: y.append(i*i) pylab.plot(x,y) plotting.set_axis_limits(pylab, 0., 10., 0., 100.)
set_labels(subplot, xlabel, ylabel)
Defines the axis labels of a plot.
Inputs: subplot - the targeted plot xlabel - a string for the x label ylabel - a string for the y label
Example:
x = range(10) y = [] for i in x: y.append(i*i) pylab.plot(x,y) plotting.set_labels(pylab, 'x', 'y=x2')
Classes
AnalogSignal
AnalogSignal(signal, dt, t_start=None, t_stop=None)
Return a AnalogSignal object which will be a analog signal trace
Inputs: signal - the vector with the data of the AnalogSignal dt - the time step between two data points of the sampled analog signal t_start - begining of the signal, in ms. If None, will be set to 0 t_stop - end of the SpikeList, in ms. If None, will be infered from the data
Examples:
as = AnalogSignal(range(100), dt=0.1, t_start=0, t_stop=10)
See also AnalogSignalList, load_currentlist, load_vmlist, load_conductancelist, load
__getslice__(self, i, j)
Return a sublist of the signal vector of the AnalogSignal
__init__(self, signal, dt, t_start=None, t_stop=None)
__len__(self)
copy(self)
Return a copy of the AnalogSignal object
duration(self)
Return the duration of the SpikeTrain
event_triggered_average(self, events, average=True, t_min=0, t_max=100, display=False, kwargs={})
Return the spike triggered averaged of an analog signal according to selected events, on a time window t_spikes - tmin, t_spikes + tmax Can return either the averaged waveform (average = True), or an array of all the waveforms triggered by all the spikes.
Inputs: events - Can be a SpikeTrain object (and events will be the spikes) or just a list of times average - If True, return a single vector of the averaged waveform. If False, return an array of all the waveforms. t_min - Time (>0) to average the signal before an event, in ms (default 0) t_max - Time (>0) to average the signal after an event, in ms (default 100) display - if True, a new figure is created. Could also be a subplot. kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples:
vm.event_triggered_average(spktrain, average=False, t_min = 50, t_max = 150) vm.event_triggered_average(spktrain, average=True) vm.event_triggered_average(range(0,1000,10), average=False, display=True)
max(self)
mean(self)
min(self)
plot(self, ylabel='Analog Signal', display=True, kwargs={})
Plot the AnalogSignal
Inputs: ylabel - A string to sepcify the label on the yaxis. display - if True, a new figure is created. Could also be a subplot kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples:
z = subplot(221) signal.plot(ylabel="Vm", display=z, kwargs={'color':'r'})
slice_by_events(self, events, t_min=100, t_max=100)
Returns a dict containing new AnalogSignals coutout around events.
Inputs: events - Can be a SpikeTrain object (and events will be the spikes) or just a list of times t_min - Time (>0) to cut the signal before an event, in ms (default 100) t_max - Time (>0) to cut the signal after an event, in ms (default 100)
Examples:
res = aslist.slice_by_events([100,200,300], t_min=0, t_max =100) print len(res)
3
threshold_detection(self, threshold=None, format=None)
Returns the times when the analog signal crosses a threshold. The times can be returned as a numpy.array or a SpikeTrain object (default)
Inputs: threshold - Threshold format - when 'raw' the raw events array is returned, otherwise this is a SpikeTrain object by default
Examples:
aslist.threshold_detection(-55, 'raw')
[54.3, 197.4, 206]
time_axis(self, normalized=False)
Return the time axis of the AnalogSignal
time_offset(self, offset)
Add a time offset to the AnalogSignal object. t_start and t_stop are shifted from offset.
Inputs: offset - the time offset, in ms
Examples:
as = AnalogSignal(arange(0,100,0.1),0.1) as.t_stop
100
as.time_offset(1000) as.t_stop
1100
time_parameters(self)
Return the time parameters of the AnalogSignal (t_start, t_stop, dt)
time_slice(self, t_start, t_stop)
Return a new AnalogSignal obtained by slicing between t_start and t_stop
Inputs: t_start - begining of the new SpikeTrain, in ms. t_stop - end of the new SpikeTrain, in ms.
AnalogSignalList
AnalogSignalList(signals, id_list, dt=None, t_start=None, t_stop=None, dims=None)
Return a AnalogSignalList object which will be a list of AnalogSignal objects.
Inputs: signals - a list of the AnalogSignals objects id_list - the list of the ids of all recorded cells (needed for silent cells) dt - if dt is specified, time values should be floats t_start - begining of the SpikeList, in ms. If None, will be infered from the data t_stop - end of the SpikeList, in ms. If None, will be infered from the data dims - dimensions of the recorded population, if not 1D population
dt, t_start and t_stop are shared for all SpikeTrains object within the SpikeList
See also load_currentlist load_vmlist, load_conductancelist
__getitem__(self, id)
__init__(self, signals, id_list, dt, t_start=None, t_stop=None, dims=None)
__iter__(self)
__len__(self)
__setitem__(self, i, val)
append(self, id, signal)
Add an AnalogSignal object to the AnalogSignalList
Inputs: id - the id of the new cell signal - the AnalogSignal object representing the new cell
The AnalogSignal object is sliced according to the t_start and t_stop times of the AnalogSignallist object
See also __setitem__
convert(self, format='[values, ids]')
Return a new representation of the AnalogSignalList object, in a user designed format. format is an expression containing either the keywords values and ids, time and id.
Inputs: format - A template to generate the corresponding data representation, with the keywords values and ids
Examples:
aslist.convert("[values, ids]") will return a list of two elements, the
first one being the array of all the values, the second the array of all the corresponding ids, sorted by time
aslist.convert("[(value,id)]") will return a list of tuples (value, id)
copy(self)
Return a copy of the AnalogSignalList object
event_triggered_average(self, eventdict, events_ids=None, analogsignal_ids=None, average=True, t_min=0, t_max=100, ylim=None, display=False, mode='same', kwargs={})
Returns the event triggered averages of the analog signals inside the list. The events can be a SpikeList object or a dict containing times. The average is performed on a time window t_spikes - tmin, t_spikes + tmax Can return either the averaged waveform (average = True), or an array of all the waveforms triggered by all the spikes.
Inputs: events - Can be a SpikeList object (and events will be the spikes) or just a dict of times average - If True, return a single vector of the averaged waveform. If False, return an array of all the waveforms. mode - 'same': the average is only done on same ids --> return {'eventids':average}; 'all': for all ids in the eventdict the average from all ananlog signals is returned --> return {'eventids':{'analogsignal_ids':average}} t_min - Time (>0) to average the signal before an event, in ms (default 0) t_max - Time (>0) to average the signal after an event, in ms (default 100) events_ids - when given only perform average over these ids analogsignal_ids = when given only perform average on these ids display - if True, a new figure is created for each average. Could also be a subplot. ylim - ylim of the plot kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples
vmlist.event_triggered_average(spikelist, average=False, t_min = 50, t_max = 150, mode = 'same') vmlist.event_triggered_average(spikelist, average=True, mode = 'all') vmlist.event_triggered_average({'1':[200,300,'3':[234,788]]}, average=False, display=True)
id_list(self)
Return the list of all the cells ids contained in the SpikeList object
id_offset(self, offset)
Add an offset to the whole AnalogSignalList object. All the id are shifted with a offset value.
Inputs: offset - the id offset
Examples:
as.id_list()
[0,1,2,3,4]
as.id_offset(10) as.id_list()
[10,11,12,13,14]
id_slice(self, id_list)
Return a new AnalogSignalList obtained by selecting particular ids
Inputs: id_list - Can be an integer (and then N random cells will be selected) or a sublist of the current ids
The new AnalogSignalList inherits the time parameters (t_start, t_stop, dt)
See also time_slice
mean(self)
Return the mean AnalogSignal after having performed the average of all the signals present in the AnalogSignalList
Examples:
a.mean()
See also: std
raw_data(self)
Function to return a N by 2 array of all values and ids.
Examples:
spklist.raw_data() array([[ 1.00000000e+00, 1.00000000e+00],
[ 1.00000000e+00, 1.00000000e+00], [ 2.00000000e+00, 2.00000000e+00], ..., [ 2.71530000e+03, 2.76210000e+03]])
See also: convert()
save(self, user_file)
Save the AnalogSignal in a text or binary file
user_file - The user file that will have its own read/write method By default, if s tring is provided, a StandardTextFile object will be created. Nevertheless, you can also provide a StandardPickleFile Examples:
a.save("data.txt") a.save(StandardTextFile("data.txt")) a.save(StandardPickleFile("data.pck"))
select_ids(self, criteria=None)
Return the list of all the cells in the AnalogSignalList that will match the criteria expressed with the following syntax.
Inputs : criteria - a string that can be evaluated on a AnalogSignal object, where the AnalogSignal should be named cell.
Exemples:
aslist.select_ids("mean(cell.signal) > 20") aslist.select_ids("cell.std() < 0.2")
std(self)
Return the standard deviation along time between all the AnalogSignals contained in the AnalogSignalList
Examples:
a.std()
numpy.array([0.01, 0.2404, ...., 0.234, 0.234]
See also: mean
time_axis(self)
Return the time axis of the AnalogSignalList object
time_slice(self, t_start, t_stop)
Return a new AnalogSignalList obtained by slicing between t_start and t_stop
Inputs: t_start - begining of the new AnalogSignalList, in ms. t_stop - end of the new AnalogSignalList, in ms.
See also id_slice
ConductanceList
__getitem__(self, id)
__init__(self, signals, id_list, dt, t_start=None, t_stop=None, dims=None)
__iter__(self)
__len__(self)
__setitem__(self, i, val)
append(self, id, signal)
Add an AnalogSignal object to the AnalogSignalList
Inputs: id - the id of the new cell signal - the AnalogSignal object representing the new cell
The AnalogSignal object is sliced according to the t_start and t_stop times of the AnalogSignallist object
See also __setitem__
convert(self, format='[values, ids]')
Return a new representation of the AnalogSignalList object, in a user designed format. format is an expression containing either the keywords values and ids, time and id.
Inputs: format - A template to generate the corresponding data representation, with the keywords values and ids
Examples:
aslist.convert("[values, ids]") will return a list of two elements, the
first one being the array of all the values, the second the array of all the corresponding ids, sorted by time
aslist.convert("[(value,id)]") will return a list of tuples (value, id)
copy(self)
Return a copy of the AnalogSignalList object
event_triggered_average(self, eventdict, events_ids=None, analogsignal_ids=None, average=True, t_min=0, t_max=100, ylim=None, display=False, mode='same', kwargs={})
Returns the event triggered averages of the analog signals inside the list. The events can be a SpikeList object or a dict containing times. The average is performed on a time window t_spikes - tmin, t_spikes + tmax Can return either the averaged waveform (average = True), or an array of all the waveforms triggered by all the spikes.
Inputs: events - Can be a SpikeList object (and events will be the spikes) or just a dict of times average - If True, return a single vector of the averaged waveform. If False, return an array of all the waveforms. mode - 'same': the average is only done on same ids --> return {'eventids':average}; 'all': for all ids in the eventdict the average from all ananlog signals is returned --> return {'eventids':{'analogsignal_ids':average}} t_min - Time (>0) to average the signal before an event, in ms (default 0) t_max - Time (>0) to average the signal after an event, in ms (default 100) events_ids - when given only perform average over these ids analogsignal_ids = when given only perform average on these ids display - if True, a new figure is created for each average. Could also be a subplot. ylim - ylim of the plot kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples
vmlist.event_triggered_average(spikelist, average=False, t_min = 50, t_max = 150, mode = 'same') vmlist.event_triggered_average(spikelist, average=True, mode = 'all') vmlist.event_triggered_average({'1':[200,300,'3':[234,788]]}, average=False, display=True)
id_list(self)
Return the list of all the cells ids contained in the SpikeList object
id_offset(self, offset)
Add an offset to the whole AnalogSignalList object. All the id are shifted with a offset value.
Inputs: offset - the id offset
Examples:
as.id_list()
[0,1,2,3,4]
as.id_offset(10) as.id_list()
[10,11,12,13,14]
id_slice(self, id_list)
Return a new AnalogSignalList obtained by selecting particular ids
Inputs: id_list - Can be an integer (and then N random cells will be selected) or a sublist of the current ids
The new AnalogSignalList inherits the time parameters (t_start, t_stop, dt)
See also time_slice
mean(self)
Return the mean AnalogSignal after having performed the average of all the signals present in the AnalogSignalList
Examples:
a.mean()
See also: std
plot(self, id_list=None, v_thresh=None, display=True, kwargs={})
Plot all cells in the AnalogSignalList defined by id_list
Inputs: id_list - can be a integer (and then N cells are randomly selected) or a list of ids. If None, we use all the ids of the SpikeList display - if True, a new figure is created. Could also be a subplot kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples:
z = subplot(221) aslist.plot(5, display=z, kwargs={'color':'r'})
raw_data(self)
Function to return a N by 2 array of all values and ids.
Examples:
spklist.raw_data() array([[ 1.00000000e+00, 1.00000000e+00],
[ 1.00000000e+00, 1.00000000e+00], [ 2.00000000e+00, 2.00000000e+00], ..., [ 2.71530000e+03, 2.76210000e+03]])
See also: convert()
save(self, user_file)
Save the AnalogSignal in a text or binary file
user_file - The user file that will have its own read/write method By default, if s tring is provided, a StandardTextFile object will be created. Nevertheless, you can also provide a StandardPickleFile Examples:
a.save("data.txt") a.save(StandardTextFile("data.txt")) a.save(StandardPickleFile("data.pck"))
select_ids(self, criteria=None)
Return the list of all the cells in the AnalogSignalList that will match the criteria expressed with the following syntax.
Inputs : criteria - a string that can be evaluated on a AnalogSignal object, where the AnalogSignal should be named cell.
Exemples:
aslist.select_ids("mean(cell.signal) > 20") aslist.select_ids("cell.std() < 0.2")
std(self)
Return the standard deviation along time between all the AnalogSignals contained in the AnalogSignalList
Examples:
a.std()
numpy.array([0.01, 0.2404, ...., 0.234, 0.234]
See also: mean
time_axis(self)
Return the time axis of the AnalogSignalList object
time_slice(self, t_start, t_stop)
Return a new AnalogSignalList obtained by slicing between t_start and t_stop
Inputs: t_start - begining of the new AnalogSignalList, in ms. t_stop - end of the new AnalogSignalList, in ms.
See also id_slice
CurrentList
__getitem__(self, id)
__init__(self, signals, id_list, dt, t_start=None, t_stop=None, dims=None)
__iter__(self)
__len__(self)
__setitem__(self, i, val)
append(self, id, signal)
Add an AnalogSignal object to the AnalogSignalList
Inputs: id - the id of the new cell signal - the AnalogSignal object representing the new cell
The AnalogSignal object is sliced according to the t_start and t_stop times of the AnalogSignallist object
See also __setitem__
convert(self, format='[values, ids]')
Return a new representation of the AnalogSignalList object, in a user designed format. format is an expression containing either the keywords values and ids, time and id.
Inputs: format - A template to generate the corresponding data representation, with the keywords values and ids
Examples:
aslist.convert("[values, ids]") will return a list of two elements, the
first one being the array of all the values, the second the array of all the corresponding ids, sorted by time
aslist.convert("[(value,id)]") will return a list of tuples (value, id)
copy(self)
Return a copy of the AnalogSignalList object
event_triggered_average(self, eventdict, events_ids=None, analogsignal_ids=None, average=True, t_min=0, t_max=100, ylim=None, display=False, mode='same', kwargs={})
Returns the event triggered averages of the analog signals inside the list. The events can be a SpikeList object or a dict containing times. The average is performed on a time window t_spikes - tmin, t_spikes + tmax Can return either the averaged waveform (average = True), or an array of all the waveforms triggered by all the spikes.
Inputs: events - Can be a SpikeList object (and events will be the spikes) or just a dict of times average - If True, return a single vector of the averaged waveform. If False, return an array of all the waveforms. mode - 'same': the average is only done on same ids --> return {'eventids':average}; 'all': for all ids in the eventdict the average from all ananlog signals is returned --> return {'eventids':{'analogsignal_ids':average}} t_min - Time (>0) to average the signal before an event, in ms (default 0) t_max - Time (>0) to average the signal after an event, in ms (default 100) events_ids - when given only perform average over these ids analogsignal_ids = when given only perform average on these ids display - if True, a new figure is created for each average. Could also be a subplot. ylim - ylim of the plot kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples
vmlist.event_triggered_average(spikelist, average=False, t_min = 50, t_max = 150, mode = 'same') vmlist.event_triggered_average(spikelist, average=True, mode = 'all') vmlist.event_triggered_average({'1':[200,300,'3':[234,788]]}, average=False, display=True)
id_list(self)
Return the list of all the cells ids contained in the SpikeList object
id_offset(self, offset)
Add an offset to the whole AnalogSignalList object. All the id are shifted with a offset value.
Inputs: offset - the id offset
Examples:
as.id_list()
[0,1,2,3,4]
as.id_offset(10) as.id_list()
[10,11,12,13,14]
id_slice(self, id_list)
Return a new AnalogSignalList obtained by selecting particular ids
Inputs: id_list - Can be an integer (and then N random cells will be selected) or a sublist of the current ids
The new AnalogSignalList inherits the time parameters (t_start, t_stop, dt)
See also time_slice
mean(self)
Return the mean AnalogSignal after having performed the average of all the signals present in the AnalogSignalList
Examples:
a.mean()
See also: std
plot(self, id_list=None, v_thresh=None, display=True, kwargs={})
Plot all cells in the AnalogSignalList defined by id_list
Inputs: id_list - can be a integer (and then N cells are randomly selected) or a list of ids. If None, we use all the ids of the SpikeList display - if True, a new figure is created. Could also be a subplot kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples:
z = subplot(221) aslist.plot(5, display=z, kwargs={'color':'r'})
raw_data(self)
Function to return a N by 2 array of all values and ids.
Examples:
spklist.raw_data() array([[ 1.00000000e+00, 1.00000000e+00],
[ 1.00000000e+00, 1.00000000e+00], [ 2.00000000e+00, 2.00000000e+00], ..., [ 2.71530000e+03, 2.76210000e+03]])
See also: convert()
save(self, user_file)
Save the AnalogSignal in a text or binary file
user_file - The user file that will have its own read/write method By default, if s tring is provided, a StandardTextFile object will be created. Nevertheless, you can also provide a StandardPickleFile Examples:
a.save("data.txt") a.save(StandardTextFile("data.txt")) a.save(StandardPickleFile("data.pck"))
select_ids(self, criteria=None)
Return the list of all the cells in the AnalogSignalList that will match the criteria expressed with the following syntax.
Inputs : criteria - a string that can be evaluated on a AnalogSignal object, where the AnalogSignal should be named cell.
Exemples:
aslist.select_ids("mean(cell.signal) > 20") aslist.select_ids("cell.std() < 0.2")
std(self)
Return the standard deviation along time between all the AnalogSignals contained in the AnalogSignalList
Examples:
a.std()
numpy.array([0.01, 0.2404, ...., 0.234, 0.234]
See also: mean
time_axis(self)
Return the time axis of the AnalogSignalList object
time_slice(self, t_start, t_stop)
Return a new AnalogSignalList obtained by slicing between t_start and t_stop
Inputs: t_start - begining of the new AnalogSignalList, in ms. t_stop - end of the new AnalogSignalList, in ms.
See also id_slice
DataHandler
Class to establish the interface for loading/saving objects in NeuroTools
Inputs: filename - the user file for reading/writing data. By default, if this is string, a StandardTextFile is created object - the object to be saved. Could be a SpikeList or an AnalogSignalList
Examples:
txtfile = StandardTextFile("results.dat") DataHandler(txtfile) picklefile = StandardPickelFile("results.dat") DataHandler(picklefile)
__init__(self, user_file, object=None)
load_analogs(self, type, **params)
Read an AnalogSignalList object from a file and return the AnalogSignalList object of type type, created from the File and from the additional params that may have been provided
type can be in ["vm", "current", "conductance"]
Examples:
params = {'id_list' : range(100), 't_stop' : 1000} handler.load_analogs("vm", params)
VmList Object (with params taken into account)
handler.load_analogs("current", params)
CurrentList Object (with params taken into account)
See also AnalogSignalList, load_spikes
load_spikes(self, **params)
Function to load a SpikeList object from a file. The data type is automatically infered. Return a SpikeList object
Inputs: params - a dictionnary with all the parameters used by the SpikeList constructor
Examples:
params = {'id_list' : range(100), 't_stop' : 1000} handler.load_spikes(params)
SpikeList object
See also SpikeList, load_analogs
save(self)
Save the object defined in self.object with the method os self.user_file
Note that you can add your own format for I/O of such NeuroTools objects
FileHandler
Class to handle all the file read/write methods for the key objects of the signals class, i.e SpikeList and AnalogSignalList. Could be extented
This is an abstract class that will be implemented for each format (txt, pickle, hdf5) The key methods of the class are: write(object) - Write an object to a file read_spikes(params) - Read a SpikeList file with some params read_analogs(type, params) - Read an AnalogSignalList of type type with some params
Inputs: filename - the file name for reading/writing data
If you want to implement your own file format, you just have to create an object that will inherit from this FileHandler class and implement the previous functions. See io.py for more details
__init__(self, filename)
read_analogs(self, type, params)
Read an AnalogSignalList object from a file and return the AnalogSignalList object of type type, created from the File and from the additional params that may have been provided
type can be in ["vm", "current", "conductance"]
Examples:
params = {'id_list' : range(100), 't_stop' : 1000} handler.read_analogs("vm", params)
VmList Object (with params taken into account)
handler.read_analogs("current", params)
CurrentList Object (with params taken into account)
read_spikes(self, params)
Read a SpikeList object from a file and return the SpikeList object, created from the File and from the additional params that may have been provided
Examples:
params = {'id_list' : range(100), 't_stop' : 1000} handler.read_spikes(params)
SpikeList Object (with params taken into account)
write(self, object)
Write the object to the file.
Examples:
handler.write(SpikeListObject) handler.write(VmListObject)
SimpleMultiplot
A figure consisting of multiple panels, all with the same datatype and the same x-range.
__init__(self, nrows, ncolumns, title=, xlabel=None, ylabel=None, scaling=('linear', 'linear'))
finalise(self)
Adjustments to be made after all panels have been plotted.
next_panel(self)
Changes to next panel within figure.
panel(self, i)
Returns panel i.
save(self, filename)
Saves/prints the figure to file.
Inputs: filename - string specifying the filename where to save the data
set_frame(self, ax, boollist, linewidth=2)
Defines frames for the chosen axis.
Inputs: as - the targeted axis boollist - a list linewidth - the limits of the y axis
SpikeList
SpikeList(spikes, id_list, t_start=None, t_stop=None, dims=None)
Return a SpikeList object which will be a list of SpikeTrain objects.
Inputs: spikes - a list of (id,time) tuples (id being in id_list) id_list - the list of the ids of all recorded cells (needed for silent cells) t_start - begining of the SpikeList, in ms. If None, will be infered from the data t_stop - end of the SpikeList, in ms. If None, will be infered from the data dims - dimensions of the recorded population, if not 1D population
t_start and t_stop are shared for all SpikeTrains object within the SpikeList
Examples:
sl = SpikeList([(0, 0.1), (1, 0.1), (0, 0.2)], range(2)) type( sl[0] )
<type SpikeTrain>
See also load_spikelist
__getitem__(self, id)
__getslice__(self, i, j)
Return a new SpikeList object with all the ids between i and j
__init__(self, spikes, id_list, t_start=None, t_stop=None, dims=None)
Constructor of the SpikeList object
See also SpikeList, load_spikelist
__iter__(self)
__len__(self)
__select_with_pairs__(self, pairs, spk1, spk2)
Internal function used to slice two SpikeList according to a list of pairs. Return two SpikeTrains and the list of pairs
Inputs: pairs - can be an int (and then N random pairs are selected). Otherwise pairs is a list of tuple (id_cell1, id_cell2) spk1 - the first SpikeList to slice spk2 - the second SpikeList to slice
Examples:
self.__select_with_pairs__(50, spk1, spk2)
__setitem__(self, id, spktrain)
activity_map(self, t_start=None, t_stop=None, float_positions=None, display=False, kwargs={})
Generate a 2D map of the activity averaged between t_start and t_stop. If t_start and t_stop are not defined, we used those of the SpikeList object
Inputs: t_start - if not defined, the one of the SpikeList is used t_stop - if not defined, the one of the SpikeList is used float_positions - None by default, meaning that the dimensions attribute of the SpikeList is used to arange the ids on a 2D grid. Otherwise, if the cells have flotting positions, float_positions should be an array of size (2, nb_cells) with the x (first line) and y (second line) coordinates of the cells display - if True, a new figure is created. Could also be a subplot. The averaged spike_histogram over the whole population is then plotted kwargs - dictionary contening extra parameters that will be sent to the plot function
The 'dimensions' attribute of the SpikeList is used to turn ids into 2d positions. It should therefore be not empty.
Examples:
spklist.activity_map(0,1000,display=True)
See also activity_movie
activity_movie(self, time_bin=10, t_start=None, t_stop=None, float_positions=None, output='animation.mpg', bounds=(0, 5), fps=10, display=True, kwargs={})
Generate a movie of the activity between t_start and t_stop. If t_start and t_stop are not defined, we used those of the SpikeList object
Inputs: time_bin - time step to bin activity during the movie. One frame is the mean rate during time_bin t_start - if not defined, the one of the SpikeList is used, in ms t_stop - if not defined, the one of the SpikeList is used, in ms float_positions - None by default, meaning that the dimensions attribute of the SpikeList is used to arange the ids on a 2D grid. Otherwise, if the cells have flotting positions, float_positions should be an array of size (2, nb_cells) with the x (first line) and y (second line) coordinates of the cells output - The filename to store the movie bounds - The common color bounds used during all the movies frame. This is a tuple of values (min, max), in spikes per frame. fps - The number of frame per second in the final movie display - if True, a new figure is created. Could also be a subplot. kwargs - dictionary contening extra parameters that will be sent to the plot function
The 'dimensions' attribute of the SpikeList is used to turn ids into 2d positions. It should therefore be not empty.
Examples:
spklist.activity_movie(10,0,1000,bounds=(0,5),display=subplot(221),output="test.mpg")
See also activity_map
append(self, id, spktrain)
Add a SpikeTrain object to the SpikeList
Inputs: id - the id of the new cell spktrain - the SpikeTrain object representing the new cell
The SpikeTrain object is sliced according to the t_start and t_stop times of the SpikeLlist object
Examples
st=SpikeTrain(range(0,100,5),0.1,0,100) spklist.append(999, st)
spklist[999]
See also concatenate, __setitem__
concatenate(self, spklists)
Concatenation of SpikeLists to the current SpikeList.
Inputs: spklists - could be a single SpikeList or a list of SpikeLists
The concatenated SpikeLists must have similar (t_start, t_stop), and they can't shared similar cells. All their ids have to be different.
See also append, merge, __setitem__
convert(self, format='[times, ids]', relative=False, quantized=False)
Return a new representation of the SpikeList object, in a user designed format. format is an expression containing either the keywords times and ids, time and id.
Inputs: relative - a boolean to say if a relative representation of the spikes times compared to t_start is needed quantized - a boolean to round the spikes_times.
Examples:
spk.convert("[times, ids]") will return a list of two elements, the
first one being the array of all the spikes, the second the array of all the corresponding ids
spk.convert("[(time,id)]") will return a list of tuples (time, id)
See also SpikeTrain.format
copy(self)
Return a copy of the SpikeList object
cv_isi(self, float_only=False)
Return the list of all the CV coefficients for each SpikeTrains object within the SpikeList. Return NaN when not enough spikes are present
Inputs: float_only - False by default. If true, NaN values are automatically removed
Examples:
spklist.cv_isi()
[0.2,0.3,Nan,2.5,Nan,1.,2.5]
spklist.cv_isi(True)
[0.2,0.3,2.5,1.,2.5]
See also: cv_isi_hist, cv_local, cv_kl, SpikeTrain.cv_isi
cv_isi_hist(self, bins=50, display=False, kwargs={})
Return the histogram of the cv coefficients.
Inputs: bins - the number of bins (between the min and max of the data) or a list/array containing the lower edges of the bins. display - if True, a new figure is created. Could also be a subplot kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples:
z = subplot(221) spklist.cv_isi_hist(10, display=z, kwargs={'color':'r'})
See also: cv_isi, cv_local, cv_kl
cv_kl(self, bins=50, float_only=False)
Return the list of all the CV coefficients for each SpikeTrains object within the SpikeList. Return NaN when not enough spikes are present
Inputs: bins - The number of bins used to gathered the ISI float_only - False by default. If true, NaN values are automatically removed
Examples:
spklit.cv_kl(50)
[0.4, Nan, 0.9, nan]
spklist.cv_kl(50, True)
[0.4, 0.9]
See also: cv_isi_hist, cv_local, cv_isi, SpikeTrain.cv_kl
cv_local(self, t_start=None, t_stop=None, length=12, step=6)
Provides a modified version of the coefficient of variation, a measure that describes the regularity of spiking neurons/networks. This CV is local in time, i.e., it considers the isi variance for consecutive inter-spike-intervals, and is then averaged over a certain window in time (1/12 length), which is shifted in time (1/6 step). Therefore rate changes and/or bimodal isi distributions do not lead to an exceptionally high CV.
Inputs: t_start - The time to start the averaging t_stop - The time to stop the averaging length - A factor to determine the window length for the average, The window considered will be (t_stop-t_start)/length. 12 by default time_bin - factor to determin the step size for its shifting.
Examples:
spklist.cv_local(0, 1000, 12, 10)
See also cv_isi, cv_isi_hist, cv_kl
distance_kreuz(self, pairs, spklist=None, dt=0.1)
Function to calculate the Kreuz/Politi distance between two spike trains See Kreuz, T.; Haas, J.S.; Morelli, A.; Abarbanel, H.D.I. & Politi, A. Measuring spike train synchrony. J Neurosci Methods, 2007, 165, 151-161
Inputs: pairs - Could be an int, and then N random pairs will be selected, or it could be a list of tuple (id cell_1, id cell_2) spklist - The other SpikeList object where cells should be taken. By default, if None, this is the one calling the function dt - The time bin used to discretized the spike times
distance_victorpurpura(self, pairs, spklist=None, cost=0.5)
Function to calculate the Victor-Purpura distance averaged over N pairs in the SpikeList See J. D. Victor and K. P. Purpura, Nature and precision of temporal coding in visual cortex: a metric-space analysis., J Neurophysiol,76(2):1310-1326, 1996
Inputs: pairs - Could be an int, and then N random pairs will be selected, or it could be a list of tuple (id cell_1, id cell_2) spklist - The other SpikeList object where cells should be taken. By default, if None, this is the one calling the function cost - The cost parameter. See the paper for more informations. BY default, set to 0.5
f1f0_ratios(self, time_bin, f_stim)
Returns the F1/F0 amplitude ratios for the spike trains contained in the spike list, where the input stimulus frequency is f_stim.
fano_factor(self, time_bin)
Compute the Fano Factor of the population activity.
Inputs: time_bin - the number of bins (between the min and max of the data) or a list/array containing the lower edges of the bins.
The Fano Factor is computed as the variance of the averaged activity divided by its mean
See also spike_histogram, firing_rate
fano_factors_isi(self)
Return a list containing the fano factors for each neuron
See also isi, isi_cv
firing_rate(self, time_bin, display=False, kwargs={})
Generate an array with all the instantaneous firing rates along time (in Hz) of all the SpikeTrains objects within the SpikeList.
Inputs: time_bin - the time bin used to gather the data display - if True, a new figure is created. Could also be a subplot. The averaged spike_histogram over the whole population is then plotted kwargs - dictionary contening extra parameters that will be sent to the plot function
See also spike_histogram, time_axis
first_spike_time(self)
Get the time of the first real spike in the SpikeList
id2position(self, id)
Return a position (x,y) from an id if the cells are aranged on a grid of size dims, as defined in the dims attribute of the SpikeList object
Inputs: id - the id of the cell
The 'dimensions' attribute of the SpikeList must be defined
See also activity_map, activity_movie
id_list(self)
Return the list of all the cells ids contained in the SpikeList object
Examples
spklist.id_list()
[0,1,2,3,....,9999]
id_offset(self, offset)
Add an offset to the whole SpikeList object. All the id are shifted according to an offset value.
Inputs: offset - the id offset
Examples:
spklist.id_list()
[0,1,2,3,4]
spklist.id_offset(10) spklist.id_list()
[10,11,12,13,14]
id_slice(self, id_list)
Return a new SpikeList obtained by selecting particular ids
Inputs: id_list - Can be an integer (and then N random cells will be selected) or a sublist of the current ids
The new SpikeList inherits the time parameters (t_start, t_stop)
Examples:
spklist.id_list()
[830, 1959, 1005, 416, 1011, 1240, 729, 59, 1138, 259]
new_spklist = spklist.id_slice(5) new_spklist.id_list()
[1011, 729, 1138, 416, 59]
See also time_slice
isi(self)
Return the list of all the isi vectors for all the SpikeTrains objects within the SpikeList.
See also: isi_hist
isi_hist(self, bins=50, display=False, kwargs={})
Return the histogram of the ISI.
Inputs: bins - the number of bins (between the min and max of the data) or a list/array containing the lower edges of the bins. display - if True, a new figure is created. Could also be a subplot kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples:
z = subplot(221) spklist.isi_hist(10, display=z, kwargs={'color':'r'})
See also: isi
last_spike_time(self)
Get the time of the last real spike in the SpikeList
mean_rate(self, t_start=None, t_stop=None)
Return the mean firing rate averaged accross all SpikeTrains between t_start and t_stop.
Inputs: t_start - begining of the selected area to compute mean_rate, in ms t_stop - end of the selected area to compute mean_rate, in ms
If t_start or t_stop are not defined, those of the SpikeList are used
Examples:
spklist.mean_rate() 12.63
See also mean_rates, mean_rate_std
mean_rate_covariance(self, spikelist, time_bin)
Return the covariance of the firing rate along time, if events are binned with a time bin.
Inputs: spikelist - the other spikelist to compute covariance time_bin - time bin to bin events
See also mean_rate, mean_rates, mean_rate_variance, firing_rate
mean_rate_std(self, t_start=None, t_stop=None)
Standard deviation of the firing rates accross all SpikeTrains between t_start and t_stop
Inputs: t_start - begining of the selected area to compute std(mean_rate), in ms t_stop - end of the selected area to compute std(mean_rate), in ms
If t_start or t_stop are not defined, those of the SpikeList are used
Examples:
spklist.mean_rate_std() 13.25
See also mean_rate, mean_rates
mean_rate_variance(self, time_bin)
Return the standard deviation of the firing rate along time, if events are binned with a time bin.
Inputs: time_bin - time bin to bin events
See also mean_rate, mean_rates, mean_rate_covariance, firing_rate
mean_rates(self, t_start=None, t_stop=None)
Returns a vector of the size of id_list giving the mean firing rate for each neuron
Inputs: t_start - begining of the selected area to compute std(mean_rate), in ms t_stop - end of the selected area to compute std(mean_rate), in ms
If t_start or t_stop are not defined, those of the SpikeList are used
See also mean_rate, mean_rate_std
merge(self, spikelist, relative=False)
For each cell id in spikelist that matches an id in this SpikeList, merge the two SpikeTrains and save the result in this SpikeList. Note that SpikeTrains with ids not in this SpikeList are appended to it.
Inputs: spikelist - the SpikeList that should be merged to the current one relative - if True, spike times are expressed in a relative time compared to the previsous one
Examples:
spklist.merge(spklist2)
See also: concatenate, append, __setitem__
pairwise_cc(self, pairs, spklist=None, time_bin=1.0, averaged=False, display=False, kwargs={})
Function to generate an array of cross correlations computed between pairs of cells within the SpikeTrains.
Inputs: pairs - Could be an int, and then N random pairs of cells will be selected, or it could be a list of tuple (id cell_1, id cell_2) time_bin - The time bin used to gather the spikes spklist - The other SpikeList object where cells should be taken. By default, if None, this is the one calling the function averaged - If true, only the averaged CC among all the pairs is returned (less memory needed) display - if True, a new figure is created. Could also be a subplot. The averaged spike_histogram over the whole population is then plotted kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples
a.pairwise_cc(500, time_bin=1, averaged=True) a.pairwise_cc(500, time_bin=1, averaged=True, display=subplot(221), kwargs={'color':'r'}) a.pairwise_cc([(i,i+1) for i in xrange(100)],spklist, time_bin=5)
See also pairwise_pearson_corrcoeff, pairwise_cc_zero
pairwise_cc_zero(self, pairs, spklist=None, time_bin=1.0, time_window=None, display=False, kwargs={})
Function to return the normalized cross correlation coefficient at zero time lag according to the method given in: See A. Aertsen et al, Dynamics of neuronal firing correlation: modulation of effective connectivity J Neurophysiol, 61:900-917, 1989
The coefficient is averaged over N pairs of cells. If time window is specified, compute the corr coeff on a sliding window, and therefore returns not a value but a vector.
Inputs: pairs - Could be an int, and then N random pairs of cells will be selected, or it could be a list of tuple (id cell_1, id cell_2) spklist - The other SpikeList object where cells should be taken. By default, if None, this is the one calling the function time_bin - The time bin used to gather the spikes time_window - None by default, and then a single number, the normalized CC is returned. If this is a float, then size (in ms) of the sliding window used to compute the normalized cc. A Vector is then returned display - if True, a new figure is created. Could also be a subplot. The averaged spike_histogram over the whole population is then plotted kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples:
a.pairwise_cc_zero(100, time_bin=1)
1.0
a.pairwise_cc_zero([(i,i+1) for i in xrange(100)], time_bin=1)
0.45
a.pairwise_cc_zero(100, time_bin=5, time_window=10, display=True)
See also: pairwise_cc, pairwise_pearson_corrcoeff
pairwise_pearson_corrcoeff(self, pairs, spklist=None, time_bin=1.0)
Function to return the mean and the variance of the pearson correlation coefficient. For more details, see Kumar et al, ....
Inputs: pairs - An int, and then N random pairs of cells will be selected, or a list of tuples (id_cell1, id_cell2) time_bin - The time bin used to gather the spikes spklist - The other SpikeList object where cells should be taken. By default, if None, this is the one calling the function
Examples
spk.pairwise_pearson_corrcoeff(50, time_bin=5)
(0.234, 0.0087)
See also pairwise_cc, pairwise_cc_zero
raster_plot(self, id_list=None, t_start=None, t_stop=None, display=True, kwargs={})
Generate a raster plot for the SpikeList in a subwindow of interest, defined by id_list, t_start and t_stop.
Inputs: id_list - can be a integer (and then N cells are randomly selected) or a list of ids. If None, we use all the ids of the SpikeList t_start - in ms. If not defined, the one of the SpikeList object is used t_stop - in ms. If not defined, the one of the SpikeList object is used display - if True, a new figure is created. Could also be a subplot kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples:
z = subplot(221) spikelist.raster_plot(display=z, kwargs={'color':'r'})
See also SpikeTrain.raster_plot
rate_distribution(self, nbins=25, normalize=True, display=False, kwargs={})
Return a vector with all the mean firing rates for all SpikeTrains.
Inputs: bins - the number of bins (between the min and max of the data) or a list/array containing the lower edges of the bins. display - if True, a new figure is created. Could also be a subplot kwargs - dictionary contening extra parameters that will be sent to the plot function
See also mean_rate, mean_rates
raw_data(self)
Function to return a N by 2 array of all times and ids.
Examples:
spklist.raw_data() array([[ 1.00000000e+00, 1.00000000e+00],
[ 1.00000000e+00, 1.00000000e+00], [ 2.00000000e+00, 2.00000000e+00], ..., [ 2.71530000e+03, 2.76210000e+03]])
See also: convert()
save(self, user_file)
Save the SpikeList in a text or binary file
Inputs: user_file - The user file that will have its own read/write method By default, if s tring is provided, a StandardTextFile object will be created. Nevertheless, you can also provide a StandardPickleFile
Examples:
spk.save("spikes.txt") spk.save(StandardTextFile("spikes.txt")) spk.save(StandardPickleFile("spikes.pck"))
See also: DataHandler
select_ids(self, criteria=None)
Return the list of all the cells in the SpikeList that will match the criteria expressed with the following syntax.
Inputs : criteria - a string that can be evaluated on a SpikeTrain object, where the SpikeTrain should be named cell.
Exemples:
spklist.select_ids("cell.mean_rate() > 0") (all the active cells) spklist.select_ids("cell.mean_rate() == 0") (all the silent cells) spklist.select_ids("len(cell.spike_times) > 10") spklist.select_ids("mean(cell.isi()) < 1")
spike_histogram(self, time_bin, normalized=False, display=False, kwargs={})
Generate an array with all the spike_histograms of all the SpikeTrains objects within the SpikeList.
Inputs: time_bin - the time bin used to gather the data normalized - if True, the histogram are in Hz (spikes/second), otherwise they are in spikes/bin display - if True, a new figure is created. Could also be a subplot. The averaged spike_histogram over the whole population is then plotted kwargs - dictionary contening extra parameters that will be sent to the plot function
See also firing_rate, time_axis
time_axis(self, time_bin)
Return a time axis between t_start and t_stop according to a time_bin
Inputs: time_bin - the bin width
See also spike_histogram
time_offset(self, offset)
Add an offset to the whole SpikeList object. t_start and t_stop are shifted from offset, so does all the SpikeTrain.
Inputs: offset - the time offset, in ms
Examples:
spklist.t_start
1000
spklist.time_offset(50) spklist.t_start
1050
time_parameters(self)
Return the time parameters of the SpikeList (t_start, t_stop)
time_slice(self, t_start, t_stop)
Return a new SpikeList obtained by slicing between t_start and t_stop
Inputs: t_start - begining of the new SpikeTrain, in ms. t_stop - end of the new SpikeTrain, in ms.
See also id_slice
SpikeTrain
SpikeTrain(spikes_times, t_start=None, t_stop=None) This class defines a spike train as a list of times events.
Event times are given in a list (sparse representation) in milliseconds.
Inputs: spike_times - a list/numpy array of spike times (in milliseconds) t_start - beginning of the SpikeTrain (if not, this is infered) t_stop - end of the SpikeTrain (if not, this is infered)
Examples:
s1 = SpikeTrain([0.0, 0.1, 0.2, 0.5]) s1.isi()
array([ 0.1, 0.1, 0.3])
s1.mean_rate()
8.0
s1.cv_isi()
0.565685424949
__getslice__(self, i, j)
Return a sublist of the spike_times vector of the SpikeTrain
__init__(self, spike_times, t_start=None, t_stop=None)
Constructor of the SpikeTrain object
See also SpikeTrain
__len__(self)
copy(self)
Return a copy of the SpikeTrain object
cv_isi(self)
Return the coefficient of variation of the isis.
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.
See also isi, cv_kl
cv_kl(self, bins=100)
Provides a measure for the coefficient of variation to describe the regularity in spiking networks. It is based on the Kullback-Leibler divergence and decribes the difference between a given interspike-interval-distribution and an exponential one (representing poissonian spike trains) with equal mean. It yields 1 for poissonian spike trains and 0 for regular ones.
Reference: http://incm.cnrs-mrs.fr/!LaurentPerrinet/Publications/Voges08fens
Inputs: bins - the number of bins used to gather the ISI
Examples:
spklist.cv_kl(100)
0.98
See also: cv_isi
distance_kreuz(self, spktrain, dt=0.1)
Function to calculate the Kreuz/Politi distance between two spike trains See Kreuz, T.; Haas, J.S.; Morelli, A.; Abarbanel, H.D.I. & Politi, A. Measuring spike train synchrony. J Neurosci Methods, 165:151-161, 2007
Inputs: spktrain - the other SpikeTrain dt - the bin width used to discretize the spike times
Examples:
spktrain.KreuzDistance(spktrain2)
See also VictorPurpuraDistance
distance_victorpurpura(self, spktrain, cost)
Function to calculate the Victor-Purpura distance between two spike trains. See J. D. Victor and K. P. Purpura, Nature and precision of temporal coding in visual cortex: a metric-space analysis., J Neurophysiol,76(2):1310-1326, 1996
Inputs: spktrain - the other SpikeTrain cost - The cost parameter. See the paper for more informations
duration(self)
Return the duration of the SpikeTrain
f1f0_ratio(self, time_bin, f_stim)
Returns the F1/F0 amplitude ratio where the input stimulus frequency is f_stim.
fano_factor_isi(self)
Return the fano factor of this spike trains ISI.
The Fano Factor is defined as the variance of the isi divided by the mean of the isi
See also isi, cv_isi
format(self, relative=False, quantized=False)
Return an array with a new representation of the spike times
Inputs: relative - if True, spike times are expressed in a relative time compared to the previsous one quantized - a value to divide spike times with before rounding
Examples:
st.spikes_times=[0, 2.1, 3.1, 4.4] st.format(relative=True)
[0, 2.1, 1, 1.3]
st.format(quantized=2)
[0, 1, 2, 2]
frequency_spectrum(self, time_bin)
Returns the frequency spectrum of the time histogram together with the frequency axis.
is_equal(self, spktrain)
Return True if the SpikeTrain object is equal to one other SpikeTrain, i.e if they have same time parameters and same spikes_times
Inputs: spktrain - A SpikeTrain object
See also: time_parameters()
isi(self)
Return an array with the inter-spike intervals of the SpikeTrain
Examples:
st.spikes_times=[0, 2.1, 3.1, 4.4] st.isi()
[2.1, 1., 1.3]
See also cv_isi
mean_rate(self, t_start=None, t_stop=None)
Returns the mean firing rate between t_start and t_stop, in Hz
Inputs: t_start - in ms. If not defined, the one of the SpikeTrain object is used t_stop - in ms. If not defined, the one of the SpikeTrain object is used
Examples:
spk.mean_rate()
34.2
merge(self, spiketrain)
Add the spike times from a spiketrain to the current SpikeTrain
Inputs: spiketrain - The SpikeTrain that should be added
Examples:
a = SpikeTrain(range(0,100,10),0.1,0,100) b = SpikeTrain(range(400,500,10),0.1,400,500) a.merge(b) a.spike_times
[ 0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 400., 410., 420., 430., 440., 450., 460., 470., 480., 490.]
a.t_stop
500
raster_plot(self, t_start=None, t_stop=None, display=True, kwargs={})
Generate a raster plot with the SpikeTrain in a subwindow of interest, defined by t_start and t_stop.
Inputs: t_start - in ms. If not defined, the one of the SpikeTrain object is used t_stop - in ms. If not defined, the one of the SpikeTrain object is used display - if True, a new figure is created. Could also be a subplot kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples:
z = subplot(221) st.raster_plot(display=z, kwargs={'color':'r'})
See also SpikeList.raster_plot
relative_times(self)
Rescale the spike times to make them relative to t_start.
Note that the SpikeTrain object itself is modified, t_start is substracted to spike_times, t_start and t_stop
time_axis(self, time_bin=10)
Return a time axis between t_start and t_stop according to a time_bin
Inputs: time_bin - the bin width
Examples:
st = SpikeTrain(range(100),0.1,0,100) st.time_axis(10)
[ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90n 100]
See also time_histogram
time_histogram(self, time_bin=10, 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.
Inputs: time_bin - the bin width for gathering spikes_times normalized - if True, the bin values are scaled to represent firing rates in spikes/second, otherwise otherwise it's the number of spikes per bin.
Examples:
st=SpikeTrain(range(0,100,5),0.1,0,100) st.time_histogram(10)
[200, 200, 200, 200, 200, 200, 200, 200, 200, 200]
st.time_histogram(10, normalized=False)
[2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
See also time_axis
time_offset(self, offset)
Add an offset to the SpikeTrain object. t_start and t_stop are shifted from offset, so does all the spike times.
Inputs: offset - the time offset, in ms
Examples:
spktrain = SpikeTrain(arange(0,100,10)) spktrain.time_offset(50) spklist.spike_times
[ 50., 60., 70., 80., 90., 100., 110., 120., 130., 140.]
time_parameters(self)
Return the time parameters of the SpikeTrain (t_start, t_stop)
time_slice(self, t_start, t_stop)
Return a new SpikeTrain obtained by slicing between t_start and t_stop. The new t_start and t_stop values of the returned SpikeTrain are the one given as arguments
Inputs: t_start - begining of the new SpikeTrain, in ms. t_stop - end of the new SpikeTrain, in ms.
Examples:
spk = spktrain.time_slice(0,100) spk.t_start
0
spk.t_stop
100
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!)
StandardPickleFile
__init__(self, filename)
read_analogs(self, type, params)
read_spikes(self, params)
write(self, object)
StandardTextFile
__init__(self, filename)
get_data(self, sepchar='\t', skipchar='#')
Load data from a text file and returns a list of data
read_analogs(self, type, params)
read_spikes(self, params)
write(self, object)
VmList
__getitem__(self, id)
__init__(self, signals, id_list, dt, t_start=None, t_stop=None, dims=None)
__iter__(self)
__len__(self)
__setitem__(self, i, val)
append(self, id, signal)
Add an AnalogSignal object to the AnalogSignalList
Inputs: id - the id of the new cell signal - the AnalogSignal object representing the new cell
The AnalogSignal object is sliced according to the t_start and t_stop times of the AnalogSignallist object
See also __setitem__
convert(self, format='[values, ids]')
Return a new representation of the AnalogSignalList object, in a user designed format. format is an expression containing either the keywords values and ids, time and id.
Inputs: format - A template to generate the corresponding data representation, with the keywords values and ids
Examples:
aslist.convert("[values, ids]") will return a list of two elements, the
first one being the array of all the values, the second the array of all the corresponding ids, sorted by time
aslist.convert("[(value,id)]") will return a list of tuples (value, id)
copy(self)
Return a copy of the AnalogSignalList object
event_triggered_average(self, eventdict, events_ids=None, analogsignal_ids=None, average=True, t_min=0, t_max=100, ylim=None, display=False, mode='same', kwargs={})
Returns the event triggered averages of the analog signals inside the list. The events can be a SpikeList object or a dict containing times. The average is performed on a time window t_spikes - tmin, t_spikes + tmax Can return either the averaged waveform (average = True), or an array of all the waveforms triggered by all the spikes.
Inputs: events - Can be a SpikeList object (and events will be the spikes) or just a dict of times average - If True, return a single vector of the averaged waveform. If False, return an array of all the waveforms. mode - 'same': the average is only done on same ids --> return {'eventids':average}; 'all': for all ids in the eventdict the average from all ananlog signals is returned --> return {'eventids':{'analogsignal_ids':average}} t_min - Time (>0) to average the signal before an event, in ms (default 0) t_max - Time (>0) to average the signal after an event, in ms (default 100) events_ids - when given only perform average over these ids analogsignal_ids = when given only perform average on these ids display - if True, a new figure is created for each average. Could also be a subplot. ylim - ylim of the plot kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples
vmlist.event_triggered_average(spikelist, average=False, t_min = 50, t_max = 150, mode = 'same') vmlist.event_triggered_average(spikelist, average=True, mode = 'all') vmlist.event_triggered_average({'1':[200,300,'3':[234,788]]}, average=False, display=True)
id_list(self)
Return the list of all the cells ids contained in the SpikeList object
id_offset(self, offset)
Add an offset to the whole AnalogSignalList object. All the id are shifted with a offset value.
Inputs: offset - the id offset
Examples:
as.id_list()
[0,1,2,3,4]
as.id_offset(10) as.id_list()
[10,11,12,13,14]
id_slice(self, id_list)
Return a new AnalogSignalList obtained by selecting particular ids
Inputs: id_list - Can be an integer (and then N random cells will be selected) or a sublist of the current ids
The new AnalogSignalList inherits the time parameters (t_start, t_stop, dt)
See also time_slice
mean(self)
Return the mean AnalogSignal after having performed the average of all the signals present in the AnalogSignalList
Examples:
a.mean()
See also: std
plot(self, id_list=None, v_thresh=None, display=True, kwargs={})
Plot all cells in the AnalogSignalList defined by id_list
Inputs: id_list - can be a integer (and then N cells are randomly selected) or a list of ids. If None, we use all the ids of the SpikeList v_thresh- For graphical purpose, plot a spike when Vm > V_thresh. If None, just plot the raw Vm display - if True, a new figure is created. Could also be a subplot kwargs - dictionary contening extra parameters that will be sent to the plot function
Examples:
z = subplot(221) aslist.plot(5, v_thresh = -50, display=z, kwargs={'color':'r'})
raw_data(self)
Function to return a N by 2 array of all values and ids.
Examples:
spklist.raw_data() array([[ 1.00000000e+00, 1.00000000e+00],
[ 1.00000000e+00, 1.00000000e+00], [ 2.00000000e+00, 2.00000000e+00], ..., [ 2.71530000e+03, 2.76210000e+03]])
See also: convert()
save(self, user_file)
Save the AnalogSignal in a text or binary file
user_file - The user file that will have its own read/write method By default, if s tring is provided, a StandardTextFile object will be created. Nevertheless, you can also provide a StandardPickleFile Examples:
a.save("data.txt") a.save(StandardTextFile("data.txt")) a.save(StandardPickleFile("data.pck"))
select_ids(self, criteria=None)
Return the list of all the cells in the AnalogSignalList that will match the criteria expressed with the following syntax.
Inputs : criteria - a string that can be evaluated on a AnalogSignal object, where the AnalogSignal should be named cell.
Exemples:
aslist.select_ids("mean(cell.signal) > 20") aslist.select_ids("cell.std() < 0.2")
std(self)
Return the standard deviation along time between all the AnalogSignals contained in the AnalogSignalList
Examples:
a.std()
numpy.array([0.01, 0.2404, ...., 0.234, 0.234]
See also: mean
time_axis(self)
Return the time axis of the AnalogSignalList object
time_slice(self, t_start, t_stop)
Return a new AnalogSignalList obtained by slicing between t_start and t_stop
Inputs: t_start - begining of the new AnalogSignalList, in ms. t_stop - end of the new AnalogSignalList, in ms.
See also id_slice

