Skip to content

Commit

Permalink
chore(neuroml): use variable for setting rounding precision
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayankur31 committed Oct 23, 2024
1 parent 3e3663b commit 6e7cc40
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions netpyne/conversion/neuromlFormat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
pp = pprint.PrettyPrinter(depth=6, indent=4)
ROUND_PRECISION = 10

try:
import neuroml
Expand Down Expand Up @@ -1215,7 +1216,8 @@ def handle_network(self, network_id, notes, temperature=None):
"""
if temperature:
self.simConfig.hParams["celsius"] = round(
pynml.convert_to_units(temperature, "degC"), 5
pynml.convert_to_units(temperature, "degC"),
ROUND_PRECISION
)
logger.info(
"Setting global temperature to %s"
Expand Down Expand Up @@ -1567,8 +1569,8 @@ def handle_population(
end_len = path_dist[seg_grp.id][last.id]

inhomogeneous_parameters[seg_grp.id][nrn_sec] = (
round(start_len, 10),
round(end_len, 10),
round(start_len, ROUND_PRECISION),
round(end_len, ROUND_PRECISION),
)
logger.debug(
"Inhomogeneous parameter: Seg: %s (%s) -> %s (%s)",
Expand All @@ -1586,13 +1588,16 @@ def handle_population(
group = "all" if not cm.segment_groups else cm.segment_groups
for section_name in seg_grps_vs_nrn_sections[group]:
gmax = round(
pynml.convert_to_units(cm.cond_density, "S_per_cm2"), 10
pynml.convert_to_units(cm.cond_density,
"S_per_cm2"),
ROUND_PRECISION
)
if cm.ion_channel == "pas":
mech = {"g": gmax}
else:
mech = {"gmax": gmax}
erev = round(pynml.convert_to_units(cm.erev, "mV"), 10)
erev = round(pynml.convert_to_units(cm.erev, "mV"),
ROUND_PRECISION)

cellRule["secs"][section_name]["mechs"][cm.ion_channel] = mech

Expand All @@ -1610,13 +1615,16 @@ def handle_population(
group = "all" if not cm.segment_groups else cm.segment_groups
for section_name in seg_grps_vs_nrn_sections[group]:
gmax = round(
pynml.convert_to_units(cm.cond_density, "S_per_cm2"), 10
pynml.convert_to_units(cm.cond_density,
"S_per_cm2"),
ROUND_PRECISION
)
if cm.ion_channel == "pas":
mech = {"g": gmax}
else:
mech = {"gmax": gmax}
erev = round(pynml.convert_to_units(cm.erev, "mV"), 10)
erev = round(pynml.convert_to_units(cm.erev, "mV"),
ROUND_PRECISION)

cellRule["secs"][section_name]["mechs"][cm.ion_channel] = mech

Expand All @@ -1635,7 +1643,9 @@ def handle_population(
group = "all" if not cm.segment_groups else cm.segment_groups
for section_name in seg_grps_vs_nrn_sections[group]:
gmax = round(
pynml.convert_to_units(cm.cond_density, "S_per_cm2"), 10
pynml.convert_to_units(cm.cond_density,
"S_per_cm2"),
ROUND_PRECISION
)
if cm.ion_channel == "pas":
mech = {"g": gmax}
Expand All @@ -1659,7 +1669,8 @@ def handle_population(
group = "all" if not cm.segment_groups else cm.segment_groups
for section_name in seg_grps_vs_nrn_sections[group]:
permeability = round(
pynml.convert_to_units(cm.permeability, "cm_per_s"), 10
pynml.convert_to_units(cm.permeability,
"cm_per_s"), ROUND_PRECISION
)
mech = {"permeability": permeability}

Expand All @@ -1678,7 +1689,9 @@ def handle_population(
group = "all" if not cm.segment_groups else cm.segment_groups
for section_name in seg_grps_vs_nrn_sections[group]:
gmax = round(
pynml.convert_to_units(cm.cond_density, "S_per_cm2"), 10
pynml.convert_to_units(cm.cond_density,
"S_per_cm2"),
ROUND_PRECISION
)
if cm.ion_channel == "pas":
mech = {"g": gmax}
Expand Down

0 comments on commit 6e7cc40

Please sign in to comment.