From fb40e3b48d11ac1f875ed0ad1e637c9c05996b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kili=C3=A7=20Ilkan=20Fabrice?= Date: Fri, 15 Sep 2023 18:46:10 +0200 Subject: [PATCH 1/5] remove test entry in pyr.json --- .../emodel_pipeline_local_python/README.rst | 1 + .../config/params/pyr.json | 63 ++++++++++--------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/examples/emodel_pipeline_local_python/README.rst b/examples/emodel_pipeline_local_python/README.rst index 65ace2db..01c90522 100644 --- a/examples/emodel_pipeline_local_python/README.rst +++ b/examples/emodel_pipeline_local_python/README.rst @@ -85,6 +85,7 @@ Finally, the different steps of the pipeline can be run with the commands: pipeline.extract_efeatures() pipeline.optimise(seed=1) pipeline.store_optimisation_results() + pipeline.validation() pipeline.plot(only_validated=False) This snippet will likely not be used as such as the different steps of the pipeline are computationally intensive and will be run separately. diff --git a/examples/emodel_pipeline_local_python/config/params/pyr.json b/examples/emodel_pipeline_local_python/config/params/pyr.json index 7a82a35f..9005596a 100644 --- a/examples/emodel_pipeline_local_python/config/params/pyr.json +++ b/examples/emodel_pipeline_local_python/config/params/pyr.json @@ -29,18 +29,18 @@ {"name":"celsius", "val":34} ], "distribution_decay": [ - {"name":"constant", "val":[-0.1, 0.0], "test": -0.0054993896903911335} + {"name":"constant", "val":[-0.1, 0.0]} ], "myelinated": [ {"name":"cm", "val":0.02} ], "all": [ {"name":"Ra", "val":100}, - {"name":"g_pas", "val":[1e-5, 6e-5], "test":5.3926647384073322e-05}, - {"name":"e_pas", "val":[-95, -60], "test":-75.862421167964129} + {"name":"g_pas", "val":[1e-5, 6e-5]}, + {"name":"e_pas", "val":[-95, -60]} ], "somadend": [ - {"name":"gIhbar_Ih", "val":[0, 2e-4], "test":4.9710877962221885e-06, "dist":"exp", + {"name":"gIhbar_Ih", "val":[0, 2e-4], "dist":"exp", "__comment": "distribution starts in soma (uniform) and spreads exponentially to dendrites"} ], "axonal": [ @@ -49,16 +49,17 @@ {"name":"ek", "val":-90}, {"name":"vshifth_NaTg", "val":10}, {"name":"slopem_NaTg", "val":9}, - {"name":"gNaTgbar_NaTg", "val":[0, 1.5], "test":0.45001599746214271}, - {"name":"gNap_Et2bar_Nap_Et2", "val":[0, 0.02], "test":0.0074930910112714971}, - {"name":"gK_Pstbar_K_Pst", "val":[0, 1], "test":0.41317541509924871}, - {"name":"gK_Tstbar_K_Tst", "val":[0, 0.2], "test":0.18323702633195063}, - {"name":"gSKv3_1bar_SKv3_1", "val":[0, 1], "test":0.59766537780998541}, - {"name":"gCa_HVAbar_Ca_HVA2", "val":[0, 0.001], "test":0.00065484400421279019}, - {"name":"gCa_LVAstbar_Ca_LVAst", "val":[0, 0.01], "test":0.0006624110987988748}, - {"name":"gSK_E2bar_SK_E2", "val":[0, 0.1], "test":0.0055436826094973947}, - {"name":"decay_CaDynamics_DC0", "val":[20, 300], "test": 187.93939189992398}, - {"name":"gamma_CaDynamics_DC0", "val":[0.005, 0.05], "test":0.018262044595632514} + {"name":"gNaTgbar_NaTg", "val":[0, 1.5]}, + {"name":"gNap_Et2bar_Nap_Et2", "val":[0, 0.02]}, + {"name":"gK_Pstbar_K_Pst", "val":[0, 1]}, + {"name":"gK_Tstbar_K_Tst", "val":[0, 0.2]}, + {"name":"gSKv3_1bar_SKv3_1", "val":[0, 1]}, + {"name":"gCa_HVAbar_Ca_HVA2", "val":[0, 0.001]}, + {"name":"gCa_HVAbar_Ca_HVA2", "val":[0, 0.001]}, + {"name":"gCa_LVAstbar_Ca_LVAst", "val":[0, 0.01]}, + {"name":"gSK_E2bar_SK_E2", "val":[0, 0.1]}, + {"name":"decay_CaDynamics_DC0", "val":[20, 300]}, + {"name":"gamma_CaDynamics_DC0", "val":[0.005, 0.05]} ], "somatic": [ {"name":"cm", "val":1}, @@ -67,33 +68,33 @@ {"name":"vshiftm_NaTg", "val":13}, {"name":"vshifth_NaTg", "val":15}, {"name":"slopem_NaTg", "val":7}, - {"name":"gNaTgbar_NaTg", "val":[0, 0.3], "test":0.22533600162118178}, - {"name":"gK_Pstbar_K_Pst", "val":[0, 0.2], "test":0.15029253289238459}, - {"name":"gK_Tstbar_K_Tst", "val":[0, 0.1], "test":0.0048028568033722466}, - {"name":"gSKv3_1bar_SKv3_1", "val":[0, 1], "test":0.17097147644202285}, - {"name":"gCa_HVAbar_Ca_HVA2", "val":[0, 0.001], "test":0.00056391253652122346}, - {"name":"gCa_LVAstbar_Ca_LVAst", "val":[0, 0.01], "test":0.0010207881257459726}, - {"name":"gSK_E2bar_SK_E2", "val":[0, 0.1], "test":0.079708174678391613}, - {"name":"decay_CaDynamics_DC0", "val":[20, 300], "test":104.85544592336207}, - {"name":"gamma_CaDynamics_DC0", "val":[0.005, 0.05], "test":0.02349598838420491} + {"name":"gNaTgbar_NaTg", "val":[0, 0.3]}, + {"name":"gK_Pstbar_K_Pst", "val":[0, 0.2]}, + {"name":"gK_Tstbar_K_Tst", "val":[0, 0.1]}, + {"name":"gSKv3_1bar_SKv3_1", "val":[0, 1]}, + {"name":"gCa_HVAbar_Ca_HVA2", "val":[0, 0.001]}, + {"name":"gCa_LVAstbar_Ca_LVAst", "val":[0, 0.01]}, + {"name":"gSK_E2bar_SK_E2", "val":[0, 0.1]}, + {"name":"decay_CaDynamics_DC0", "val":[20, 300]}, + {"name":"gamma_CaDynamics_DC0", "val":[0.005, 0.05]} ], "apical": [ {"name":"cm", "val":2}, {"name":"ena", "val":50}, {"name":"ek", "val":-90}, - {"name":"gamma_CaDynamics_DC0", "val":[0.005, 0.05], "test":0.0066739787731804143}, + {"name":"gamma_CaDynamics_DC0", "val":[0.005, 0.05]}, {"name":"vshiftm_NaTg", "val":6}, {"name":"vshifth_NaTg", "val":6}, - {"name":"gNaTgbar_NaTg", "val":[0, 0.1], "test": 0.099937269709686416, "dist":"decay"}, - {"name":"gSKv3_1bar_SKv3_1", "val":[0, 0.003], "test":0.0014911639485230455}, - {"name":"gCa_HVAbar_Ca_HVA2", "val":[0, 0.0001], "test":2.0449633205094153e-05}, - {"name":"gCa_LVAstbar_Ca_LVAst", "val":[0, 0.001], "test":0.00011242611925684145} + {"name":"gNaTgbar_NaTg", "val":[0, 0.1], "dist":"decay"}, + {"name":"gSKv3_1bar_SKv3_1", "val":[0, 0.003]}, + {"name":"gCa_HVAbar_Ca_HVA2", "val":[0, 0.0001]}, + {"name":"gCa_LVAstbar_Ca_LVAst", "val":[0, 0.001]} ], "basal": [ {"name":"cm", "val":2}, - {"name":"gamma_CaDynamics_DC0", "val":[0.005, 0.05], "test":0.04066564973313349}, - {"name":"gCa_HVAbar_Ca_HVA2", "val":[0, 0.0001], "test":8.087166736008117e-05}, - {"name":"gCa_LVAstbar_Ca_LVAst", "val":[0, 0.001], "test":2.7582661164552104e-05} + {"name":"gamma_CaDynamics_DC0", "val":[0.005, 0.05]}, + {"name":"gCa_HVAbar_Ca_HVA2", "val":[0, 0.0001]}, + {"name":"gCa_LVAstbar_Ca_LVAst", "val":[0, 0.001]} ] } } From f945f4b35e877882a6602755799a86ddbd7f72ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kili=C3=A7=20Ilkan=20Fabrice?= Date: Fri, 15 Sep 2023 18:58:17 +0200 Subject: [PATCH 2/5] plotting: highlight labels in red for scores greater than 5. --- bluepyemodel/emodel_pipeline/plotting.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bluepyemodel/emodel_pipeline/plotting.py b/bluepyemodel/emodel_pipeline/plotting.py index 60cfcf99..79ef1228 100644 --- a/bluepyemodel/emodel_pipeline/plotting.py +++ b/bluepyemodel/emodel_pipeline/plotting.py @@ -353,6 +353,11 @@ def scores(model, figures_dir="./figures", write_fig=True): axs[0, 0].set_yticks(pos) axs[0, 0].set_yticklabels(scores_names, size="small") + # Update y-tick labels' color based on the condition + for idx, (label, s) in zip(axs[0, 0].get_yticklabels(), score): + if s > 5: + label.set_color("red") + axs[0, 0].set_xlim(0, 5) axs[0, 0].set_ylim(-0.5, len(pos) - 0.5) From 517cfc0f7341b37ef7e351d581f68b6e10e352cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kili=C3=A7=20Ilkan=20Fabrice?= Date: Mon, 18 Sep 2023 12:21:09 +0200 Subject: [PATCH 3/5] plotting: add SCORE_THRESHOLD --- bluepyemodel/emodel_pipeline/emodel_pipeline.py | 6 +++++- bluepyemodel/emodel_pipeline/plotting.py | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bluepyemodel/emodel_pipeline/emodel_pipeline.py b/bluepyemodel/emodel_pipeline/emodel_pipeline.py index 2d9ba780..c5f747ea 100644 --- a/bluepyemodel/emodel_pipeline/emodel_pipeline.py +++ b/bluepyemodel/emodel_pipeline/emodel_pipeline.py @@ -243,9 +243,13 @@ def plot(self, only_validated=False, load_from_local=False): record_ions_and_currents=self.access_point.pipeline_settings.plot_currentscape, ) + chkp_paths = glob.glob("./checkpoints/**/*.pkl", recursive=True) + if not chkp_paths: + raise ValueError("The checkpoints directory is empty, or there are no .pkl files.") + # Filter the checkpoints to plot checkpoint_paths = [] - for chkp_path in glob.glob("./checkpoints/**/*.pkl", recursive=True): + for chkp_path in chkp_paths: if self.access_point.emodel_metadata.emodel not in chkp_path: continue if ( diff --git a/bluepyemodel/emodel_pipeline/plotting.py b/bluepyemodel/emodel_pipeline/plotting.py index 79ef1228..cd355cdb 100644 --- a/bluepyemodel/emodel_pipeline/plotting.py +++ b/bluepyemodel/emodel_pipeline/plotting.py @@ -333,6 +333,8 @@ def evolution_parameters_density( def scores(model, figures_dir="./figures", write_fig=True): """Plot the scores of a model""" + SCORE_THRESHOLD = 5.0 + make_dir(figures_dir) score = list(model.scores.values()) + list(model.scores_validation.values()) @@ -345,7 +347,7 @@ def scores(model, figures_dir="./figures", write_fig=True): axs[0, 0].barh(pos, score, height=0.7, align="center", color="gray") for p, s in zip(pos, score): - if s > 5.0: + if s > SCORE_THRESHOLD: axs[0, 0].text(5.15, p - 0.25, s="{:.1f}".format(s), color="red", fontsize=8) axs[0, 0].set_xlabel("z-score") @@ -354,8 +356,8 @@ def scores(model, figures_dir="./figures", write_fig=True): axs[0, 0].set_yticklabels(scores_names, size="small") # Update y-tick labels' color based on the condition - for idx, (label, s) in zip(axs[0, 0].get_yticklabels(), score): - if s > 5: + for label, s in zip(axs[0, 0].get_yticklabels(), score): + if s > SCORE_THRESHOLD: label.set_color("red") axs[0, 0].set_xlim(0, 5) From 80acfeda0e38f8c287b93a4135452f211c049c41 Mon Sep 17 00:00:00 2001 From: ilkilic Date: Mon, 25 Sep 2023 14:00:55 +0200 Subject: [PATCH 4/5] remove duplicate entry in pyr.json --- examples/emodel_pipeline_local_python/config/params/pyr.json | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/emodel_pipeline_local_python/config/params/pyr.json b/examples/emodel_pipeline_local_python/config/params/pyr.json index 9005596a..025e2cb6 100644 --- a/examples/emodel_pipeline_local_python/config/params/pyr.json +++ b/examples/emodel_pipeline_local_python/config/params/pyr.json @@ -55,7 +55,6 @@ {"name":"gK_Tstbar_K_Tst", "val":[0, 0.2]}, {"name":"gSKv3_1bar_SKv3_1", "val":[0, 1]}, {"name":"gCa_HVAbar_Ca_HVA2", "val":[0, 0.001]}, - {"name":"gCa_HVAbar_Ca_HVA2", "val":[0, 0.001]}, {"name":"gCa_LVAstbar_Ca_LVAst", "val":[0, 0.01]}, {"name":"gSK_E2bar_SK_E2", "val":[0, 0.1]}, {"name":"decay_CaDynamics_DC0", "val":[20, 300]}, From ff1128e12cd66ff2b8f5170f1d8311a114d1776b Mon Sep 17 00:00:00 2001 From: ilkilic Date: Mon, 25 Sep 2023 14:43:56 +0200 Subject: [PATCH 5/5] remove highlight feature labels --- bluepyemodel/emodel_pipeline/plotting.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/bluepyemodel/emodel_pipeline/plotting.py b/bluepyemodel/emodel_pipeline/plotting.py index cd355cdb..379861ce 100644 --- a/bluepyemodel/emodel_pipeline/plotting.py +++ b/bluepyemodel/emodel_pipeline/plotting.py @@ -355,11 +355,6 @@ def scores(model, figures_dir="./figures", write_fig=True): axs[0, 0].set_yticks(pos) axs[0, 0].set_yticklabels(scores_names, size="small") - # Update y-tick labels' color based on the condition - for label, s in zip(axs[0, 0].get_yticklabels(), score): - if s > SCORE_THRESHOLD: - label.set_color("red") - axs[0, 0].set_xlim(0, 5) axs[0, 0].set_ylim(-0.5, len(pos) - 0.5)