Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add settings for customisable plots #176

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions bluepyemodel/emodel_pipeline/emodel_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
35 changes: 27 additions & 8 deletions bluepyemodel/emodel_pipeline/emodel_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
54 changes: 27 additions & 27 deletions bluepyemodel/tasks/emodel_creation/optimisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -1299,30 +1293,36 @@ 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)
fname += "__evo_parameter_density.pdf"
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)
fname += "__scores.pdf"
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)
Expand Down
Loading