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

Fix: Make sure param in final works #36

Merged
merged 1 commit into from
Feb 9, 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
14 changes: 4 additions & 10 deletions emodel_generalisation/model/bpopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@


class eFELFeatureBPEM(eFELFeature):

"""eFEL feature extra"""

SERIALIZED_FIELDS = (
Expand Down Expand Up @@ -318,7 +317,6 @@ def check_recordings(recordings, icell, sim):


class BPEMProtocol(ephys.protocols.SweepProtocol):

"""Base protocol"""

def __init__(
Expand Down Expand Up @@ -479,7 +477,6 @@ def instantiate(self, sim=None, icell=None):


class ResponseDependencies:

"""To add to a protocol to specify that it depends on the responses of other protocols"""

def __init__(self, dependencies=None):
Expand Down Expand Up @@ -536,7 +533,6 @@ def run(


class ProtocolWithDependencies(BPEMProtocol, ResponseDependencies):

"""To add to a protocol to specify that it depends on the responses of other protocols"""

def __init__(
Expand Down Expand Up @@ -577,7 +573,6 @@ def _run(


class ReboundBurst(BPEMProtocol):

"""Protocol for rebound bursting of thalamic cells."""

def __init__(
Expand All @@ -603,6 +598,7 @@ def get_holding_current_from_voltage(
isolate=None,
timeout=None,
responses=None,
max_depth=10,
):
"""Run bisection search to get holding current that match holding voltage."""
# maybe not the best, this is copied from normal holding search
Expand All @@ -619,6 +615,7 @@ def get_holding_current_from_voltage(
self.stimulus.location,
target_voltage=target_voltage,
stimulus_duration=2000.0,
max_depth=max_depth,
)
if self.stimulus.holding_current is not None:
hold_prot.stimulus.delay = 1000
Expand All @@ -642,6 +639,7 @@ def run(
isolate,
timeout,
responses,
max_depth=20,
)

if self.stimulus.amp_voltage is not None:
Expand All @@ -653,12 +651,12 @@ def run(
isolate,
timeout,
responses,
max_depth=10,
)
return BPEMProtocol.run(self, cell_model, param_values, sim, isolate, timeout, responses)


class ThresholdBasedProtocol(ProtocolWithDependencies):

"""Protocol having rheobase-rescaling capabilities. When using ThresholdBasedProtocol,
the current amplitude and step amplitude of the stimulus will be ignored and replaced by
values obtained from the holding current and rheobase of the cell model respectively."""
Expand Down Expand Up @@ -695,7 +693,6 @@ def run(


class RMPProtocol(BPEMProtocol):

"""Protocol consisting of a step of amplitude zero"""

def __init__(self, name, location, target_voltage, stimulus_duration=500.0):
Expand Down Expand Up @@ -756,7 +753,6 @@ def run(


class RinProtocol(ProtocolWithDependencies):

"""Protocol used to find the input resistance of a model"""

def __init__(
Expand Down Expand Up @@ -1054,7 +1050,6 @@ def bisection_search(


class SearchThresholdCurrent(ProtocolWithDependencies):

"""Protocol used to find the threshold current (rheobase) of a model"""

def __init__(
Expand Down Expand Up @@ -1267,7 +1262,6 @@ def bisection_search(


class ProtocolRunner(ephys.protocols.Protocol):

"""Meta-protocol in charge of running the other protocols in the correct order"""

def __init__(self, protocols, name="ProtocolRunner"):
Expand Down
9 changes: 4 additions & 5 deletions emodel_generalisation/model/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,6 @@ def _define_protocols(


class ProtocolConfiguration:

"""Container for the definition of a protocol"""

def __init__(
Expand Down Expand Up @@ -857,7 +856,6 @@ def _get_stim(stimulus, sec_id):


class EFeatureConfiguration:

"""Container for the definition of an EFeature"""

def __init__(
Expand Down Expand Up @@ -956,7 +954,6 @@ def as_dict(self):


class FitnessCalculatorConfiguration:

"""The goal of this class is to store the results of an efeature extraction (efeatures
and protocols) or to contain the results of a previous extraction retrieved from an access
point. This object is used for the creation of the fitness calculator.
Expand Down Expand Up @@ -1943,8 +1940,10 @@ def get_emodel_data(access_point, combo, morphology_path, morph_modifiers):
model_configuration=model_configuration,
morph_modifiers=modifiers.get_synth_modifiers(combo, morph_modifiers=morph_modifiers),
)

emodel_params = access_point.final[combo["emodel"]]["params"]
if "params" in access_point.final[combo["emodel"]]:
emodel_params = access_point.final[combo["emodel"]]["params"]
else:
emodel_params = access_point.final[combo["emodel"]]["parameters"]
return cell, fitness_calculator_configuration, emodel_params


Expand Down
Loading