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

add cvode argument to apply_multiple_stimuli #191

Merged
merged 1 commit into from
Jul 8, 2024
Merged
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
8 changes: 6 additions & 2 deletions bluecellulab/analysis/inject_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def run_stimulus(
stimulus: Stimulus,
section: str,
segment: float,
cvode: bool = True,
) -> Recording:
"""Creates a cell and stimulates it with a given stimulus.

Expand All @@ -45,6 +46,7 @@ def run_stimulus(
stimulus: The input stimulus to inject into the cell.
section: Name of the section of cell where the stimulus is to be injected.
segment: The segment of the section where the stimulus is to be injected.
cvode: True to use variable time-steps. False for fixed time-steps.

Returns:
The voltage-time recording at the specified location.
Expand All @@ -61,7 +63,7 @@ def run_stimulus(
current_vector = neuron.h.Vector()
current_vector.record(iclamp._ref_i)
simulation = Simulation(cell)
simulation.run(stimulus.stimulus_time)
simulation.run(stimulus.stimulus_time, cvode=cvode)
current = np.array(current_vector.to_python())
voltage = cell.get_voltage_recording(neuron_section, segment)
time = cell.get_time()
Expand All @@ -78,6 +80,7 @@ def apply_multiple_stimuli(
section_name: str | None = None,
segment: float = 0.5,
n_processes: int | None = None,
cvode: bool = True,
) -> StimulusRecordings:
"""Apply multiple stimuli to the cell on isolated processes.

Expand All @@ -91,6 +94,7 @@ def apply_multiple_stimuli(
If None, the stimuli are applied at the soma[0] of the cell.
segment: The segment of the section where the stimuli are applied.
n_processes: The number of processes to use for running the stimuli.
cvode: True to use variable time-steps. False for fixed time-steps.

Returns:
A dictionary where the keys are the names of the stimuli and the values
Expand Down Expand Up @@ -140,7 +144,7 @@ def apply_multiple_stimuli(
else:
raise ValueError("Unknown stimulus name.")

task_args.append((cell.template_params, stimulus, section_name, segment))
task_args.append((cell.template_params, stimulus, section_name, segment, cvode))

with IsolatedProcess(processes=n_processes) as pool:
# Map expects a function and a list of argument tuples
Expand Down