Skip to content

Commit

Permalink
Merge pull request #106 from BlueBrain/special-chars
Browse files Browse the repository at this point in the history
add use_ProbAMPANMDA_EMS setting
  • Loading branch information
AurelienJaquier authored Feb 14, 2024
2 parents 9069bc6 + 177ad15 commit cbd2823
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
3 changes: 3 additions & 0 deletions bluepyemodel/emodel_pipeline/emodel_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ def as_string(self, seed=None, use_allen_notation=True):
if seed not in [None, "None"]:
s += f"seed={seed}__"

# can have ':' in mtype. Replace this character.
s = s.replace(":", "_")

return s[:-2]

def check_emodel_name(self):
Expand Down
6 changes: 6 additions & 0 deletions bluepyemodel/emodel_pipeline/emodel_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __init__(
validation_function="max_score",
validation_threshold=5.0,
plot_optimisation=True,
use_ProbAMPANMDA_EMS=False,
compile_mechanisms=False,
n_model=3,
optimisation_batch_size=5,
Expand Down Expand Up @@ -204,6 +205,8 @@ def __init__(
building task done. Only used by the Luigi workflow.
plot_optimisation (bool): should the e-models scores and traces be plotted. Only used
by the Luigi workflow.
use_ProbAMPANMDA_EMS (bool): True to link ProbAMPANMDA_EMS in EMC on nexus,
and download ProbAMPANMDA from nexus along with other mechanisms.
compile_mechanisms (bool): should the mod files be copied in the local
mechanisms_dir directory. Only used by the Luigi workflow.
path_extract_config (str): specify the path to the .json file containing the targets
Expand Down Expand Up @@ -358,5 +361,8 @@ def __init__(
self.auto_targets = auto_targets
self.auto_targets_presets = auto_targets_presets

# Settings used with nexus
self.use_ProbAMPANMDA_EMS = use_ProbAMPANMDA_EMS

def as_dict(self):
return vars(self)
4 changes: 4 additions & 0 deletions bluepyemodel/emodel_pipeline/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,10 @@ def dendritic_feature_plot(

if write_fig:
fname = model.emodel_metadata.as_string(model.seed) + f"__{feature.name}.pdf"
# can have '[', ']' and ',' in feature name. Replace those characters
fname = fname.replace("[", "_")
fname = fname.replace("]", "_")
fname = fname.replace(",", "_")
save_fig(figures_dir, fname)

return fig, ax
Expand Down
18 changes: 18 additions & 0 deletions bluepyemodel/model/neuron_model_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(
available_mechanisms=None,
available_morphologies=None,
morph_modifiers=None,
extra_mech_ids=None,
):
"""Creates a model configuration, which includes the model parameters, distributions,
mechanisms and a morphology.
Expand Down Expand Up @@ -89,6 +90,16 @@ def __init__(
.. code-block::
morph_modifiers = [["path_to_module", "name_of_function"], ...].
extra_mech_ids (list of 2-d tuples): extra nexus ids and types to add to
related nexus ids. Must have shape:
.. code-block::
extra_mech_ids = [
("id1", "type1"),
("id2", "type2"),
...
]
"""

if isinstance(parameters, dict):
Expand Down Expand Up @@ -130,6 +141,7 @@ def __init__(
self.available_morphologies = available_morphologies

self.morph_modifiers = morph_modifiers
self.extra_mech_ids = extra_mech_ids

@property
def mechanism_names(self):
Expand Down Expand Up @@ -574,6 +586,12 @@ def get_related_nexus_ids(self):
uses.append({"id": m.id, "type": "SubCellularModelScript"})
mechs_ids.add(m.id)

if self.extra_mech_ids is not None:
for mech_id, mech_type in self.extra_mech_ids:
if mech_id not in mechs_ids:
uses.append({"id": mech_id, "type": mech_type})
mechs_ids.add(mech_id)

return {"uses": uses}

def as_dict(self):
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/test_emodelmetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,18 @@ def test_for_resource(metadata):
def test_as_string(metadata):
"""Test as_string method."""
assert metadata.as_string(seed=42) == (
"emodel=L5_TPC__etype=cAC__ttype=245_L5 PT CTX__mtype=L5_TPC:B__"
"emodel=L5_TPC__etype=cAC__ttype=245_L5 PT CTX__mtype=L5_TPC_B__"
"species=mouse__brain_region=SSCX__iteration=v0__seed=42"
)

metadata.allen_notation = "SS"
assert metadata.as_string() == (
"emodel=L5_TPC__etype=cAC__ttype=245_L5 PT CTX__mtype=L5_TPC:B__"
"emodel=L5_TPC__etype=cAC__ttype=245_L5 PT CTX__mtype=L5_TPC_B__"
"species=mouse__brain_region=SS__iteration=v0"
)

assert metadata.as_string(use_allen_notation=False) == (
"emodel=L5_TPC__etype=cAC__ttype=245_L5 PT CTX__mtype=L5_TPC:B__"
"emodel=L5_TPC__etype=cAC__ttype=245_L5 PT CTX__mtype=L5_TPC_B__"
"species=mouse__brain_region=SSCX__iteration=v0"
)

Expand Down

0 comments on commit cbd2823

Please sign in to comment.