diff --git a/bluepyemodel/emodel_pipeline/emodel_pipeline.py b/bluepyemodel/emodel_pipeline/emodel_pipeline.py index c298fc6d..f3a6aa56 100644 --- a/bluepyemodel/emodel_pipeline/emodel_pipeline.py +++ b/bluepyemodel/emodel_pipeline/emodel_pipeline.py @@ -262,16 +262,16 @@ def plot(self, only_validated=False, load_from_local=False, seeds=None): mapper=self.mapper, seeds=seeds, figures_dir=pathlib.Path("./figures") / self.access_point.emodel_metadata.emodel, - plot_optimisation_progress=True, + plot_optimisation_progress=pp_settings.plot_optimisation_progress, optimiser=pp_settings.optimiser, - plot_parameter_evolution=True, - plot_distributions=True, - plot_scores=True, - plot_traces=True, - plot_thumbnail=True, + plot_parameter_evolution=pp_settings.plot_parameter_evolution, + plot_distributions=pp_settings.plot_distributions, + plot_scores=pp_settings.plot_scores, + plot_traces=pp_settings.plot_traces, + plot_thumbnail=pp_settings.plot_thumbnail, plot_currentscape=pp_settings.plot_currentscape, - plot_dendritic_ISI_CV=True, - plot_dendritic_rheobase=True, + plot_dendritic_ISI_CV=pp_settings.plot_dendritic_ISI_CV, + plot_dendritic_rheobase=pp_settings.plot_dendritic_rheobase, plot_bAP_EPSP=pp_settings.plot_bAP_EPSP, plot_IV_curve=pp_settings.plot_IV_curves, plot_FI_curve_comparison=pp_settings.plot_FI_curve_comparison, diff --git a/bluepyemodel/emodel_pipeline/emodel_settings.py b/bluepyemodel/emodel_pipeline/emodel_settings.py index 661eec3c..140097d1 100644 --- a/bluepyemodel/emodel_pipeline/emodel_settings.py +++ b/bluepyemodel/emodel_pipeline/emodel_settings.py @@ -18,7 +18,7 @@ import logging -# pylint: disable=too-many-arguments,too-many-locals,too-many-instance-attributes +# pylint: disable=too-many-arguments,too-many-locals,too-many-instance-attributes, unused-argument # pylint: disable=too-many-statements logger = logging.getLogger(__name__) @@ -60,7 +60,6 @@ def __init__( use_stagnation_criterion=True, validation_function="max_score", validation_threshold=5.0, - plot_optimisation=True, use_ProbAMPANMDA_EMS=False, compile_mechanisms=False, n_model=3, @@ -71,8 +70,16 @@ def __init__( name_rmp_protocol=None, validation_protocols=None, name_gene_map=None, - plot_currentscape=True, + plot_optimisation=True, + plot_optimisation_progress=True, plot_parameter_evolution=True, + plot_distributions=True, + plot_scores=True, + plot_traces=True, + plot_thumbnail=True, + plot_currentscape=True, + plot_dendritic_ISI_CV=True, + plot_dendritic_rheobase=True, plot_bAP_EPSP=False, plot_IV_curves=False, plot_FI_curve_comparison=False, @@ -235,8 +242,6 @@ def __init__( Nexus access_point and the IC-selector. n_model (int): minimum number of models to pass validation to consider the e-model 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 @@ -260,10 +265,18 @@ def __init__( validation_protocols (list of str): name of the protocols to be used for validation only. E.g. ``["APWaveform_300"]``. These protocols will not be used during optimisation. - plot_currentscape (bool): during the plotting, should the currentscapes be - plotted for the recordings. + plot_optimisation (bool): legacy parameter, is not used anymore. + plot_optimisation_progress (bool): True to plot the optimisation progress + from checkpoint. plot_parameter_evolution (bool): during the plotting, should the evolution of the parameters be plotted. + plot_distributions (bool): True to plot the parameters distributions. + plot_scores (bool): True to plot the scores + plot_traces (bool): True to plot the traces + plot_thumbnail (bool): True to plot a trace that can be used as thumbnail + plot_currentscape (bool): during the plotting, should the currentscapes be + plotted for the recordings. + plot_dendritic_rheobase (bool): True to plot dendritic rheobase (if present) plot_bAP_EPSP (bool): during the plotting, should ready-to-use back-propagating AP and EPSP protocols be run and plotted. Should be True only for pyramidal cells, @@ -419,7 +432,13 @@ def __init__( self.name_gene_map = name_gene_map # Settings specific to the analysis (figure plotting) - self.plot_optimisation = plot_optimisation + self.plot_optimisation_progress = plot_optimisation_progress + self.plot_distributions = plot_distributions + self.plot_scores = plot_scores + self.plot_traces = plot_traces + self.plot_thumbnail = plot_thumbnail + self.plot_dendritic_ISI_CV = plot_dendritic_ISI_CV + self.plot_dendritic_rheobase = plot_dendritic_rheobase self.plot_currentscape = plot_currentscape self.currentscape_config = currentscape_config self.plot_parameter_evolution = plot_parameter_evolution diff --git a/bluepyemodel/tasks/emodel_creation/optimisation.py b/bluepyemodel/tasks/emodel_creation/optimisation.py index 0b8ac908..d71a4cc0 100644 --- a/bluepyemodel/tasks/emodel_creation/optimisation.py +++ b/bluepyemodel/tasks/emodel_creation/optimisation.py @@ -530,8 +530,11 @@ class Validation(WorkflowTaskRequiringMechanisms, IPyParallelTask): def requires(self): """ """ - plot_optimisation = self.access_point.pipeline_settings.plot_optimisation compile_mechanisms = self.access_point.pipeline_settings.compile_mechanisms + plot_parameter_evolution = self.access_point.pipeline_settings.plot_parameter_evolution + plot_distributions = self.access_point.pipeline_settings.plot_distributions + plot_traces = self.access_point.pipeline_settings.plot_traces + plot_scores = self.access_point.pipeline_settings.plot_scores to_run = [ StoreBestModels( @@ -558,7 +561,7 @@ def requires(self): ) ) - if plot_optimisation: + if any((plot_parameter_evolution, plot_distributions, plot_scores, plot_traces)): to_run.append( PlotModels( emodel=self.emodel, @@ -1096,21 +1099,6 @@ def requires(self): ) ] - plot_optimisation = self.access_point.pipeline_settings.plot_optimisation - - if plot_optimisation: - to_run.append( - PlotValidatedDistributions( - emodel=self.emodel, - etype=self.etype, - ttype=self.ttype, - mtype=self.mtype, - species=self.species, - brain_region=self.brain_region, - iteration_tag=self.iteration_tag, - ) - ) - return to_run @@ -1249,7 +1237,13 @@ def requires(self): def run(self): """ """ - plot_optimisation = self.access_point.pipeline_settings.plot_optimisation + plot_parameter_evolution = self.access_point.pipeline_settings.plot_parameter_evolution + plot_distributions = self.access_point.pipeline_settings.plot_distributions + plot_traces = self.access_point.pipeline_settings.plot_traces + plot_scores = self.access_point.pipeline_settings.plot_scores + plot_thumbnail = self.access_point.pipeline_settings.plot_thumbnail + plot_dendritic_ISI_CV = self.access_point.pipeline_settings.plot_dendritic_ISI_CV + plot_dendritic_rheobase = self.access_point.pipeline_settings.plot_dendritic_rheobase plot_currentscape = self.access_point.pipeline_settings.plot_currentscape plot_bAP_EPSP = self.access_point.pipeline_settings.plot_bAP_EPSP plot_IV_curves = self.access_point.pipeline_settings.plot_IV_curves @@ -1271,13 +1265,13 @@ def run(self): figures_dir=Path("./figures") / self.emodel, # False because already done in PlotOptimisation task plot_optimisation_progress=False, - plot_parameter_evolution=plot_optimisation, - plot_distributions=plot_optimisation, - plot_traces=plot_optimisation, - plot_scores=plot_optimisation, - plot_thumbnail=plot_optimisation, - plot_dendritic_ISI_CV=plot_optimisation, - plot_dendritic_rheobase=plot_optimisation, + plot_parameter_evolution=plot_parameter_evolution, + plot_distributions=plot_distributions, + plot_traces=plot_traces, + plot_scores=plot_scores, + plot_thumbnail=plot_thumbnail, + plot_dendritic_ISI_CV=plot_dendritic_ISI_CV, + plot_dendritic_rheobase=plot_dendritic_rheobase, plot_currentscape=plot_currentscape, plot_bAP_EPSP=plot_bAP_EPSP, plot_IV_curve=plot_IV_curves, @@ -1299,10 +1293,13 @@ def output(self): """ """ batch_size = self.access_point.pipeline_settings.optimisation_batch_size - plot_optimisation = self.access_point.pipeline_settings.plot_optimisation + plot_parameter_evolution = self.access_point.pipeline_settings.plot_parameter_evolution + plot_distributions = self.access_point.pipeline_settings.plot_distributions + plot_traces = self.access_point.pipeline_settings.plot_traces + plot_scores = self.access_point.pipeline_settings.plot_scores outputs = [] - if plot_optimisation: + if plot_parameter_evolution: # parameter evolution for seed in range(self.seed, self.seed + batch_size): fname = self.access_point.emodel_metadata.as_string(seed=seed) @@ -1310,12 +1307,14 @@ def output(self): fpath = Path("./figures") / self.emodel / "parameter_evolution" / fname outputs.append(luigi.LocalTarget(fpath)) + if plot_distributions: # distribution fname = self.access_point.emodel_metadata.as_string() fname += "__parameters_distribution.pdf" fpath = Path("./figures") / self.emodel / "distributions" / "all" / fname outputs.append(luigi.LocalTarget(fpath)) + if plot_scores: # scores for seed in range(self.seed, self.seed + batch_size): fname = self.access_point.emodel_metadata.as_string(seed) @@ -1323,6 +1322,7 @@ def output(self): fpath = Path("./figures") / self.emodel / "scores" / "all" / fname outputs.append(luigi.LocalTarget(fpath)) + if plot_traces: # traces for seed in range(self.seed, self.seed + batch_size): fname = self.access_point.emodel_metadata.as_string(seed)