Sections¶
Sections are cilindrical representations of pieces of a cell. They have a length and a diameter. Sections are the main building block of a simulation in NEURON.
You can use the connect() method to connect Sections together.
Sections can be subdivided into Segments by specifying
nseg, the simulator calculates the voltage for each segment, thereby affecting the
spatial resolution of the simulation. The position of a segment is represented by its
normalized position along the axis of the Segment. This means that a Segment at x=0.5
is in the middle of the Section. By default every section consists of 1 segment and
the potential will be calculated for 3 points: At the start (0) and end (1) of the
section, and in the middle of every segment (0.5). For 2 segments the simulator would
calculate at 0, 0.333…, 0.666… and 1.
from patch import p
s = p.Section()
s.L = 40
s.diam = 0.4
s.nseg = 11
s2 = p.Section()
s.connect(s2)
from neuron import h
s = h.Section()
s.L = 40
s.diam = 0.4
s.nseg = 11
s2 = h.Section()
s.connect(s2)
Retrieving segments¶
Sections can be called with an x to retrieve the segment at
that x. The segments of a patch.objects.Section can also be iterated over.
s.nseg = 5
seg05 = s(0.5)
print(seg05)
for seg in s:
print(seg)
s.nseg = 5
seg05 = s(0.5)
print(seg05)
for seg in s:
print(seg)
Recording¶
You can tell Patch to record the membrane potential of your patch.objects.Section at
one or multiple locations by calling the .record function and giving it an x. If
x is omitted 0.5 is used.
In NEURON you’d have to create a Vector and keep track of it
somewhere and find a way to link it back to the patch.objects.Section it recorded, in
Patch a section automatically stores its recording vectors in section.recordings.
s.record(x=1.0)
v = h.Vector()
v.record(s(1.0))
all_recorders.append(v)
Position in space¶
With Patch it’s very straightforward to define the 3D path of your Section through
space. Call the .add_3d function with a 2D array containing the xyz data of your
points. Optionally, you can pass another array of diameters.
s.add_3d([[0, 0, 0], [2, 2, 2]], diameters)
s.push()
points = [[0, 0, 0], [2, 2, 2]]
for point, diameter in zip(points, diameters):
h.pt3dadd(*point, diameter)
h.pop_section()
Full reference¶
Here is a full list of methods that Patch patched or added to the interface of
NEURON Sections:
- class patch.objects.Section(interpreter: PythonHocInterpreter, ptr)[source]
- add_3d(points, diameters=None)[source]
Add new 3D points to this section xyz data.
- Parameters:
points – A 2D array of xyz points.
diameters (float | list[float]) – A scalar or array of diameters corresponding to the points. Default value is the section diameter.
- connect(target, *args, **kwargs)[source]
Connect this section to another one as child section.
- connect_synapse(target, **kwargs)[source]
Connect a Segment of this Section to a target.
Usually used to connect the membrane potential to a point process.
- iclamp(amplitude: float = 1, *, x: float = 0.5, delay: float = 0, duration: float = 100) IClamp[source]
Create a current clamp on the section.
- Parameters:
x (float) – Location along the segment from 0 to 1.
delay (float) – Duration of the pre-step holding interval, from 0 to delay ms.
duration (float) – Duration of the step interval, from delay to delay + duration ms.
amplitude (float | list[float]) – Can be a single value to define the current during the step (delay to delay + duration ms), or a sequence to play after delay ms. This will play 1 value of the sequence into the clamp per timestep.
- Returns:
The current clamp placed in the section.
- Return type:
- insert(*args, **kwargs)[source]
Insert a mechanism into the Section.
- property parent
Returns the parent of the Section, or
None
- property points
Return the 3d point information associated to this section.
- pop()[source]
Pop this section off the section stack.
- push()[source]
Return a context manager that pushes this Section onto the section stack and takes it off when the context is exited.
- record(x=None)[source]
Record the Section at a certain point.
- Parameters:
x (float) – Arcpoint, defaults to
__arc__if omitted.
- set_dimensions(length, diameter)[source]
Set the length and diameter of the piece of cable this Section will represent in the simulation.
- set_segments(segments)[source]
Set the number of discrete points where equations are solved during simulation.
- synapse(factory, *args, store=False, attributes=None, **kwargs)[source]
Insert a synapse into the Section.
- Parameters:
factory (Callable) – Callable that creates a point process, is given the Section as first argument and passes on all other args.
store (bool) – Store the synapse on the Section in a
synapsesattribute.
- vclamp(voltage: float = -70, *, x: float = 0.5, before: float = 0, duration: float = 100, after: float = 0, holding=-70) SEClamp[source]
Create a voltage clamp on the section.
- Parameters:
x (float) – Location along the segment from 0 to 1.
before (float) – Duration of the pre-step holding interval, from 0 to delay ms.
duration (float) – Duration of the step interval, from delay to delay + duration ms.
after (float) – Duration of the post-step holding interval, from delay + duration to delay + duration + after ms.
voltage (float | list[float]) – Can be a single value to define the voltage during the step (delay to delay + duration ms), or 3 values to define the pre-step, step and post-step voltages altogether.
holding (float) – If voltage is a single value, holding is used for the pre-step and post-step voltages.
- Returns:
The single electrode voltage clamp placed in the section.
- Return type:
- wholetree()[source]
Return the whole tree of child Sections.
- Return type: