Skip to content

Default celsius and v_init to the operating point a hoc template was fitted with - #105

Open
pgetta wants to merge 5 commits into
mainfrom
feat/read-template-globals
Open

pgetta wants to merge 5 commits into
mainfrom
feat/read-template-globals

Conversation

@pgetta

@pgetta pgetta commented Oct 29, 2026 •

Copy link
Copy Markdown

compute_memodel_properties, compute_memodel_properties_v2 and run_validations set NEURON to 34 °C / −80 mV unless the caller passes other values. bluecellulab never runs a template's check_simulator(), so a model fitted at another operating point (thalamic ones: 25 °C / −70 mV) got its rheobase, input resistance and validation traces computed at the wrong conditions. Fixes openbraininstitute/Bluenaas#191 without code changes in Bluenaas (only a pin bump).

Changes:

  • read_template_globals(template_path) returns the NEURON globals a BluePyOpt hoc declares (celsius, v_init, and any others such as ena), from both forms BluePyOpt writes: the check_parameter(...) calls in check_simulator() and the "global parameters were set in BluePyOpt" comment block. Commented-out check_parameter lines are ignored. A template that declares none gives {}.
  • template_operating_point(template_path, celsius=None, v_init=None) uses a value passed in as is, otherwise the template's, otherwise 34 °C / −80 mV with a warning.
  • The three functions above now default celsius and v_init to None and resolve them through template_operating_point.

Behaviour change: callers that relied on the defaults now get the template's declared values. For the many templates that declare 34 / −80 nothing changes (the compute_memodel_properties_v2 numeric test is unchanged); explicit values still win. Downstream in obi-one, once it gets this version:

  • memodel_build calibration (obi_one/scientific/library/memodel_calibration_validation.py, compute_memodel_properties(cell) with no values) moves to the template's values. Its validation passes 34 / −80 explicitly (DEFAULT_CELSIUS / DEFAULT_V_INIT) and stays as it is.
  • E-model building calibration (obi_one/scientific/tasks/emodel_building/task2_emodel_optimization/calibration_validation.py:133, also compute_memodel_properties(cell) with no values) moves to the template's values too. Those templates come from obi-one's own optimization, which declares celsius and v_init as globals, so calibration now runs at the operating point the e-model was optimized at.

Verified: calibrating a copy of cADpyr_L2TPC.hoc declaring 25 / −70 with compute_memodel_properties(cell) and no values, every Simulation.run call sees celsius=25, v_init=-70, including the input-resistance runs in forked subprocesses.

read_template_globals returns celsius, v_init and any other NEURON global
from the check_parameter calls in check_simulator() or the ignored-globals
comment. bluecellulab never runs check_simulator(), so callers such as
compute_memodel_properties fall back to 34 C / -80 mV unless they pass the
model's own operating point; this gives them a place to read it.
The example HOCs it read both declare 34 / -80, the values callers default
to anyway; the CA1 one declares v_init -70. The comment-block test repeated
the combined one, which now covers an integer value. The number pattern no
longer lets \d+ and \d* split one digit run.
BluePyOpt writes each check_parameter call on its own line; anchoring the
pattern there keeps a // check_parameter(...) line from overriding the live
one. The CHANGELOG names celsius and v_init, the only globals
compute_memodel_properties and run_validations take.
@pgetta pgetta self-assigned this Oct 29, 2026
…with

compute_memodel_properties, compute_memodel_properties_v2 and run_validations
set NEURON to 34 C / -80 mV unless the caller passed other values, so a model
fitted at another operating point (thalamic: 25 C / -70 mV) got its rheobase,
Rin and validation traces at the wrong conditions. Their defaults are now the
template's declared values; a template that declares none keeps 34 C / -80 mV
and logs a warning. Explicit values still win.
@pgetta pgetta changed the title Read the globals a BluePyOpt hoc template was fitted with Default celsius and v_init to the operating point a hoc template was fitted with Oct 29, 2026
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
bluecellulab/cell/template.py 97.76% <100.00%> (+0.41%) ⬆️
bluecellulab/tools.py 98.81% <100.00%> (+3.03%) ⬆️
bluecellulab/validation/validation.py 100.00% <100.00%> (ø)
tests/test_cell/test_template.py 100.00% <100.00%> (ø)
tests/test_tools.py 98.95% <100.00%> (+0.05%) ⬆️
tests/test_validation/test_validation.py 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The mock cell now points at the CA1 example hoc (v_init -70): a call without
celsius/v_init sets NEURON to 34 / -70, and explicit values still win.
@pgetta
pgetta marked this pull request as ready for review October 29, 2026 15:35
@ilkilic

ilkilic commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Thank you @pgetta, looks good to me.

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.

Calibration uses wrong temperature/v_init -> wrong threshold & holding current

2 participants