neurodynex.tools package¶
Submodules¶
neurodynex.tools.input_factory module¶
-
neurodynex.tools.input_factory.
get_ramp_current
(t_start, t_end, unit_time, amplitude_start, amplitude_end, append_zero=True)[source]¶ Creates a ramp current. If t_start == t_end, then ALL entries are 0.
Parameters: - t_start (int) – start of the ramp
- t_end (int) – end of the ramp
- unit_time (Brian2 unit) – unit of t_start and t_end. e.g. 0.1*brian2.ms
- amplitude_start (Quantity) – amplitude of the ramp at t_start. e.g. 3.5*brian2.uamp
- amplitude_end (Quantity) – amplitude of the ramp at t_end. e.g. 4.5*brian2.uamp
- append_zero (bool, optional) – if true, 0Amp is appended at t_end+1. Without that trailing 0, Brian reads out the last value in the array (=amplitude_end) for all indices > t_end.
Returns: Brian2.TimedArray
Return type: TimedArray
-
neurodynex.tools.input_factory.
get_sinusoidal_current
(t_start, t_end, unit_time, amplitude, frequency, direct_current, phase_offset=0.0, append_zero=True)[source]¶ Creates a sinusoidal current. If t_start == t_end, then ALL entries are 0.
Parameters: - t_start (int) – start of the sine wave
- t_end (int) – end of the sine wave
- unit_time (Quantity, Time) – unit of t_start and t_end. e.g. 0.1*brian2.ms
- amplitude (Quantity, Current) – maximum amplitude of the sinus e.g. 3.5*brian2.uamp
- frequency (Quantity, Hz) – Frequency of the sine. e.g. 0.5*brian2.kHz
- direct_current (Quantity, Current) – DC-component (=offset) of the current
- phase_offset (float, Optional) – phase at t_start. Default = 0.
- append_zero (bool, optional) – if true, 0Amp is appended at t_end+1. Without that trailing 0, Brian reads out the last value in the array for all indices > t_end.
Returns: Brian2.TimedArray
Return type: TimedArray
-
neurodynex.tools.input_factory.
get_spikes_current
(t_spikes, unit_time, amplitude, append_zero=True)[source]¶ Creates a two dimensional TimedArray wich has one column for each value in t_spikes. All values in each column are 0 except one, the spike time as specified in t_spikes is set to amplitude. Note: This function is provided to easily insert pulse currents into a cable. For other use of spike input, search the Brian2 documentation for SpikeGeneration.
Parameters: - t_spikes (int) – list of spike times
- unit_time (Quantity, Time) – unit of t_spikes . e.g. 1*brian2.ms
- amplitude (Quantity, Current) – amplitude of the spike. All spikes have the sampe amplitude
- append_zero (bool, optional) – if true, 0Amp is appended at t_end+1. Without that trailing 0,
- reads out the last value in the array for all indices > t_end. (Brian) –
Returns: Brian2.TimedArray
Return type: TimedArray
-
neurodynex.tools.input_factory.
get_step_current
(t_start, t_end, unit_time, amplitude, append_zero=True)[source]¶ Creates a step current. If t_start == t_end, then a single entry in the values array is set to amplitude.
Parameters: - t_start (int) – start of the step
- t_end (int) – end of the step
- unit_time (Brian2 unit) – unit of t_start and t_end. e.g. 0.1*brian2.ms
- amplitude (Quantity) – amplitude of the step. e.g. 3.5*brian2.uamp
- append_zero (bool, optional) – if true, 0Amp is appended at t_end+1.
- that trailing 0, Brian reads out the last value in the array (Without) –
Returns: Brian2.TimedArray
Return type: TimedArray
-
neurodynex.tools.input_factory.
get_zero_current
()[source]¶ Returns a TimedArray with one entry: 0 Amp
Returns: TimedArray
-
neurodynex.tools.input_factory.
plot_ramp_current_example
()[source]¶ Example for get_ramp_current Returns:
neurodynex.tools.plot_tools module¶
-
neurodynex.tools.plot_tools.
plot_voltage_and_current_traces
(voltage_monitor, current, title=None, firing_threshold=None, do_show_plot=True, legend_location=1)[source]¶ plots voltage and current .
Parameters: - voltage_monitor (StateMonitor) – recorded voltage
- current (TimedArray) – injected current
- title (string, optional) – title of the figure
- firing_threshold (Quantity, optional) – if set to a value, the firing threshold is plotted.
- do_show_plot (bool) – optional, default=True. Set it to False to suppress the blocking pyplot.show() call.
neurodynex.tools.spike_tools module¶
-
neurodynex.tools.spike_tools.
get_spike_stats
(voltage_monitor, spike_threshold)[source]¶ Detects spike times and computes ISI, mean ISI and firing frequency. Note: meanISI and firing frequency are set to numpy.nan if less than two spikes are detected Note: currently only the spike times of the first column in voltage_monitor are detected. Matrix-like monitors are not supported. :param voltage_monitor: A state monitor with at least the fields “v: and “t” :type voltage_monitor: StateMonitor :param spike_threshold: The spike threshold voltage. e.g. -50*b2.mV :type spike_threshold: Quantity
Returns: (nr_of_spikes, spike_times, isi, mean_isi, spike_rate) Return type: tuple
-
neurodynex.tools.spike_tools.
get_spike_time
(voltage_monitor, spike_threshold)[source]¶ Detects the spike times in the voltage. The spike time is the value in voltage_monitor.t for which voltage_monitor.v[idx] is above threshold AND voltage_monitor.v[idx-1] is below threshold (crossing from below). Note: currently only the spike times of the first column in voltage_monitor are detected. Matrix-like monitors are not supported. :param voltage_monitor: A state monitor with at least the fields “v: and “t” :type voltage_monitor: StateMonitor :param spike_threshold: The spike threshold voltage. e.g. -50*b2.mV :type spike_threshold: Quantity
Returns: A list of spike times (Quantity)
-
neurodynex.tools.spike_tools.
pretty_print_spike_train_stats
(voltage_monitor, spike_threshold)[source]¶ Computes and returns the same values as get_spike_stats. Additionally prints these values to the console. :param voltage_monitor: :param spike_threshold:
Returns: (nr_of_spikes, spike_times, isi, mean_isi, spike_rate) Return type: tuple