Repository navigation
Scale IV curve current range to rheobase - #104
Merged
Merged
Conversation
compute_plot_iv_curve hardcoded the current sweep as linspace(rheobase - 2, rheobase - 0.1), an absolute -2 nA offset that implicitly assumes a rheobase on the order of 1 nA. For cells with a much smaller rheobase this injects currents orders of magnitude above rheobase and yields nonphysical steady-state voltages, while the positive-slope check still passes, so the issue is silent. Scale the sweep to the cell's rheobase instead. The range is unchanged for a rheobase near 1 nA, so existing callers are unaffected. Add a regression test asserting the sweep scales with rheobase.
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 19 files with indirect coverage changes 🚀 New features to boost your workflow:
|
darshanmandge
left a comment
Collaborator
There was a problem hiding this comment.
This will change the IV curves generated with default parameters. Let's think before merging this.
Document in PR description that the behavior change: the sweep is now ~-rheobase to 0.9*rheobase (was rheobase-2 to rheobase-0.1).
Replace the rheobase-scaled sweep with an explicit -rheobase to 0.9*rheobase linspace, removing the abs() form that was only correct for positive rheobase and masked a sign trap. At rheobase = 1 nA this matches the previous endpoints exactly, so cells near 1 nA are unaffected. Add two guards that fail loudly instead of producing silent garbage: - nb_bins < 2 cannot span a range (checked before the rheobase search). - rheobase must be finite and positive; a bare <= 0 check let NaN through (nan <= 0 is False) into an all-NaN sweep. Tests assert exact sweep endpoints for a small and a large rheobase (so a reintroduced fixed offset is caught), assert the sweep is ascending, and cover the rheobase and nb_bins rejection paths.
darshanmandge
approved these changes
Nov 6, 2026
darshanmandge
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, @ilkilic. LGTM now.
Highlighting this from the PR description in case we need to come back:
The default injected current range for a given rheobase changed. Old: [rheobase - 2, rheobase - 0.1] nA. New: [-rheobase, 0.9 * rheobase] nA.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
compute_plot_iv_curvebuilt its sweep asnp.linspace(rheobase - 2, rheobase - 0.1, nb_bins). The- 2is an absolute nA offset that assumes a rheobase near 1 nA; for cells with a much smaller rheobase it injects large hyperpolarizing currents, far more negative than the cell's subthreshold range, and produces nonphysical steady-state voltages, while the positive-slope check still passes (so it is silent).This scales the sweep to the cell's rheobase, hardens the guards, and lets callers override the bounds for a fixed absolute sweep.
Changes
np.linspace(-rheobase, 0.9 * rheobase, nb_bins), so it runs from-rheobaseup to just below threshold and includes positive subthreshold currents.min_amp/max_amp(nA). When unset they default to the rheobase-scaled range; when set they define a fixed absolute sweep and rheobase is neither computed nor required.nb_bins < 2, reject a non-finite or non-positive rheobase (NaN included), and reject bounds that are non-finite or havemin_amp >= max_amp.iv_testnow passes explicit bounds (-rheobase,0.9 * rheobase) rather than relying on the library default, so the validation range is pinned in the validation code and will not move if the default changes. It also catches the rangeValueErrorand marks the IV test failed, so a model with rheobase <= 0 fails that test instead of aborting the wholerun_validationscall.nb_binsstill controls resolution.Behavior change (breaking: default output)
rheobasechanged. Old:[rheobase - 2, rheobase - 0.1]nA. New:[-rheobase, 0.9 * rheobase]nA. For a rheobase near 1 nA these are similar; for smaller rheobase (the platform median is ~0.1 nA, where the old range was all hyperpolarizing) the new range stays physiological. IV figures produced with default settings, including the platform validation figures, will differ from before. To reproduce the old window, passmin_amp=rheobase - 2, max_amp=rheobase - 0.1.Tests
nb_binsare rejected.min_amp/max_ampset the sweep directly and skip rheobase; inverted bounds are rejected.iv_testreturns a failed result (not an exception) when the range cannot be built.