2727from bluepyemodel .access_point import get_access_point
2828from bluepyemodel .access_point .local import LocalAccessPoint
2929from bluepyemodel .evaluation .evaluator import create_evaluator
30+ from bluepyemodel .evaluation .protocols import ProtocolRunner
3031from bluepyemodel .model import model
3132from bluepyemodel .tools .mechanisms import compile_mechs_in_emodel_dir
3233from bluepyemodel .tools .mechanisms import delete_compiled_mechanisms
@@ -120,14 +121,18 @@ def get_responses(to_run):
120121
121122 Args:
122123 to_run (dict): of the form
123- to_run = {"evaluator": CellEvaluator, "parameters": Dict}
124+ to_run = {"evaluator": CellEvaluator, "parameters": Dict, "threshold_data": Dict }
124125 """
125126
126127 eva = to_run ["evaluator" ]
127128 params = to_run ["parameters" ]
128129
129130 eva .cell_model .unfreeze (params )
130131
132+ for prot in eva .fitness_protocols .values ():
133+ if to_run .get ("threshold_data" , {}) and isinstance (prot , ProtocolRunner ):
134+ prot .threshold_data = to_run ["threshold_data" ]
135+
131136 responses = eva .run_protocols (protocols = eva .fitness_protocols .values (), param_values = params )
132137 responses ["evaluator" ] = eva
133138
@@ -142,6 +147,7 @@ def compute_responses(
142147 preselect_for_validation = False ,
143148 store_responses = False ,
144149 load_from_local = False ,
150+ recompute_threshold_protocols = False ,
145151):
146152 """Compute the responses of the emodel to the optimisation and validation protocols.
147153
@@ -157,6 +163,8 @@ def compute_responses(
157163 only select models that have not been through validation yet.
158164 store_responses (bool): whether to locally store the responses.
159165 load_from_local (bool): True to load responses from locally saved recordings.
166+ recompute_threshold_protocols (bool): True to re-compute rmp, rin, holding current and
167+ threshold current even when threshold output is available.
160168 Returns:
161169 emodels (list): list of emodels.
162170 """
@@ -183,6 +191,7 @@ def compute_responses(
183191 {
184192 "evaluator" : copy .deepcopy (cell_evaluator ),
185193 "parameters" : mo .parameters ,
194+ "threshold_data" : {} if recompute_threshold_protocols else mo .threshold_data ,
186195 }
187196 )
188197
0 commit comments