add test for firerate model, move step size test
This commit is contained in:
parent
61ddd9159e
commit
6e1b9d325b
@ -1,29 +1,9 @@
|
||||
|
||||
from models.LIFAC import LIFACModel
|
||||
from stimuli.StepStimulus import StepStimulus
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import functions as fu
|
||||
|
||||
|
||||
def test_lifac():
|
||||
model = LIFACModel()
|
||||
stimulus = StepStimulus(0.5, 1, 15)
|
||||
|
||||
for step_size in [0.001, 0.1]:
|
||||
model.set_variable("step_size", step_size)
|
||||
|
||||
v, spiketimes = model(stimulus, 2)
|
||||
|
||||
plt.plot(np.arange(0, 2, step_size/1000), v, label="step_size:" + str(step_size))
|
||||
|
||||
plt.xlabel("time in seconds")
|
||||
plt.ylabel("Voltage")
|
||||
plt.title("Voltage in the LIFAC-Model with different step sizes")
|
||||
plt.show()
|
||||
plt.close()
|
||||
|
||||
|
||||
def test_plot_inverses(ficurve):
|
||||
var = ficurve.boltzmann_fit_vars
|
||||
|
||||
@ -41,4 +21,8 @@ def test_plot_inverses(ficurve):
|
||||
ax1.plot([fu.inverse_full_boltzmann(x, var[0], var[1], var[2], var[3]) for x in x_values], x_values,
|
||||
'.', c="red", label='inverse')
|
||||
plt.legend()
|
||||
plt.show()
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
|
||||
|
48
tests/ModelTests.py
Normal file
48
tests/ModelTests.py
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from models.FirerateModel import FirerateModel
|
||||
from models.LIFAC import LIFACModel
|
||||
from stimuli.StepStimulus import StepStimulus
|
||||
|
||||
|
||||
def main():
|
||||
# test_firerate_model()
|
||||
test_stepsize_influence()
|
||||
|
||||
|
||||
def test_stepsize_influence():
|
||||
# model = LIFACModel()
|
||||
model = FirerateModel()
|
||||
stimulus = StepStimulus(0.5, 1, 15)
|
||||
|
||||
for step_size in [0.001, 0.1]:
|
||||
model.set_variable("step_size", step_size)
|
||||
|
||||
model.simulate(stimulus, 2)
|
||||
|
||||
# y = model.get_voltage_trace()
|
||||
y = model.get_frequency()
|
||||
|
||||
plt.plot(np.arange(0, 2, step_size/1000), y, label="step_size:" + str(step_size))
|
||||
|
||||
plt.xlabel("time in seconds")
|
||||
plt.ylabel("Voltage")
|
||||
plt.title("Voltage in the LIFAC-Model with different step sizes")
|
||||
plt.legend()
|
||||
plt.show()
|
||||
plt.close()
|
||||
|
||||
|
||||
def test_firerate_model():
|
||||
model = FirerateModel()
|
||||
duration = 0.2
|
||||
stimulus = StepStimulus(duration/2, duration, 10)
|
||||
|
||||
model.simulate(stimulus, duration*2)
|
||||
plt.plot(np.arange(0, duration*2, model.get_sampling_interval()/1000), model.get_frequency())
|
||||
plt.show()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user