def calibrate_current(self, ttfs): for current in range(0, 10000, 1): neuron = Neuron() for time in range(0, ttfs + 1): neuron.time_step(current / 10., time) if neuron.has_spiked(): break if neuron.last_spike == ttfs: return current / 10.
def calibrate_current(self, rate): """ Rate must be less than self.t_window """ for current in range(0, 1000, 1): neuron = Neuron() spikes = 0 for c_time in range(1, self.t_window + 1): if neuron.time_step(current / 10., c_time) == 1: spikes += 1 if spikes == rate: return current / 10. if spikes == self.t_window: break return -1
CAPACITANCE = 2.5 REST_VOLTAGE = 10 SPIKE_VOLTAGE = 75 print('Problem 1') plt.figure(1) for x in range(10, 90, 20): CURRENTS.append(x) for i in range(1, len(CURRENTS)+1): neuron = LIF(CAPACITANCE, RESISTANCE, SPIKE_VOLTAGE, REST_VOLTAGE) current = CURRENTS[i-1] plt.subplot(810+i) plt.title('Current: {}'.format(current)) for i in range(TIME_STEPS-1): neuron.time_step(current, i) neuron.add_plot(plt) x1, x2, y1, y2 = plt.axis() plt.axis((x1, x2, 0, SPIKE_VOLTAGE*SPIKE_MULTIPLIER)) plt.gca().yaxis.set_minor_formatter(NullFormatter()) plt.grid(True) plt.minorticks_on() plt.gca().set_yticks([REST_VOLTAGE, SPIKE_VOLTAGE]) plt.gca().set_xticks([]) for i in range(1, len(CURRENTS)+1): neuron = LIF(CAPACITANCE, RESISTANCE, SPIKE_VOLTAGE, REST_VOLTAGE) current = CURRENTS[i-1] plt.subplot(810+i+4) plt.title('Current: {}'.format(current)) for i in range(int(TIME_STEPS*2/3)): neuron.time_step(current, i)
RESISTANCE = 2 CAPACITANCE = 2.5 REST_VOLTAGE = 10 SPIKE_VOLTAGE = 75 print('Problem 1') plt.figure(1) for x in range(10, 90, 20): CURRENTS.append(x) for i in range(1, len(CURRENTS) + 1): neuron = LIF(CAPACITANCE, RESISTANCE, SPIKE_VOLTAGE, REST_VOLTAGE) current = CURRENTS[i - 1] plt.subplot(810 + i) plt.title('Current: {}'.format(current)) for i in range(TIME_STEPS - 1): neuron.time_step(current) neuron.add_plot(plt) x1, x2, y1, y2 = plt.axis() plt.axis((x1, x2, 0, SPIKE_VOLTAGE * SPIKE_MULTIPLIER)) plt.gca().yaxis.set_minor_formatter(NullFormatter()) plt.grid(True) plt.minorticks_on() plt.gca().set_yticks([REST_VOLTAGE, SPIKE_VOLTAGE]) plt.gca().set_xticks([]) for i in range(1, len(CURRENTS) + 1): neuron = LIF(CAPACITANCE, RESISTANCE, SPIKE_VOLTAGE, REST_VOLTAGE) current = CURRENTS[i - 1] plt.subplot(810 + i + 4) plt.title('Current: {}'.format(current)) for i in range(int(TIME_STEPS * 2 / 3)): neuron.time_step(current)