Skip to content

Commit

Permalink
Add default value for segx param, improve docs vcs: #minor (#127)
Browse files Browse the repository at this point in the history
* DOCS: add explanation on segx param

* fix code style

* add default value of segx to 0.5
  • Loading branch information
anilbey authored Feb 5, 2024
1 parent d7a5240 commit b87d55e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bluecellulab/cell/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,28 +377,31 @@ def add_ais_recording(self, dt: Optional[float] = None) -> None:
self.add_recording("self.axonal[1](0.5)._ref_v", dt=dt)

def add_voltage_recording(
self, section: "neuron.h.Section", segx: float, dt: Optional[float] = None
self, section: "neuron.h.Section", segx: float = 0.5, dt: Optional[float] = None
) -> None:
"""Add a voltage recording to a certain section at a given segment
(segx).
Args:
section: Section to record from (Neuron section pointer).
segx: Segment x coordinate.
dt: Recording time step. If not provided, the recording step will default to the simulator's time step.
segx: Segment x coordinate. Specify a value between 0 and 1.
0 is typically the end closest to the soma, 1 is the distal end.
dt: Recording time step. If not provided, the recording step will
default to the simulator's time step.
"""
var_name = f"neuron.h.{section.name()}({segx})._ref_v"
self.add_recording(var_name, dt)

def get_voltage_recording(
self, section: "neuron.h.Section", segx: float
self, section: "neuron.h.Section", segx: float = 0.5
) -> np.ndarray:
"""Get a voltage recording for a certain section at a given segment
(segx).
Args:
section: Section to record from (Neuron section pointer).
segx: Segment x coordinate.
segx: Segment x coordinate. Specify a value between 0 and 1.
0 is typically the end closest to the soma, 1 is the distal end.
Returns:
A NumPy array containing the voltage recording values.
Expand All @@ -419,14 +422,14 @@ def add_allsections_voltagerecordings(self):
"""Add a voltage recording to every section of the cell."""
all_sections = public_hoc_cell(self.cell).all
for section in all_sections:
self.add_voltage_recording(section, segx=0.5, dt=self.record_dt)
self.add_voltage_recording(section, dt=self.record_dt)

def get_allsections_voltagerecordings(self) -> dict[str, np.ndarray]:
"""Get all the voltage recordings from all the sections."""
all_section_voltages = {}
all_sections = public_hoc_cell(self.cell).all
for section in all_sections:
recording = self.get_voltage_recording(section, segx=0.5)
recording = self.get_voltage_recording(section)
all_section_voltages[section.name()] = recording
return all_section_voltages

Expand Down

0 comments on commit b87d55e

Please sign in to comment.