Skip to content

Commit

Permalink
Merge pull request #86 from darshanmandge/cvode_update
Browse files Browse the repository at this point in the history
Disable CVODE if neuron_dt is None
  • Loading branch information
AurelienJaquier authored Nov 29, 2023
2 parents ca5c960 + 6870d6f commit 1883200
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
3 changes: 2 additions & 1 deletion bluepyemodel/evaluation/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ def get_evaluator_from_access_point(
and validation efeatures be added to the evaluator.
timeout (float): duration (in second) after which the evaluation of a
protocol will be interrupted.
use_fixed_dt_recordings (bool): whether to record at a fixed dt of 0.1 ms.
use_fixed_dt_recordings (bool): used for legacy currentscape
to record at a fixed dt of 0.1 ms.
record_ions_and_currents (bool): whether to add the ion and non-specific currents
and the ionic concentration to the recordings.
Expand Down
37 changes: 27 additions & 10 deletions bluepyemodel/evaluation/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def define_recording(recording_conf, use_fixed_dt_recordings=False):
recording_conf (dict): configuration of the recording. Must contain the type of the
recording as well as information about the location of the recording (see function
define_location).
use_fixed_dt_recordings (bool): whether to record at a fixed dt of 0.1 ms.
use_fixed_dt_recordings (bool): used for legacy currentscape
to record at a fixed dt of 0.1 ms.
Returns:
FixedDtRecordingCustom or LooseDtRecordingCustom
Expand All @@ -125,19 +126,23 @@ def define_recording(recording_conf, use_fixed_dt_recordings=False):
return rec_class(name=recording_conf["name"], location=location, variable=variable)


def define_protocol(protocol_configuration, stochasticity=False, use_fixed_dt_recordings=False):
def define_protocol(
protocol_configuration, stochasticity=False, use_fixed_dt_recordings=False, dt=None
):
"""Create a protocol.
Args:
protocol_configuration (ProtocolConfiguration): configuration of the protocol
stochasticity (bool): Should the stochastic channels be stochastic or
deterministic
use_fixed_dt_recordings (bool): whether to record at a fixed dt of 0.1 ms.
use_fixed_dt_recordings (bool): used for legacy currentscape to record at a fixed dt
of 0.1 ms. However, Simulations will be run based on dt.
dt (float): NEURON dt for fixed time step simulation. If None, variable
dt will be used.
Returns:
Protocol
"""
cvode_active = True
cvode_active = not dt

recordings = []
for rec_conf in protocol_configuration.recordings:
Expand Down Expand Up @@ -393,6 +398,7 @@ def define_protocols(
include_validation_protocols,
stochasticity,
use_fixed_dt_recordings,
dt,
):
"""Instantiate several efeatures"""

Expand All @@ -401,7 +407,7 @@ def define_protocols(
if not include_validation_protocols and protocols_def.validation:
continue
protocols[protocols_def.name] = define_protocol(
protocols_def, stochasticity, use_fixed_dt_recordings
protocols_def, stochasticity, use_fixed_dt_recordings, dt
)

return protocols
Expand Down Expand Up @@ -440,6 +446,7 @@ def define_optimisation_protocol(
stochasticity=True,
efel_settings=None,
use_fixed_dt_recordings=False,
dt=None,
):
"""Create a meta protocol in charge of running the other protocols.
Expand All @@ -451,14 +458,17 @@ def define_optimisation_protocol(
stochasticity (bool): Should the stochastic channels be stochastic or
deterministic
efel_settings (dict): eFEl settings.
use_fixed_dt_recordings (bool): whether to record at a fixed dt of 0.1 ms.
use_fixed_dt_recordings (bool): used for legacy currentscape
to record at a fixed dt of 0.1 ms.
dt (float): NEURON dt for fixed time step simulation. If None, variable dt will be used.
"""

protocols = define_protocols(
fitness_calculator_configuration,
include_validation_protocols,
stochasticity,
use_fixed_dt_recordings,
dt,
)

efeatures = define_efeatures(
Expand All @@ -482,6 +492,7 @@ def define_threshold_based_optimisation_protocol(
max_depth_holding_search=7,
max_depth_threshold_search=10,
spikecount_timeout=50,
dt=None,
):
"""Create a meta protocol in charge of running the other protocols.
Expand All @@ -501,20 +512,23 @@ def define_threshold_based_optimisation_protocol(
will search for the rheobase.
strict_holding_bounds (bool): to adaptively enlarge bounds if holding current is outside
when set to False
use_fixed_dt_recordings (bool): whether to record at a fixed dt of 0.1 ms.
use_fixed_dt_recordings (bool): used for legacy currentscape
to record at a fixed dt of 0.1 ms.
max_depth_holding_search (int): maximum depth for the binary search for the
holding current
max_depth_threshold_search (int): maximum depth for the binary search for the
threshold current
spikecount_timeout (float): timeout for spikecount computation, if timeout is reached,
we set spikecount=2 as if many spikes were present, to speed up bisection search.
dt (float): NEURON dt for fixed time step simulation. If None, variable dt will be used.
"""

protocols = define_protocols(
fitness_calculator_configuration,
include_validation_protocols,
stochasticity,
use_fixed_dt_recordings,
dt,
)

efeatures = define_efeatures(
Expand Down Expand Up @@ -581,7 +595,7 @@ def get_simulator(stochasticity, cell_model, dt=None, mechanisms_directory=None,
Args:
stochasticity (bool): allow the use of simulator for stochastic channels
cell_model (CellModel): used to check if any stochastic channels are present
dt (float): if not None, cvode will be disabled and fixed timesteps used.
dt (float): NEURON dt for fixed time step simulation. If None, variable dt will be used.
mechanisms_directory (str or Path): path to the directory containing the mechanisms
cvode_minstep (float): minimum time step allowed for a CVODE step.
"""
Expand Down Expand Up @@ -639,7 +653,8 @@ def create_evaluator(
include_validation_protocols (bool): should the validation protocols
and validation efeatures be added to the evaluator.
mechanisms_directory (str or Path): path to the directory containing the mechanisms.
use_fixed_dt_recordings (bool): whether to record at a fixed dt of 0.1 ms.
use_fixed_dt_recordings (bool): used for legacy currentscape
to record at a fixed dt of 0.1 ms.
Returns:
CellEvaluator
Expand Down Expand Up @@ -673,6 +688,7 @@ def create_evaluator(
max_depth_holding_search=pipeline_settings.max_depth_holding_search,
max_depth_threshold_search=pipeline_settings.max_depth_threshold_search,
spikecount_timeout=pipeline_settings.spikecount_timeout,
dt=pipeline_settings.neuron_dt,
)
else:
main_protocol, features = define_optimisation_protocol(
Expand All @@ -681,6 +697,7 @@ def create_evaluator(
stochasticity=stochasticity,
efel_settings=pipeline_settings.efel_settings,
use_fixed_dt_recordings=use_fixed_dt_recordings,
dt=pipeline_settings.neuron_dt,
)

fitness_calculator = define_fitness_calculator(features)
Expand Down

0 comments on commit 1883200

Please sign in to comment.