Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudon committed Sep 19, 2024
1 parent 020549e commit 87b23ad
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
14 changes: 8 additions & 6 deletions emodel_generalisation/adaptation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def build_resistance_models(

# it seems dask does not quite work on this (to investigate, but multiprocessing is fast enough)
df = func(df, access_point, parallel_factory="multiprocessing")

models = {}
for emodel in emodels:
_df = df[df.emodel == emodel]
Expand All @@ -93,13 +92,16 @@ def build_resistance_models(
if len(rin[rin < 0]) == 0:
try:
coeffs, extra = Polynomial.fit(np.log10(scaler), np.log10(rin), 3, full=True)
if extra[0] < rcond_min:
models[emodel] = {
"resistance": {"polyfit_params": coeffs.convert().coef.tolist()},
"shape": exemplar_data[key],
}
if extra[0] > rcond_min:
print(f"resistance fit for {key} of {emodel} is not so good")
models[emodel] = {
"resistance": {"polyfit_params": coeffs.convert().coef.tolist()},
"shape": exemplar_data[key],
}
except (np.linalg.LinAlgError, TypeError):
print(f"fail to fit emodel {emodel}")
else:
print(f"resistance fit for {key} of {emodel} has negative rin")
return df[df.emodel.isin(models)], models


Expand Down
7 changes: 6 additions & 1 deletion emodel_generalisation/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,13 @@ def _get_resistance_models(exemplar_df, exemplar_data, scales_params):
"""We fit the scale/Rin relation for AIS and soma."""
models = {}
for emodel in exemplar_df.emodel:
Path(f"local/{emodel}").mkdir(parents=True, exist_ok=True)
models[emodel] = build_all_resistance_models(
access_point, [emodel], exemplar_data[emodel], scales_params
access_point,
[emodel],
exemplar_data[emodel],
scales_params,
fig_path=Path(f"local/{emodel}"),
)
return models

Expand Down
4 changes: 1 addition & 3 deletions emodel_generalisation/model/bpopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ def __init__(
location,
target_voltage=None,
voltage_precision=0.1,
stimulus_duration=500.0,
stimulus_duration=1000.0,
upper_bound=0.2,
lower_bound=-0.2,
strict_bounds=True,
Expand Down Expand Up @@ -912,7 +912,6 @@ def get_voltage_base(
self, holding_current, cell_model, param_values, sim, isolate, timeout=None
):
"""Calculate voltage base for a certain holding current"""

self.stimuli[0].amp = holding_current
response = BPEMProtocol.run(
self, cell_model, param_values, sim=sim, isolate=isolate, timeout=timeout
Expand Down Expand Up @@ -1102,7 +1101,6 @@ def __init__(
"totduration": stimulus_totduration,
"holding_current": None,
}

self.recording_name = f"{name}.{location.name}.v"
stimulus = eCodes["step"](location=location, **stimulus_definition)
recordings = [
Expand Down
4 changes: 2 additions & 2 deletions emodel_generalisation/model/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def _define_Rin_protocol(


def _define_holding_protocol(
efeatures, strict_bounds=False, ais_recording=False, max_depth=7, stimulus_duration=500.0
efeatures, strict_bounds=False, ais_recording=False, max_depth=7, stimulus_duration=1000.0
):
"""Define the search holding current protocol"""
target_voltage = None
Expand Down Expand Up @@ -1013,7 +1013,7 @@ def __init__(
self.rin_step_duration = 500.0
self.rin_step_amp = -0.02
self.rin_totduration = self.rin_step_delay + self.rin_step_duration
self.search_holding_duration = 500.0
self.search_holding_duration = 1000.0
self.search_threshold_step_delay = 500.0
self.search_threshold_step_duration = 2000.0
self.search_threshold_totduration = 3000.0
Expand Down

0 comments on commit 87b23ad

Please sign in to comment.