netpyne.support.morphology module
Module with support functions for morphology
- class netpyne.support.morphology.Cell(name='neuron', soma=None, apic=None, dend=None, axon=None)[source]
Bases:
object
- netpyne.support.morphology.load(filename, fileformat=None, cell=None, use_axon=True, xshift=0, yshift=0, zshift=0)[source]
Load an SWC from filename and instantiate inside cell. Code kindly provided by @ramcdougal.
- Parameters:
morphology (filename = .swc file containing)
(Default (cell = Cell() object.) – None, creates new object)
file (filename = the filename of the SWC)
Default (use_axon = include the axon?) – True (yes)
xshift
yshift
cell (zshift = use to position the)
- Returns:
Cell() object with populated soma, axon, dend, & apic fields
- Minimal example:
# pull the morphology for the demo from NeuroMorpho.Org from PyNeuronToolbox import neuromorphoorg with open(‘c91662.swc’, ‘w’) as f: f.write(neuromorphoorg.morphology(‘c91662’)) cell = load_swc(filename)
- netpyne.support.morphology.sequential_spherical(xyz)[source]
Converts sequence of cartesian coordinates into a sequence of line segments defined by spherical coordinates.
- Parameters:
array (xyz = 2d numpy) – cartesian coordinates (x,y,z) tracing out a path in 3D space.
in (each row specifies a point) – cartesian coordinates (x,y,z) tracing out a path in 3D space.
- Returns:
r = lengths of each line segment (1D array) theta = angles of line segments in XY plane (1D array) phi = angles of line segments down from Z axis (1D array)
- netpyne.support.morphology.spherical_to_cartesian(r, theta, phi)[source]
Simple conversion of spherical to cartesian coordinates
- Parameters:
r
theta
coordinates (phi = scalar spherical)
- Returns:
x,y,z = scalar cartesian coordinates
- netpyne.support.morphology.find_coord(targ_length, xyz, rcum, theta, phi)[source]
Find (x,y,z) ending coordinate of segment path along section path.
- Parameters:
path (xyz = coordinates specifying the section) – from the begining of the section path
starting – from the begining of the section path
path
xyz (phi = angles between each coordinate in)
theta
xyz
- netpyne.support.morphology.interpolate_jagged(xyz, nseg)[source]
Interpolates along a jagged path in 3D
- Parameters:
coordinates (xyz = section path specified in cartesian)
path (nseg = number of segment paths in section)
- Returns:
interp_xyz = interpolated path
- netpyne.support.morphology.shapeplot(h, ax, sections=None, order='pre', cvals=None, clim=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>, legend=True, **kwargs)[source]
Plots a 3D shapeplot
- Parameters:
neuron (h = hocObject to interface with)
plotting (ax = matplotlib axis for)
plotted (sections = list of h.Section() objects to be)
sections (order = { None= use h.allsec() to get) – ‘pre’= pre-order traversal of morphology }
useful (cvals = list/array with values mapped to color by cmap;) – for displaying voltage, calcium or some other state variable across the shapeplot.
matplotlib (**kwargs passes on to)
- Returns:
lines = list of line objects making up shapeplot
- netpyne.support.morphology.shapeplot_animate(v, lines, nframes=None, tscale='linear', clim=[-80, 50], cmap=<matplotlib.colors.LinearSegmentedColormap object>)[source]
Returns animate function which updates color of shapeplot
- netpyne.support.morphology.mark_locations(h, section, locs, markspec='or', **kwargs)[source]
Marks one or more locations on along a section. Could be used to mark the location of a recording or electrical stimulation.
- Parameters:
neuron (h = hocObject to interface with)
section (section = reference to)
1 (locs = float between 0 and)
floats (or array of)
marker (optional arguments specify details of)
- Returns:
line = reference to plotted markers
- netpyne.support.morphology.root_sections(h)[source]
Returns a list of all sections that have no parent.
- netpyne.support.morphology.leaf_sections(h)[source]
Returns a list of all sections that have no children.
- netpyne.support.morphology.root_indices(sec_list)[source]
Returns the index of all sections without a parent.
- netpyne.support.morphology.allsec_preorder(h)[source]
Alternative to using h.allsec(). This returns all sections in order from the root. Traverses the topology each neuron in “pre-order”
- netpyne.support.morphology.add_pre(h, sec_list, section, order_list=None, branch_order=None)[source]
A helper function that traverses a neuron’s morphology (or a sub-tree) of the morphology in pre-order. This is usually not necessary for the user to import.
- netpyne.support.morphology.dist_between(h, seg1, seg2)[source]
Calculates the distance between two segments. I stole this function from a post by Michael Hines on the NEURON forum (www.neuron.yale.edu/phpbb/viewtopic.php?f=2&t=2114)
- netpyne.support.morphology.all_branch_orders(h)[source]
Produces a list branch orders for each section (following pre-order tree traversal)