diff --git a/bluepyemodel/emodel_pipeline/emodel_metadata.py b/bluepyemodel/emodel_pipeline/emodel_metadata.py index a13863fe..f10277c9 100644 --- a/bluepyemodel/emodel_pipeline/emodel_metadata.py +++ b/bluepyemodel/emodel_pipeline/emodel_metadata.py @@ -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): diff --git a/bluepyemodel/emodel_pipeline/emodel_settings.py b/bluepyemodel/emodel_pipeline/emodel_settings.py index 0793b449..d3a3246e 100644 --- a/bluepyemodel/emodel_pipeline/emodel_settings.py +++ b/bluepyemodel/emodel_pipeline/emodel_settings.py @@ -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, @@ -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 @@ -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) diff --git a/bluepyemodel/emodel_pipeline/plotting.py b/bluepyemodel/emodel_pipeline/plotting.py index 945f209e..bb2230a5 100644 --- a/bluepyemodel/emodel_pipeline/plotting.py +++ b/bluepyemodel/emodel_pipeline/plotting.py @@ -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 diff --git a/bluepyemodel/model/neuron_model_configuration.py b/bluepyemodel/model/neuron_model_configuration.py index 7ae7f995..a6999881 100644 --- a/bluepyemodel/model/neuron_model_configuration.py +++ b/bluepyemodel/model/neuron_model_configuration.py @@ -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. @@ -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): @@ -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): @@ -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): diff --git a/tests/unit_tests/test_emodelmetadata.py b/tests/unit_tests/test_emodelmetadata.py index 0956edd3..9349a21c 100644 --- a/tests/unit_tests/test_emodelmetadata.py +++ b/tests/unit_tests/test_emodelmetadata.py @@ -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" )