Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fitzhughnagumo Model #34

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

shraddhajain13
Copy link
Collaborator

first version of fitzhughnagumo

@clinssen clinssen self-requested a review September 6, 2020 11:26
Copy link
Contributor

@clinssen clinssen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this bug and adding the FitzHugh-Nagumo model! I left several comments, hopefully most of them should be relatively minor changes.

Could you please file a separate PR containing the typing bugfix? Then we'll try to get that merged into master first.

r"""
Internally converts to a global, sorted list of spike times.

:param spike_times: For each variable, used as a key, the list of spike times associated with it.
"""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary whitelines.

@@ -0,0 +1,164 @@
#
# test_mixed_integrator_numeric.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct filename

tests/fitzhughnagumo.json Show resolved Hide resolved

"options": {
"sim_time": "45E-3",
"integration_accuracy_abs" : "1E-6",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the entire "options" block can be removed. Could you double-check that the default integration accuracy is adequate (i.e. results look the same when we remove this block from the model)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caveat: note that the integration accuracy, passed here to ODE-toolbox as input, will be used by ODE-toolbox during its analysis, and is (possibly) a different value from the one used during the numeric integration in the unit test.



class TestFitxhughNagumo(unittest.TestCase):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace

peaks, _ = find_peaks(np.array(y_log)[N1:,0], height = 1.5 ) #finding peaks above 1.5 microvolts ignoring the first 200 ms
num_peaks[j] = (int)(len(peaks)/((T-200)*0.001)) #frequency (in Hz) of the peaks for every value of current
if(I_ext[j] >(1/3)):
assert(num_peaks[j]>20)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parentheses not necessary.

if INTEGRATION_TEST_DEBUG_PLOTS:
self._FI_curve(I_ext,num_peaks,basedir="",fn_snip = "FI curve", title_snip = "FI curve")

def _timeseries_plot(self,N1, t_log, h_log, y_log, sym_list, basedir="", fn_snip="", title_snip=""):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain what N1 is here in the docstring.


h = 1 # [ms] #time steps
T = 1000 # [ms] #total simulation time
n = 25 #total number of current values between 0 and 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to drastically lower this number if we're not making any plots, just so the testsuite doesn't take too long to complete on Travis. Possibly even a manually curated list (I_ext = np.array([0., ..., 1.]))

plt.savefig(fn,dpi=600)
plt.close()


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra newlines.

shapes,
analytic_solver_dict=None,
parameters={"I_ext":str(I_ext[j])},
random_seed=123,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
random_seed=123,

Not important for this test.

@clinssen
Copy link
Contributor

clinssen commented Nov 2, 2020

Thanks for the updates addressing my comments. I still have a few remaining concerns.

I'm still not happy with the time it takes the unit testing suite to complete. I would suggest to move to a manually curated list:

I_ext_list = np.array([1/3 - .1, 1/3 + .1])

and change the loop from

n = 10
for j in range(n):

to

for j, I_ext in enumerate(I_ext_list):

The test

if I_ext[j] > 1 / 3:

has to be changed to include a margin. After all, because of floating point discretisation errors (the minutiae of which might even depend on the model of CPU that we're running on), we can't really predict very well what happens near I_ext = 1/3. So would need something like:

if I_ext < 1/3 - margin:
	# assert NO spikes
elif I_ext > 1/3 + margin:
	# assert spiking
# else
#   # don't know what might happen!

Please include a comment in the code (where appropriate) to note that the current I_ext should be in the range [0, 1] (inclusive).

Could you also fix the merge conflict, by pulling latest upstream/master and picking the line without the comment? Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants