Spikes¶

Spikes is responsible for locating spikes in a voltage trace, and is a container for all spikes found. Each spike is stored in a Spike object. Spikes is used in SpikingFeatures

API Reference¶

Spikes¶

class uncertainpy.features.Spikes(time=None, V=None, threshold=-30, end_threshold=-10, extended_spikes=False, trim=True, normalize=False, min_amplitude=0, min_duration=0, xlabel=u'', ylabel=u'')[source]

Finds spikes in the given voltage trace and is a container for the resulting Spike objects.

Parameters: time (array_like) – The time of the voltage trace. V (array_like) – The voltage trace. threshold ({int, float, “auto”}) – The threshold for what is considered a spike. If the voltage trace rise above and then fall below this threshold + end_threshold it is considered a spike. If “auto” the threshold is set to the standard deviation of the voltage trace. Default is -30. end_threshold ({int, float}, optional) – The end threshold for a spike relative to the threshold. Generally negative values give the best results. Default is -10. extended_spikes (bool) – If the spikes should be extended past the threshold, until the derivative of the voltage trace is below 0.5. Default is False. trim (bool, optional) – If the spikes should be trimmed back from the termination threshold, so each spike is equal the threshold at both ends. Default is True. normalize (bool, optional) – If the voltage trace should be normalized before the spikes are found. If normalize is used threshold must be between [0, 1], and the end_threshold a similar relative value. Default is False. min_amplitude ({int, float}, optional) – Minimum height for what should be considered a spike. Default is 0. min_duration ({int, float}, optional) – Minimum duration for what should be considered a spike. Default is 0. xlabel (str, optional) – Label for the x-axis. ylabel (str, optional) – Label for the y-axis. spikes (list) – A list of Spike objects. nr_spikes (int) – The number of spikes. xlabel (str, optional) – Label for the x-axis. ylabel (str, optional) – Label for the y-axis. time (array_like) – The time of the voltage trace. V (array_like) – The voltage trace.

Notes

The spikes are found by finding where the voltage trace goes above the threshold, and then later falls below this threshold + end_threshold. The spike is considered to be everything within this interval.

The spike can be extended. If extended_spikes is True, the spike is extended around the above area until the derivative of the voltage trace falls below 0.5. This works badly with noisy voltage traces.

Spike
The class for a single spike.
find_spikes
Finding spikes in the voltage trace.
consecutive(data)[source]

Returns the first consecutive array, from a discontinuous index array such as [2, 3, 4, 5, 12, 13, 14], which returns [2, 3, 4, 5]

Parameters: data (array_like) The first consecutive array array_like
find_spikes(time, V, threshold=-30, end_threshold=-10, extended_spikes=False, trim=True, normalize=False, min_amplitude=0, min_duration=0)[source]

Finds spikes in the given voltage trace.

Parameters: time (array_like) – The time of the voltage trace. V (array_like) – The voltage trace. threshold ({int, float, “auto”}) – The threshold for what is considered a spike. If the voltage trace rise above and then fall below this threshold + end_threshold it is considered a spike. If “auto” the threshold is set to the standard deviation of the voltage trace. Default is -30. end_threshold ({int, float}, optional) – The end threshold for a spike relative to the threshold. Generally negative values give the best results. Default is -10. extended_spikes (bool, optional) – If the spikes should be extended past the threshold, until the derivative of the voltage trace is below 0.5. Default is False. trim (bool, optional) – If the spikes should be trimmed back from the termination threshold, so each spike is equal the threshold at both ends. Default is True. normalize (bool, optional) – If the voltage traceshould be normalized before the spikes are found. If normalize is used threshold must be between [0, 1], and the end_threshold must have a absolute value between [0, 1]. Default is False. min_amplitude ({int, float}, optional) – Minimum height for what should be considered a spike. Default is 0. min_duration ({int, float}, optional) – Minimum duration for what should be considered a spike. Default is 0. ValueError – If the threshold is outside the interval [0, 1] when normalize=True. ValueError – If the absolute value of end_threshold is outside the interval [0, 1] when normalize=True.

Notes

The spikes are added to self.spikes and self.nr_spikes is updated.

The spikes are found by finding where the voltage trace goes above the threshold, and then later falls below this threshold + end_threshold. The spike is considered to be everything within this interval.

The spike can be extended. If extended_spikes is True, the spike is extended around the above area until the derivative of the voltage trace falls below 0.5. This works badly with noisy voltage traces.

plot_spikes(save_name=None)[source]

Plot all spikes.

Parameters: save_name ({str, None}) – Name of the plot file. If None, the plot is shown instead of saved to disk. Default is None.
plot_voltage(save_name)[source]

Plot the voltage with the peak of each spike marked.

Parameters: save_name ({str, None}) – Name of the plot file. If None, the plot is shown instead of saved to disk. Default is None.

Spike¶

class uncertainpy.features.Spike(time, V, time_spike, V_spike, global_index, xlabel=u'', ylabel=u'')[source]

A single spike found in a voltage trace.

Parameters: time (array_like) – The time array of the spike. V (array_like) – The voltage array of the spike. time_spike ({float, int}) – The timing of the peak of the spike. V_spike ({float, int}) – The voltage at the peak of the spike. global_index (int) – Index of the spike peak in the simulation. xlabel (str, optional) – Label for the x-axis. ylabel (str, optional) – Label for the y-axis. time (array_like) – The time array of the spike. V (array_like) – The voltage array of the spike. time_spike ({float, int}) – The timing of the peak of the spike. V_spike ({float, int}) – The voltage at the peak of the spike. global_index (int) – Index of the spike peak in the simulation. xlabel (str, optional) – Label for the x-axis. ylabel (str, optional) – Label for the y-axis.
plot(save_name=None)[source]

Plot the spike.

Parameters: save_name ({str, None}) – Name of the plot file. If None, the plot is shown instead of saved to disk. Default is None.
trim(threshold, min_extent_from_peak=1)[source]

Remove the first and last values of the spike that is below threshold.

Parameters: threshold ({float, int}) – Remove all values from each side of the spike that is bellow this value. min_extent_from_peak (int, optional) – Minimum extent of the spike in each direction from the peak.