This repository was archived by the owner on Feb 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
Raise exception when the voltage becomes unrealistic during a neuron simulation #387
Open
DrTaDa
wants to merge
1
commit into
master
Choose a base branch
from
fadvance
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+16
−3
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,12 +112,19 @@ def neuron(self): | |
|
||
return neuron | ||
|
||
def check_voltage_valid(self, icell, voltage_bound=200.): | ||
"""Raises exception if voltage at soma is out of bound""" | ||
|
||
if icell and abs(icell.soma[0](0.5).v) > voltage_bound: | ||
raise NrnSimulatorException('Membrane potential is out of bound') | ||
|
||
def run( | ||
self, | ||
tstop=None, | ||
dt=None, | ||
cvode_active=None, | ||
random123_globalindex=None): | ||
random123_globalindex=None, | ||
icell=None): | ||
"""Run protocol""" | ||
|
||
self.neuron.h.tstop = tstop | ||
|
@@ -163,7 +170,10 @@ def run( | |
rng.Random123_globalindex(random123_globalindex) | ||
|
||
try: | ||
self.neuron.h.run() | ||
self.neuron.h.finitialize() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we sure this 'exactly' replicates the 'run()' behavior of Neuron? We don't want to change results if not necessary. |
||
while self.neuron.h.t < self.neuron.h.tstop: | ||
self.neuron.h.fadvance() | ||
self.check_voltage_valid(icell) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also need to check how this affects the simulation time. |
||
except Exception as e: | ||
raise NrnSimulatorException('Neuron simulator error', e) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this dangerous though. Ideally NEURON should detect if it gets values that it can't handle. Do we know what the effect this has on optimizations? I wouldn't be surprised if a lot of initial solutions might be out of bounds here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok,I will open an issue in Neuron
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any news?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The engineer who was looking into it is just back from vacation. He will resume working on it.