patch package

patch.core module

patch.core.assert_connectable(obj, label=None)[source]

Assert whether an object could be used as a Connectable.

Parameters

label (str) – Optional label to display to describe the object if the assertion fails.

patch.core.is_point_process(name)[source]

Check if a PointProcess with name exists on the HocInterpreter.

Parameters

name (str) – Name of the PointProcess to look for. Needs to be a known attribute of neuron.h.

Returns

Whether an attribute with name exists on neuron.h and has functions matching those expected to be present on a PointProcess.

Return type

bool

patch.core.is_section(obj)[source]

Check if the class name of an object is Section.

patch.core.transform(obj)[source]

Transform an object to its NEURON representation, if the __neuron__ magic method is present.

patch.core.transform_arc(obj, *args, **kwargs)[source]

Get an arclength object on a NEURON object. Calls the __arc__ magic method on the callable object if present, otherwise returns the transformed object.

patch.core.transform_netcon(obj)[source]

Transform an object into the pointer that should be connected, if the __netcon__ magic method is present.

patch.core.transform_record(obj)[source]

Transform an object into the pointer that should be recorded, if the __record__ magic method is present.

patch.interpreter module

class patch.interpreter.ParallelContext(*args, **kwargs)[source]

Bases: patch.objects.PythonHocObject

broadcast(data, root=0)[source]

Broadcast either a Vector or arbitrary picklable data. If data is a Vector, the Vectors are resized and filled with the data from the Vector in the root node. If data is not a Vector, it is pickled, transmitted and returned from this function to all nodes.

Parameters
  • data (Vector or any picklable object.) – The data to broadcast to the nodes.

  • root (int) – The id of the node that is broadcasting the data.

Returns

None (Vectors filled) or the transmitted data

Raises

BroadcastError if neuron.hoc.HocObjects that aren’t Vectors are transmitted

cell(gid, nc)[source]
setup_transfer(*args, **kwargs)
source_var(*args, **kwargs)
target_var(*args, **kwargs)
class patch.interpreter.PythonHocInterpreter[source]

Bases: object

IClamp(x=0.5, sec=None)[source]
NetCon(source, target, *args, **kwargs)[source]
NetStim(*args, **kwargs)
ParallelCon(a, b, output=True, *args, **kwargs)[source]
ParallelContext()[source]
PointProcess(*args, **kwargs)
SEClamp(sec, x=0.5)[source]
Section(*args, **kwargs)
SectionRef(*args, sec=None)[source]
Segment(interpreter, ptr, section, **kwargs)
VecStim(pattern=None, *args, **kwargs)[source]
Vector(interpreter, ptr)
cas()[source]
continuerun(time_stop, add=False)[source]
finitialize(initial=None)[source]
load_extension(extension)[source]
nrn_load_dll(path)[source]
property parallel
record(target)[source]
classmethod register_hoc_object(hoc_object_class)[source]
run()[source]
property time

patch.objects module

class patch.objects.Connectable[source]

Bases: object

class patch.objects.IClamp(interpreter, ptr)[source]

Bases: patch.objects.PythonHocObject, patch.objects.WrapsPointers

class patch.objects.NetCon(interpreter, ptr)[source]

Bases: patch.objects.PythonHocObject

record(vector=None)[source]
class patch.objects.NetStim(*args, **kwargs)[source]

Bases: patch.objects.PythonHocObject, patch.objects.Connectable

class patch.objects.PointProcess(*args, **kwargs)[source]

Bases: patch.objects.PythonHocObject, patch.objects.Connectable, patch.objects.WrapsPointers

Wrapper for all point processes (membrane and synapse mechanisms).

stimulate(pattern=None, weight=0.04, delay=0.0, **kwargs)[source]

Stimulate a point process.

Parameters
  • pattern (list[float]) – Specific stimulus event times to play into the point process.

  • kwargs – All keyword arguments will be passed set on the NetStim

class patch.objects.PointerWrapper(attr)[source]

Bases: object

class patch.objects.PythonHocObject(interpreter, ptr)[source]

Bases: object

__deref__(obj)[source]

Magic method that is called when a strong reference needs to be removed from the object.

__neuron__()[source]

Magic method that is called when this object is passed to NEURON.

__ref__(obj)[source]

Magic method that is called when a strong reference needs to be stored on the object.

class patch.objects.SEClamp(interpreter, ptr)[source]

Bases: patch.objects.PythonHocObject, patch.objects.WrapsPointers

class patch.objects.Section(*args, **kwargs)[source]

Bases: patch.objects.PythonHocObject, patch.objects.Connectable, patch.objects.WrapsPointers

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 or array) – 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_points(target, x=None, **kwargs)[source]

Connect a Segment of this Section to a target. Usually used to connect the membrane potential to a point process.

iclamp(x=0.5, delay=0, duration=100, amplitude=0)[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 (Union[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

objects.SEClamp

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, **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 synapses attribute.

vclamp(x=0.5, delay=0, duration=100, after=0, voltage=- 70, holding=- 70)[source]

Create a voltage 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.

  • after (float) – Duration of the post-step holding interval, from delay + duration to delay + duration + after ms.

  • voltage (Union[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

objects.SEClamp

wholetree()[source]

Return the whole tree of child Sections

Return type

List[patch.Section]

class patch.objects.SectionRef(interpreter, ptr)[source]

Bases: patch.objects.PythonHocObject

property child
class patch.objects.Segment(interpreter, ptr, section, **kwargs)[source]

Bases: patch.objects.PythonHocObject, patch.objects.Connectable, patch.objects.WrapsPointers

class patch.objects.VecStim(*args, **kwargs)[source]

Bases: patch.objects.PythonHocObject, patch.objects.Connectable

property pattern
property vector
class patch.objects.Vector(interpreter, ptr)[source]

Bases: patch.objects.PythonHocObject

record(target, *args, **kwargs)[source]
class patch.objects.WrapsPointers[source]

Bases: object

Module contents