cnmodel.morphology package¶
cnmodel.morphology.hoc_reader¶
-
class
cnmodel.morphology.hoc_reader.HocReader(hoc)[source] Bases:
objectProvides useful methods for reading hoc structures.
Parameters: hoc – Either a hoc object that hs been already created, or a string that defines a hoc file name. -
add_groups_by_section_list(names)[source] Add a new section groups from the hoc variables indicated in names.
Parameters: - names (list) –
- List containing variable names as strings. Each name must refer to a list of
- Sections in hoc. If a dict is supplied instead, then it maps {hoc_list_name: section_group_name}.
- effects (modifies) (Side) –
- ----------------------- – calls add_section_group
- names (list) –
-
add_section_group(name, sections, overwrite=False)[source] Declare a grouping of sections (or section names). Sections may be grouped by any arbitrary criteria (cell, anatomical type, etc).
Parameters: - name (str) – name of the section group
- sections (list) – section names or hoc Section objects.
-
find_hoc_hname(regex)[source] Find hoc names matching a pattern
Parameters: regex (str) – Regular expression (Python Re module) to search for. Returns: The names of HOC objects whose hname matches regex. Return type: list
-
get_branch(root)[source] Return all sections in a branch, starting with root.
Parameters: root – The NEURON section object.
-
get_density(section, mechanism)[source] Get density mechanism that may be found the section. mechanism is a list [‘name’, ‘gbarname’]. This is needed because some mechanisms do not adhere to any convention and may have a different kind of ‘gbarname’ than ‘gbar<name>_mechname’ returns the average of the conductance density, as that may range across different values in a section (e.g., can vary by segments)
Parameters: - section – The NEURON section object.
- mechanism (list) – mechanism is a list [‘name’, ‘gbarname’]. It is used to retrieve the mechanism density from HOC as segment.name.gbarname.
Returns: Return type: Mean conductance of the selected mechanism in the section, averaged across all segments of the section.
-
get_geometry()[source] modified from:neuronvisio Generate structures that describe the geometry of the sections and their segments (all segments are returned)
Returns: - vertexes (record array containing {pos: (x,y,z), dia, sec_id}) – for each segment.
- edges (array of pairs indicating the indexes of connected) – vertexes.
- Side effects
- ———— – Modifies vertexes and edges.
-
get_mechanisms(section)[source] Get a set of all of the mechanisms inserted into a given section
Parameters: section – The NEURON section object. Returns: Return type: A list of mechanism names
-
get_sec_info(section)[source] Get the info of the given section modified from: neuronvisio
Parameters: section – The NEURON section object. Returns: containing the information, with html formatting. Return type: str
-
get_section(sec_name)[source] Get the section associated with the section name
Parameters: sec_name (str) – The name of the section object. Returns: Return type: The hoc Section object with the given name.
-
get_section_group(name)[source] Get a section group by name :param name: name of the group (dendrite, for example) :type name: str
Returns: Return type: The set of section names in the group name.
-
get_section_lists()[source] Search through all of the hoc variables to find those that are “SectionLists”
-
get_section_prefixes()[source] Go through all the sections and generate a dictionary mapping their name prefixes to the list of sections with that prefix.
For example, with sections names axon[0], axon[1], ais[0], and soma[0], we would generate the following structure:
- {‘axon’: [‘axon[0]’, ‘axon[1]’],
- ‘ais’: [‘ais[0]’], ‘soma’: [‘soma[0]’]}
-
hoc_namespace()[source] Get a dict of the HOC namespace {‘variable_name’: hoc_object}. NOTE: this method requires NEURON >= 7.3
-
make_volume_data(resolution=1.0, max_size=500000000.0)[source] Using the current state of vertexes, edges, generates a scalar field useful for building isosurface or volumetric renderings.
Parameters: - resolution (float, default=1.0 microns) – width (um) of a single voxel in the scalar field.
- max_size (int) – maximum allowed scalar field size (bytes).
Returns: - * 3D scalar field indicating distance from nearest membrane,
- * 3D field indicating section IDs of nearest membrane,
- * QTransform that maps from 3D array indexes to original vertex – coordinates.
-
read_section_info()[source] Read all the information about the sections in the current hoc file Stores the result in the mechanisms class variable.
-
retrieve_coordinate(section)[source] Retrieve the coordinates of a section avoiding duplicates
Parameters: section – The NEURON section object. Returns: arrays of x, y, z, d for all the segments of the specified section. Return type: array
-
translate_branch(root, dx)[source] Move the branch beginning at root by dx.
Parameters: - root – The NEURON section object.
- dx (array) – Which must be an array of length 3 defining the translation.
-
cnmodel.morphology.morphology¶
-
class
cnmodel.morphology.morphology.Morphology[source] Bases:
objectBase class for morphological structure Provides the ability to read .hoc files for NEURON simulations.
-
hocReader(filename=None)[source] Access the hoc reader
Parameters: filename (str (default: None)) – The hoc file to read and save as the morphology object
-
init()[source]
-
swcReader(filename=None)[source] Access the swc reader (*NOT IMPLEMENTED*)
Parameters: filename (str (default: None)) – The swc file to read and save as the morphology object
-