From 7c4ece377e4d6b5f8634d50e4dcc17dfef1371a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaquier=20Aur=C3=A9lien=20Tristan?= Date: Tue, 9 Jul 2024 11:50:59 +0200 Subject: [PATCH] add current_precision to the emodel_settings Change-Id: I37bc2ba549d707b8a719e3c90c6eccf73bed761b --- bluepyemodel/emodel_pipeline/emodel_settings.py | 4 ++++ bluepyemodel/evaluation/evaluator.py | 10 ++++++++++ bluepyemodel/evaluation/protocols.py | 2 +- examples/memodel/memodel.py | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bluepyemodel/emodel_pipeline/emodel_settings.py b/bluepyemodel/emodel_pipeline/emodel_settings.py index 6cabd0dc..c31f2f89 100644 --- a/bluepyemodel/emodel_pipeline/emodel_settings.py +++ b/bluepyemodel/emodel_pipeline/emodel_settings.py @@ -79,6 +79,7 @@ def __init__( neuron_dt=None, cvode_minstep=0.0, use_params_for_seed=True, + current_precision=1e-2, max_threshold_voltage=-30, strict_holding_bounds=True, max_depth_holding_search=7, @@ -268,6 +269,8 @@ def __init__( cvode_minstep (float): minimum time step allowed when using cvode. use_params_for_seed (bool): use a hashed version of the parameter dictionary as a seed for the simulator + current_precision (float): size of search interval in current to stop the search + in SearchThresholdProtocol max_threshold_voltage (float): upper bound for the voltage during the search for the threshold or rheobase current (see SearchThresholdProtocol). strict_holding_bounds (bool): if True, the minimum and maximum values for the current @@ -305,6 +308,7 @@ def __init__( self.minimum_protocol_delay = minimum_protocol_delay # Settings related to the evaluator + self.current_precision = current_precision self.max_threshold_voltage = max_threshold_voltage self.threshold_efeature_std = threshold_efeature_std self.max_depth_holding_search = max_depth_holding_search diff --git a/bluepyemodel/evaluation/evaluator.py b/bluepyemodel/evaluation/evaluator.py index f4906ed0..65920225 100644 --- a/bluepyemodel/evaluation/evaluator.py +++ b/bluepyemodel/evaluation/evaluator.py @@ -464,6 +464,7 @@ def define_holding_protocol( def define_threshold_protocol( efeatures, + current_precision=1e-2, max_threshold_voltage=-30, step_delay=500.0, step_duration=2000.0, @@ -497,6 +498,7 @@ def define_threshold_protocol( name=thres_prot_name, location=location, target_threshold=target_current[0], + current_precision=current_precision, max_threshold_voltage=max_threshold_voltage, stimulus_delay=step_delay, stimulus_duration=step_duration, @@ -626,6 +628,7 @@ def define_preprotocols( fitness_calculator_configuration, strict_holding_bounds=False, max_depth_holding_search=7, + current_precision=1e-2, max_threshold_voltage=-30, spikecount_timeout=50, max_depth_threshold_search=10, @@ -685,6 +688,7 @@ def define_preprotocols( ) threshold_prot = define_threshold_protocol( efeatures, + current_precision, max_threshold_voltage, fitness_calculator_configuration.search_threshold_step_delay, fitness_calculator_configuration.search_threshold_step_duration, @@ -717,6 +721,7 @@ def define_threshold_based_optimisation_protocol( stochasticity=True, ais_recording=False, efel_settings=None, + current_precision=1e-2, max_threshold_voltage=-30, strict_holding_bounds=True, use_fixed_dt_recordings=False, @@ -740,6 +745,7 @@ def define_threshold_based_optimisation_protocol( deterministic ais_recording (bool): if True all the soma recording will be at the first axonal section. efel_settings (dict): eFEl settings. + current_precision (float): size of search interval in current to stop the search max_threshold_voltage (float): maximum voltage at which the SearchThresholdProtocol will search for the rheobase. strict_holding_bounds (bool): to adaptively enlarge bounds if holding current is outside @@ -789,6 +795,7 @@ def define_threshold_based_optimisation_protocol( fitness_calculator_configuration=fitness_calculator_configuration, strict_holding_bounds=strict_holding_bounds, max_depth_holding_search=max_depth_holding_search, + current_precision=current_precision, max_threshold_voltage=max_threshold_voltage, spikecount_timeout=spikecount_timeout, max_depth_threshold_search=max_depth_threshold_search, @@ -820,6 +827,7 @@ def define_threshold_based_optimisation_protocol( fitness_calculator_configuration=fitness_calculator_configuration, strict_holding_bounds=strict_holding_bounds, max_depth_holding_search=max_depth_holding_search, + current_precision=current_precision, max_threshold_voltage=max_threshold_voltage, spikecount_timeout=spikecount_timeout, max_depth_threshold_search=max_depth_threshold_search, @@ -847,6 +855,7 @@ def define_threshold_based_optimisation_protocol( fitness_calculator_configuration=fitness_calculator_configuration, strict_holding_bounds=strict_holding_bounds, max_depth_holding_search=max_depth_holding_search, + current_precision=current_precision, max_threshold_voltage=max_threshold_voltage, spikecount_timeout=spikecount_timeout, max_depth_threshold_search=max_depth_threshold_search, @@ -976,6 +985,7 @@ def create_evaluator( include_validation_protocols, stochasticity=stochasticity, efel_settings=pipeline_settings.efel_settings, + current_precision=pipeline_settings.current_precision, max_threshold_voltage=pipeline_settings.max_threshold_voltage, strict_holding_bounds=pipeline_settings.strict_holding_bounds, use_fixed_dt_recordings=use_fixed_dt_recordings, diff --git a/bluepyemodel/evaluation/protocols.py b/bluepyemodel/evaluation/protocols.py index a0caee24..b3d5a720 100644 --- a/bluepyemodel/evaluation/protocols.py +++ b/bluepyemodel/evaluation/protocols.py @@ -686,7 +686,7 @@ def __init__( name, location, target_threshold=None, - current_precision=2e-3, + current_precision=1e-2, stimulus_delay=500.0, stimulus_duration=2000.0, stimulus_totduration=3000.0, diff --git a/examples/memodel/memodel.py b/examples/memodel/memodel.py index ffce5bb3..1c63d5e2 100644 --- a/examples/memodel/memodel.py +++ b/examples/memodel/memodel.py @@ -452,6 +452,9 @@ def update_memodel( access_token=access_token, ) + # update settings for better threshold precision + access_point.pipeline_settings.current_precision = 2e-3 + # get cell evaluator with 'new' morphology cell_evaluator = get_cell_evaluator(access_point, morph_name, morph_format, morph_id)