pyneuroml.neuron package#

A package of utilities for exporting NEURON models to NeuroML 2 & for analysing/comparing NEURON models to NeuroML versions

Will use some some utilities from OpenSourceBrain/NEURONShowcase

pyneuroml.neuron.allca() None#

Prints Ca conc of all compartments (segments).

pyneuroml.neuron.allcells(var: str) None#

Prints information on all cells stored in the variable var.

Parameters:

var (str) – name of NEURON variable holding cells to get information for

pyneuroml.neuron.allsyns(var: str) None#

Prints information on network connections for all cells stored in the variable var

Parameters:

var (str) – name of NEURON variable holding cells to get information for

pyneuroml.neuron.allv() None#

Prints voltage of all compartments (segments).

pyneuroml.neuron.areainfo() None#

Provide information on the area of the cell.

Iterates over all sections of the current cell providing:

  • x, y, z, diameter information for each segment in the section

  • total area of the section

  • summary metrics for the whole cell

pyneuroml.neuron.cellinfo(doprint: str = '') dict#

Provide summary information on the current cell.

Returns a dictionary, and also prints out the information in yaml or json.

Parameters:

doprint (str) – toggle printing to std output and its format. Use “json” or “yaml” to print in the required format, any other value to disable printing.

Returns:

cellinfo dict

pyneuroml.neuron.cellinfohoc() None#

Provide information on current cell.

Uses the hoc utility function. Please prefer the cellinfo function instead, which is written in pure Python and provides the output in JSON which makes it easier to compare information from different cells.

pyneuroml.neuron.export_mod_to_neuroml2(mod_file: str)#

Helper function to export a mod file describing an ion channel to NeuroML2 format.

Note that these exports usually require more manual work before they are the converstion is complete. This method tries to take as much information as it can from the mod file to convert it into a NeuroML2 channel file.

Please use pynml-channelanalysis and pynml-modchannelanalysis commands to generate steady state etc. plots for the two implementations to compare them.

See also: https://docs.neuroml.org/Userdocs/CreatingNeuroMLModels.html#b-convert-channels-to-neuroml

Parameters:

mod_file (str) – full path to mod file

pyneuroml.neuron.export_to_neuroml1(hoc_file, nml1_file_name, level=1, validate=True)#

Export to NeuroML1.

NOTE: NeuroML1 is deprecated and supporting functions will be removed in a future release. Please use NeuroML2.

pyneuroml.neuron.export_to_neuroml2(hoc_or_python_file: str, nml2_file_name: str, includeBiophysicalProperties: bool = True, separateCellFiles: bool = False, known_rev_potentials: dict = {}, validate: bool = True) None#

Export NEURON hoc morphology files to NeuroML2 format.

Please note that the conversion of NEURON Python scripts is not yet implemented.

Parameters:
  • hoc_or_python_file (str) – NEURON hoc or Python file to convert

  • nml2_file_name (str) – name of NeuroML2 file to save to

  • includeBiophysicalProperties (bool) – whether or not to include biophysical properties in the conversion

  • separateCellFiles – whether cells should be exported to individual files

  • known_rev_potentials (dict with ions as keys, and their reveral potentials) – known reversal potentials

  • validate (bool) – whether the generated files should be validated

pyneuroml.neuron.get_seg_midpoint(seg: int, nseg: int) float#

Get mid point of segment

The total section is from 0 -> 1.

Parameters:
  • seg (int) – segment to get mid point of

  • nseg (int) – total number of segments

Returns:

location of mid point of segment in (0, 1)

pyneuroml.neuron.get_utils_hoc() Path#

Get full path of utils.hoc file

Returns:

pathlib.Path object for utils.hoc file

pyneuroml.neuron.getinfo(seclist: list, doprint: str = '', listall: bool = False)#

Provide detailed information on the provided section list.

Returns a dictionary, and also prints out the information in yaml or json.

Parameters:
  • doprint (str) – toggle printing to std output and its format. Use “json” or “yaml” to print in the required format, any other value to disable printing.

  • listall (bool) – also list mechs that are not present on any sections

Returns:

dict

pyneuroml.neuron.load_hoc_or_python_file(hoc_or_python_file: str) bool#

Load a NEURON hoc file or Python script.

Note: loading Python scripts is not yet supported.

Parameters:

hoc_or_python_file (str) – NEURON hoc or Python file to convert

Returns:

True if file was loaded, False if an error occurred

pyneuroml.neuron.morphinfo(section: str | None = None, doprint: str = '') dict#

Provides morphology of the provided section.

Returns a dictionary, and also prints out the information in yaml or json.

Parameters:
  • section (str or None) – section name, current section if None (default)

  • doprint (str) – toggle printing to std output and its format. Use “json” or “yaml” to print in the required format, any other value to disable printing.

Returns:

morphology information dict

pyneuroml.neuron.morphinfohoc(section: str | None = None) None#

Provides information on the morphology of the currently accessed section.

Uses the hoc utility function. Please prefer the morph function instead, which is written in pure Python and provides the output in JSON which makes it easier to compare information from different cells.

Parameters:

section (str or None) – section name, current section if None (default)

pyneuroml.neuron.replace_brackets(astring: str) str#

Replaces the [] in strings with _. if ] is the last char, just skips it.

Parameters:

astring (str) – id to convert

Returns:

converted id

pyneuroml.neuron.rm_NML_str(astring: str) str#

Replaces the _NML2 suffix from names to ease comparison

Parameters:

astring (str) – string to modify

Returns:

new string

pyneuroml.neuron.secinfo(section: str = '', doprint: str = 'json')#

Print summary information on provided section, like an expanded psection():

  • number of segments in the section,

  • voltage of the section

  • total area

  • total ri

  • information in each segment - start - end - area - ri

Returns a dictionary, and also prints out the information in yaml or json.

Parameters:
  • section (str) – section to investigate, or current section if “”

  • doprint (str) – toggle printing to std output and its format. Use “json” or “yaml” to print in the required format, any other value to disable printing.

Returns:

section information dict

pyneuroml.neuron.secinfohoc(section: str = '') None#

Provide information on current section, like an expanded psection(). Uses the hoc utility function. Please prefer the cellinfo function instead, which is written in pure Python and provides the output in JSON which makes it easier to compare information from different cells.

pyneuroml.neuron.analysis module#

Utilities to analyse NEURON models.