From 6e1b9d325b629597cba1b8d3c56b242752839b77 Mon Sep 17 00:00:00 2001 From: "a.ott" Date: Wed, 15 Jan 2020 14:32:30 +0100 Subject: [PATCH] add test for firerate model, move step size test --- functionalityTests.py | 26 +++++------------------ tests/ModelTests.py | 48 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 tests/ModelTests.py diff --git a/functionalityTests.py b/functionalityTests.py index 25b14fd..18ff6c9 100644 --- a/functionalityTests.py +++ b/functionalityTests.py @@ -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() \ No newline at end of file + plt.show() + + + + diff --git a/tests/ModelTests.py b/tests/ModelTests.py new file mode 100644 index 0000000..6ea5d7c --- /dev/null +++ b/tests/ModelTests.py @@ -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() \ No newline at end of file