nml Module (NeuroML Core classes)#

These NeuroML core classes are Python representations of the Component Types defined in the NeuroML standard . These can be used to build NeuroML models in Python, and these models can then be exported to the standard XML NeuroML representation. These core classes also contain some utility functions to make it easier for users to carry out common tasks.

Each NeuroML Component Type is represented here as a Python class. Due to implementation limitations, whereas NeuroML Component Types use lower camel case naming, the Python classes here use upper camel case naming. So, for example, the adExIaFCell Component Type in the NeuroML schema becomes the AdExIaFCell class here, and expTwoSynapse becomes the ExpTwoSynapse class.

The child and children elements that NeuroML Component Types can have are represented in the Python classes as variables. The variable names, to distinguish them from class names, use snake case. So for example, the cell NeuroML Component Type has a corresponding Cell Python class here. The biophysicalProperties child Component Type in cell is represented as the biophysical_properties list variable in the Cell Python class. The class signatures list all the child/children elements and text fields that the corresponding Component Type possesses. To again use the Cell class as an example, the construction signature is this:

class neuroml.nml.nml.Cell(neuro_lex_id=None, id=None, metaid=None, notes=None, properties=None, annotation=None, morphology_attr=None, biophysical_properties_attr=None, morphology=None, biophysical_properties=None, extensiontype_=None, **kwargs_)

As can be seen here, it includes both the biophysical_properties and morphology child elements as variables.

Please see the examples in the NeuroML documentation to see usage examples of libNeuroML. Please also note that this module is also included in the top level of the neuroml package, so you can use these classes by importing neuroml:

from neuroml import AdExIaFCell

List of Component classes#

This documentation is auto-generated from the NeuroML schema. In case of issues, please refer to the schema documentation for clarifications. If the schema documentation does not resolve the issue, please contact us.

GeneratedsSuperSuper#

class neuroml.nml.generatedssupersuper.GeneratedsSuperSuper#

Bases: object

Super class for GeneratedsSuper.

Any bits that must go into every libNeuroML class should go here.

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

GdsCollector#

class neuroml.nml.generatedscollector.GdsCollector(messages=None)#

Bases: object

add_message(msg)#
clear_messages()#
get_messages()#
print_messages()#
write_messages(outstream)#

AdExIaFCell#

class neuroml.nml.nml.AdExIaFCell(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, C: a Nml2Quantity_capacitance (required) = None, g_l: a Nml2Quantity_conductance (required) = None, EL: a Nml2Quantity_voltage (required) = None, reset: a Nml2Quantity_voltage (required) = None, VT: a Nml2Quantity_voltage (required) = None, thresh: a Nml2Quantity_voltage (required) = None, del_t: a Nml2Quantity_voltage (required) = None, tauw: a Nml2Quantity_time (required) = None, refract: a Nml2Quantity_time (required) = None, a: a Nml2Quantity_conductance (required) = None, b: a Nml2Quantity_current (required) = None, gds_collector_=None, **kwargs_)#

Bases: BaseCellMembPotCap

AdExIaFCell – Model based on Brette R and Gerstner W ( 2005 ) Adaptive Exponential Integrate-and-Fire Model as an Effective Description of Neuronal Activity. J Neurophysiol 94:3637-3642

Parameters:
  • gL (conductance) – Leak conductance

  • EL (voltage) – Leak reversal potential

  • VT (voltage) – Spike threshold

  • thresh (voltage) – Spike detection threshold

  • reset (voltage) – Reset potential

  • delT (voltage) – Slope factor

  • tauw (time) – Adaptation time constant

  • refract (time) – Refractory period

  • a (conductance) – Sub-threshold adaptation variable

  • b (current) – Spike-triggered adaptation variable

  • C (capacitance) – Total capacitance of the cell membrane

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

AlphaCondSynapse#

class neuroml.nml.nml.AlphaCondSynapse(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, tau_syn: a float (required) = None, e_rev: a float (required) = None, gds_collector_=None, **kwargs_)#

Bases: BasePynnSynapse

AlphaCondSynapse – Alpha synapse: rise time and decay time are both tau_syn. Conductance based synapse.

Parameters:
  • e_rev (none) –

  • tau_syn (none) –

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

AlphaCurrSynapse#

class neuroml.nml.nml.AlphaCurrSynapse(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, tau_syn: a float (required) = None, gds_collector_=None, **kwargs_)#

Bases: BasePynnSynapse

AlphaCurrSynapse – Alpha synapse: rise time and decay time are both tau_syn. Current based synapse.

Parameters:

tau_syn (none) –

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

AlphaCurrentSynapse#

class neuroml.nml.nml.AlphaCurrentSynapse(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, tau: a Nml2Quantity_time (required) = None, ibase: a Nml2Quantity_current (required) = None, gds_collector_=None, **kwargs_)#

Bases: BaseCurrentBasedSynapse

AlphaCurrentSynapse – Alpha current synapse: rise time and decay time are both tau.

Parameters:
  • tau (time) – Time course for rise and decay

  • ibase (current) – Baseline current increase after receiving a spike

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

AlphaSynapse#

class neuroml.nml.nml.AlphaSynapse(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, gbase: a Nml2Quantity_conductance (required) = None, erev: a Nml2Quantity_voltage (required) = None, tau: a Nml2Quantity_time (required) = None, gds_collector_=None, **kwargs_)#

Bases: BaseConductanceBasedSynapse

AlphaSynapse – Ohmic synapse model where rise time and decay time are both tau. Max conductance reached during this time ( assuming zero conductance before ) is gbase * weight.

Parameters:
  • tau (time) – Time course of rise/decay

  • gbase (conductance) – Baseline conductance, generally the maximum conductance following a single spike

  • erev (voltage) – Reversal potential of the synapse

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

Annotation#

class neuroml.nml.nml.Annotation(anytypeobjs_=None, gds_collector_=None, **kwargs_)#

Bases: BaseWithoutId

Annotation – A structured annotation containing metadata, specifically RDF or property elements

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

Base#

class neuroml.nml.nml.Base(id: a NmlId (required) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: BaseWithoutId

Base – Anything which can have a unique (within its parent) id of the form NmlId (spaceless combination of letters, numbers and underscore).

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BaseCell#

class neuroml.nml.nml.BaseCell(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: Standalone

BaseCell – Base type of any cell ( e. g. point neuron like izhikevich2007Cell , or a morphologically detailed Cell with segment s ) which can be used in a population

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BaseCellMembPotCap#

class neuroml.nml.nml.BaseCellMembPotCap(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, C: a Nml2Quantity_capacitance (required) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: BaseCell

BaseCellMembPotCap – Any cell with a membrane potential v with voltage units and a membrane capacitance C. Also defines exposed value iSyn for current due to external synapses and iMemb for total transmembrane current ( usually channel currents plus iSyn )

Parameters:

C (capacitance) – Total capacitance of the cell membrane

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BaseConductanceBasedSynapse#

class neuroml.nml.nml.BaseConductanceBasedSynapse(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, gbase: a Nml2Quantity_conductance (required) = None, erev: a Nml2Quantity_voltage (required) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: BaseVoltageDepSynapse

BaseConductanceBasedSynapse – Synapse model which exposes a conductance g in addition to producing a current. Not necessarily ohmic!! cno_0000027

Parameters:
  • gbase (conductance) – Baseline conductance, generally the maximum conductance following a single spike

  • erev (voltage) – Reversal potential of the synapse

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BaseConductanceBasedSynapseTwo#

class neuroml.nml.nml.BaseConductanceBasedSynapseTwo(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, gbase1: a Nml2Quantity_conductance (required) = None, gbase2: a Nml2Quantity_conductance (required) = None, erev: a Nml2Quantity_voltage (required) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: BaseVoltageDepSynapse

BaseConductanceBasedSynapseTwo – Synapse model suited for a sum of two expTwoSynapses which exposes a conductance g in addition to producing a current. Not necessarily ohmic!! cno_0000027

Parameters:
  • gbase1 (conductance) – Baseline conductance 1

  • gbase2 (conductance) – Baseline conductance 2

  • erev (voltage) – Reversal potential of the synapse

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BaseConnection#

class neuroml.nml.nml.BaseConnection(id: a NmlId (required) = None, neuro_lex_id: a NeuroLexId (optional) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: BaseNonNegativeIntegerId

BaseConnection – Base of all synaptic connections (chemical/electrical/analog, etc.) inside projections

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BaseConnectionNewFormat#

class neuroml.nml.nml.BaseConnectionNewFormat(id: a NmlId (required) = None, neuro_lex_id: a NeuroLexId (optional) = None, pre_cell: a string (required) = None, pre_segment: a NonNegativeInteger (optional) = '0', pre_fraction_along: a ZeroToOne (optional) = '0.5', post_cell: a string (required) = None, post_segment: a NonNegativeInteger (optional) = '0', post_fraction_along: a ZeroToOne (optional) = '0.5', extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: BaseConnection

BaseConnectionNewFormat – Base of all synaptic connections with preCell, postSegment, etc. See BaseConnectionOldFormat

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BaseConnectionOldFormat#

class neuroml.nml.nml.BaseConnectionOldFormat(id: a NmlId (required) = None, neuro_lex_id: a NeuroLexId (optional) = None, pre_cell_id: a Nml2PopulationReferencePath (required) = None, pre_segment_id: a NonNegativeInteger (optional) = '0', pre_fraction_along: a ZeroToOne (optional) = '0.5', post_cell_id: a Nml2PopulationReferencePath (required) = None, post_segment_id: a NonNegativeInteger (optional) = '0', post_fraction_along: a ZeroToOne (optional) = '0.5', extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: BaseConnection

BaseConnectionOldFormat – Base of all synaptic connections with preCellId, postSegmentId, etc. Note: this is not the best name for these attributes, since Id is superfluous, hence BaseConnectionNewFormat

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

validate_Nml2PopulationReferencePath(value)#
validate_Nml2PopulationReferencePath_patterns_ = [['^((\\.\\./)?([a-zA-Z_][a-zA-Z0-9_]*)((\\[[0-9]+\\])|(/[0-9]+)+((/[a-zA-Z_][a-zA-Z0-9_]*)?)/?))$']]#

BaseCurrentBasedSynapse#

class neuroml.nml.nml.BaseCurrentBasedSynapse(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: BaseSynapse

BaseCurrentBasedSynapse – Synapse model which produces a synaptic current.

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BaseNonNegativeIntegerId#

class neuroml.nml.nml.BaseNonNegativeIntegerId(id: a NmlId (required) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: BaseWithoutId

BaseNonNegativeIntegerId – Anything which can have a unique (within its parent) id, which must be an integer zero or greater.

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BaseProjection#

class neuroml.nml.nml.BaseProjection(id: a NmlId (required) = None, presynaptic_population: a NmlId (required) = None, postsynaptic_population: a NmlId (required) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: Base

BaseProjection – Base for projection (set of synaptic connections) between two populations

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BasePynnSynapse#

class neuroml.nml.nml.BasePynnSynapse(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, tau_syn: a float (required) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: BaseSynapse

BasePynnSynapse – Base type for all PyNN synapses. Note, the current I produced is dimensionless, but it requires a membrane potential v with dimension voltage

Parameters:

tau_syn (none) –

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BaseSynapse#

class neuroml.nml.nml.BaseSynapse(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: Standalone

BaseSynapse – Base type for all synapses, i. e. ComponentTypes which produce a current ( dimension current ) and change Dynamics in response to an incoming event. cno_0000009

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BaseVoltageDepSynapse#

class neuroml.nml.nml.BaseVoltageDepSynapse(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: BaseSynapse

BaseVoltageDepSynapse – Base type for synapses with a dependence on membrane potential

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BaseWithoutId#

class neuroml.nml.nml.BaseWithoutId(extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: GeneratedsSuper

BaseWithoutId – Base element without ID specified yet, e.g. for an element with a particular requirement on its id which does not comply with NmlId (e.g. Segment needs nonNegativeInteger).

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BiophysicalProperties#

class neuroml.nml.nml.BiophysicalProperties(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, membrane_properties: a MembraneProperties (required) = None, intracellular_properties: a IntracellularProperties (optional) = None, extracellular_properties: a ExtracellularProperties (optional) = None, gds_collector_=None, **kwargs_)#

Bases: Standalone

BiophysicalProperties – The biophysical properties of the cell , including the membraneProperties and the intracellularProperties

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BiophysicalProperties2CaPools#

class neuroml.nml.nml.BiophysicalProperties2CaPools(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, membrane_properties2_ca_pools: a MembraneProperties2CaPools (required) = None, intracellular_properties2_ca_pools: a IntracellularProperties2CaPools (optional) = None, extracellular_properties: a ExtracellularProperties (optional) = None, gds_collector_=None, **kwargs_)#

Bases: Standalone

BiophysicalProperties2CaPools – The biophysical properties of the cell , including the membraneProperties2CaPools and the intracellularProperties2CaPools for a cell with two Ca pools

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BlockMechanism#

class neuroml.nml.nml.BlockMechanism(type: a BlockTypes (required) = None, species: a NmlId (required) = None, block_concentration: a Nml2Quantity_concentration (required) = None, scaling_conc: a Nml2Quantity_concentration (required) = None, scaling_volt: a Nml2Quantity_voltage (required) = None, gds_collector_=None, **kwargs_)#

Bases: BaseWithoutId

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

BlockingPlasticSynapse#

class neuroml.nml.nml.BlockingPlasticSynapse(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, gbase: a Nml2Quantity_conductance (required) = None, erev: a Nml2Quantity_voltage (required) = None, tau_decay: a Nml2Quantity_time (required) = None, tau_rise: a Nml2Quantity_time (required) = None, plasticity_mechanism: a PlasticityMechanism (optional) = None, block_mechanism: a BlockMechanism (optional) = None, gds_collector_=None, **kwargs_)#

Bases: ExpTwoSynapse

BlockingPlasticSynapse – Biexponential synapse that allows for optional block and plasticity mechanisms, which can be expressed as child elements.

Parameters:
  • tauRise (time) –

  • tauDecay (time) –

  • gbase (conductance) – Baseline conductance, generally the maximum conductance following a single spike

  • erev (voltage) – Reversal potential of the synapse

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

Case#

class neuroml.nml.nml.Case(condition: a string (optional) = None, value: a string (required) = None, gds_collector_=None, **kwargs_)#

Bases: GeneratedsSuper

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

Cell#

class neuroml.nml.nml.Cell(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, morphology_attr: a NmlId (optional) = None, biophysical_properties_attr: a NmlId (optional) = None, morphology: a Morphology (optional) = None, biophysical_properties: a BiophysicalProperties (optional) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: BaseCell

Cell – Cell with segment s specified in a morphology element along with details on its biophysicalProperties . NOTE: this can only be correctly simulated using jLEMS when there is a single segment in the cell, and v of this cell represents the membrane potential in that isopotential segment.

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

add_channel_density(nml_cell_doc, cd_id, ion_channel, cond_density, erev='0.0 mV', group_id='all', ion='non_specific', ion_chan_def_file='')#

Add channel density.

Parameters:
  • nml_cell_doc (NeuroMLDocument) – cell NeuroML document to which channel density is to be added

  • cd_id (str) – id for channel density

  • ion_channel (str) – name of ion channel

  • cond_density (str) – value of conductance density with units

  • erev (str) – value of reversal potential with units

  • group_id (str) – segment groups to add to

  • ion (str) – name of ion

  • ion_chan_def_file (str) – path to NeuroML2 file defining the ion channel, if empty, it assumes the channel is defined in the same file

Returns:

added channel density

Return type:

ChannelDensity

add_channel_density_v(channel_density_type, nml_cell_doc, ion_chan_def_file='', **kwargs)#

Generic function to add channel density components to a Cell.

Parameters:
  • channel_density_type (str) – type of channel density to add. See https://docs.neuroml.org/Userdocs/Schemas/Cells.html for the complete list.

  • nml_cell_doc (NeuroMLDocument) – cell NeuroML document to which channel density is to be added

  • ion_chan_def_file (str) – path to NeuroML2 file defining the ion channel, if empty, it assumes the channel is defined in the same file

  • kwargs (Any) – named arguments for required channel density type

Returns:

added channel density

add_intracellular_property(property_name, **kwargs)#

Generic function to add an intracellular property to the cell.

For a full list of membrane properties, see: https://docs.neuroml.org/Userdocs/Schemas/Cells.html?#intracellularproperties

Parameters:
  • property_name (str) – name of intracellular property to add

  • kwargs (Any) – named arguments for intracellular property to be added

Returns:

added property

add_membrane_property(property_name, **kwargs)#

Generic function to add a membrane property to the cell.

For a full list of membrane properties, see: https://docs.neuroml.org/Userdocs/Schemas/Cells.html?#membraneproperties

Please also see specific functions in this module, which are designed to be easier to use than this generic function.

Parameters:
  • property_name (str) – name of membrane to add

  • kwargs (Any) – named arguments for membrane property to be added

Returns:

added property

add_segment(prox, dist, seg_id=None, name=None, parent=None, fraction_along=1.0, group_id=None, use_convention=True, seg_type=None, reorder_segment_groups=True, optimise_segment_groups=True)#

Add a segment to the cell, to the provided segment group, creating it if required.

Parameters:
  • prox (list with 4 float entries: [x, y, z, diameter]) – proximal segment information

  • dist (list with 4 float entries: [x, y, z, diameter]) – dist segment information

  • seg_id (str) – explicit ID to set for segment When not provided, the function will automatically add an ID based on the number of segments already included in the cell. It is best to either always set an explicit ID or let the function set it automatically, but not to mix the two. A ValueError is raised if a segment with the provided ID already exists

  • name (str) – name of segment If a name is given, it is used. If no name is given, but a segment group is provided, the segment is named: “Seg<number>_<group name>” where <number> is the number of the segment in the segment group. (to be read as “segment <number> in <group>”; the group name should indicate the type here) If no name is given, and no segment group is provided, the segment is simply named: “Seg<segment id>”.

  • parent (Segment) – parent segment object

  • fraction_along (float) – where the new segment is connected to the parent (0: distal point, 1: proximal point)

  • group_id (str) –

    id of segment group to add the segment to If a segment group with this id does not exist, a new segment group will be created.

    The suggested convention is: axon_, soma_, dend_ for axonal, somatic, and dendritic segment groups respectively.

    Note that a newly created segment group will not be marked as an unbranched segment group. If you wish to add a segment to an unbranched segment group, please create one using add_unbranched_segment_group and then add segments to it.

  • use_convention (bool) – whether the segment or its group should be added to the global segment groups. The seg_type notes what global group this segment or its segment group should also be added to.

  • reorder_segment_groups (bool) –

    whether the groups should be reordered to put the default segment groups last after the segment has been added. This is required for a valid NeuroML file because segment groups included in the default groups should be declared before they are used in the default groups. When adding lots of segments, one may want to only reorder at the end of the process instead of after each segment is added.

    This is only relevant if use_convention=True.

  • optimise_segment_groups (bool) – toggle whether segment groups should be optimised after operation

Seg_type:

type of segment (“axon”, “dendrite”, “soma”) If use_convention is True, and a group_id is provided, the segment group will also be added to the default segment groups if it has not been previously added. If group_id is None, the segment will be added to the default groups instead.

If use_convention is False, this is unused.

Returns:

the created segment

Return type:

Segment

Raises:

ValueError – if seg_id is provided and a segment with this ID already exists

add_segment_group(group_id, neuro_lex_id=None, notes=None)#

Add a new general segment group.

The segments included in this group do not need to be contiguous. This segment group will not be automatically marked as a section using the required NeuroLex ID.

If a segment group with provided ID already exists, it will not be overwritten.

Parameters:
  • group_id (str) – ID of segment group

  • neuro_lex_id (str) – NeuroLex ID to use for segment group

  • notes (str) – Notes text to add

Returns:

new segment group

Return type:

SegmentGroup

add_unbranched_segment_group(group_id, notes=None)#

Add a new unbranched segment group.

This is similar to the add_segment_group method, but this segment group will be used to store contiguous segments, which form an unbranched section of a cell. It adds the NeuroLex ID for a neuronal branch to the segment group.

Parameters:
  • group_id (str) – ID of segment group

  • notes (str) – notes to add

Returns:

new segment group

Return type:

SegmentGroup

add_unbranched_segments(points, parent=None, fraction_along=1.0, group_id=None, use_convention=True, seg_type=None, reorder_segment_groups=True, optimise_segment_groups=True)#

Add an unbranched list of segments to the cell.

The list of points will include the first proximal point where this should be joined to the cell, followed by a list of distal points:

|-----|-----|-----|------|.....---|
p1    d1    d2    d3     d4       d N-1

So, a list of N points will create a list of N-1 segments

The list of points will be of the form:

[[x1, y1, z1, d1], [x2, y2, z2, d2] ...]

Please ensure that the first point, p1, is correctly set to ensure that this segment list is correctly connected to the rest of the cell.

Parameters:
  • points (list of [x, y, z, d] points) – 3D points to create the segments

  • parent (SegmentParent) – parent segment where first segment of list is to be attached

  • fraction_along (float) – where the new segment list is connected to the parent (0: distal point, 1: proximal point) Note that the second and following segments will all be added at the distal point of the previous segment

  • group_id (SegmentGroup) – segment group to add the segment to if a segment group does not already exist, it will be created

  • use_convention (bool) – whether helper segment groups should be created using the default convention See the documentation of the add_segment method for more information on the convention

  • seg_type (str) – type of segments (“axon”, “soma”, “dendrite”)

  • reorder_segment_groups (bool) –

    whether the groups should be reordered to put the default segment groups last after the segment has been added. This is required for a valid NeuroML file because segment groups included in the default groups should be declared before they are used in the default groups. When adding lots of segments, one may want to only reorder at the end of the process instead of after each segment is added.

    This is only relevant if use_convention=True.

  • optimise_segment_groups (bool) – toggle whether segment groups should be optimised after operation

Returns:

the segment group containing this new list of segments

Return type:

SegmentGroup

biophysinfo()#

Get information on the biophysical properties of the cell. :returns: None

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

create_unbranched_segment_group_branches(root_segment_id: int, use_convention: bool = True, reorder_segment_groups=True, optimise_segment_groups=True)#

Organise the segments of the cell into new segment groups that each form a single contiguous unbranched cell branch.

Note that the first segment (root segment) of a branch must have a proximal point that connects it to the rest of the neuronal morphology. If, when constructing these branches, a root segment is found that does not include a proximal point, one will be added using the get_actual_proximal method.

No other changes will be made to any segments, or to any pre-existing segment groups.

Parameters:
  • root_segment_id (int) – id of segment considered the root of the tree, generally the first soma segment

  • use_convention (bool) – toggle using NeuroML convention for segment groups

  • reorder_segment_groups (bool) –

    whether the groups should be reordered to put the default segment groups last after the segment has been added. This is required for a valid NeuroML file because segment groups included in the default groups should be declared before they are used in the default groups. When adding lots of segments, one may want to only reorder at the end of the process instead of after each segment is added.

    This is only relevant if use_convention=True.

  • optimise_segment_groups (bool) – toggle whether segment groups should be optimised after operation

Returns:

modified cell with new section groups

Return type:

neuroml.Cell

get_actual_proximal(segment_id: str) Point3DWithDiam#

Get the proximal point of a segment.

If the proximal for the segment is set to None, calculate the proximal on the parent using fraction_along and return it.

Parameters:

segment_id – ID of segment

Returns:

proximal point

get_all_distances_from_segment(seg_id=0)#

Get distances of all segments from the segment with id seg_id.

Useful to get distances of segments from the soma.

Uses networkx.single_source_dijkstra on the cell graph, without a target.

Parameters:

seg_id (int) – id of segment to get distances from

Returns:

pair of dictionaries for distance, path The return value is a tuple of two dictionaries keyed by target nodes. The first dictionary stores distance to each target node. The second stores the path to each target node.

get_all_segments_in_group(segment_group: SegmentGroup, assume_all_means_all: bool = True) List[int]#

Get all the segments in a segment group of the cell.

Parameters:
  • segment_group – segment group to get all segments of

  • assume_all_means_all – return all segments if the “all” segment group wasn’t explicitly defined

Returns:

list of segment ids

Return type:

list[int]

Raises:

Exception – if no segment group is found in the cell.

get_branching_points()#

Get segments where the cell morphology branches.

That is, the out-degree of the segment is > 1

Returns:

list of segment ids

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

get_distance(dest, source=0)#

Get path length between between two segments on a cell.

Uses networkx.dijkstra_path_length to compute the shortest path between source and dest

Parameters:
  • from (int) – id of segment to get distance from

  • to (int) – id of segment to get distance to

Returns:

float

get_extremeties()#

Get segments that are at the ends/tips of the neuronal morphology, with their distances from the soma.

Returns:

dict of segment ids and their distances from cell root as values

get_graph()#

Get a networkx DiGraph of the morphology of the cell with distances between the proximal point of a parent and the point where a child connects to it as the weights of the edges of the graph.

Please see https://networkx.org/documentation/stable/reference for information on networkx routines that can be used on this graph.

This method also stores the graph in the self.cell_graph attribute for future use.

Returns:

networkx.Graph

get_morphology_root()#

Return the root of the complete cell morphology.

This is usually the first segment of the soma, and there should only be one such segment.

Returns:

id of the root segment

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

get_ordered_segments_in_groups(group_list: List, check_parentage: bool = False, include_cumulative_lengths: bool = False, include_path_lengths: bool = False, path_length_metric: str = 'Path Length from root') Any#

Get ordered list of segments in specified groups, with additional information.

Note that this method orders segments by id, so the assumption is that all segment with id N + m will be a descendent of segment with id N in the segment group.

Parameters:
  • group_list (str or list(str)) – a group id or list of group ids to get segments from

  • check_parentage (bool) – verify parentage

  • include_cumulative_lengths (bool) – also include cummulative length of each segment from root

  • include_path_lengths (bool) – also include path lengths from segment group’s root segment to proximal and distal points of each segment

  • path_length_metric (str) – metric to use for path length (“Path Length from root” is currently the only supported option, and the default)

Returns:

depending on provided arguments:

  • if no additional options are provided, returns a dictionary with segment group ids as keys, and lists of ordered segments in those segment groups as values (ord_segs)

  • if only include_path_lengths is set, returns a tuple: [ord_segs, path_lengths_to_proximal , path_lengths_to_distal]

  • if only include_cumulative_lengths is set, returns a tuple: [ord_segs, cumulative_lengths]

  • if both include_path_lengths and include_cumulative_lengths are set, returns a tuple: [ord_segs, cumulative_lengths, path_lengths_to_proximal , path_lengths_to_distal]

Raises:

Exception if check_parentage is True and parentage cannot be verified

get_segment(segment_id: int) Segment#

Get segment object by its id

Parameters:

segment_id – ID of segment

Returns:

segment

Raises:

ValueError – if the segment is not found in the cell

get_segment_adjacency_list()#

Get the adjacency list of all segments in the cell morphology. Returns a dict where each key is a parent segment, and the value is the list of its children segments.

Segment without children (leaf segments) are not included as parents in the adjacency list.

This method also stores the computed adjacency list in self.adjacency_list for future use by other methods.

self.adjacency_list is populated each time this method is run, to ensure that users can regenerate it after making modifications to the cell morphology. If the morphology has not changed, one only needs to populate it once and then re-use it as required.

Returns:

dict with parent segment ids as keys and ids of their children as values

Return type:

dict[int, list[int]]

get_segment_group(sg_id: str) SegmentGroup#

Return the SegmentGroup object for the specified segment group id.

Parameters:

sg_id (str) – id of segment group to find

Returns:

SegmentGroup object of specified ID

Raises:

ValueError – if segment group is not found in cell

get_segment_group_info(group_id)#

Get information about a segment group

Parameters:

group_id (int) – id of segment group

Returns:

None

get_segment_groups_by_substring(substring: str) dict#

Get a dictionary of segment group IDs and the segment groups matching the specified substring

Parameters:

substring (str) – substring to match

Returns:

dictionary with segment group ID as key, and segment group as value

Raises:

ValueError – if no matching segment groups are found in cell

get_segment_ids_vs_segments() Dict#

Get a dictionary of segment IDs and the segments in the cell.

Returns:

dictionary with segment ID as key, and segment as value

get_segment_length(segment_id: str) float#

Get the length of the segment.

Parameters:

segment_id – ID of segment

Returns:

length of segment

get_segment_location_info(seg_id)#

Get location information about a particular segment.

Parameters:

seg_id (int) – id of segment to get information for

Returns:

a dictionary with various metrics about the segment

  • length of segment

  • distance from cell root

  • distance from nearest branching point

  • name of unbranched segment group segment belongs to (if any)

  • id of root segment of the unbranched segment group

  • distance from the segment group root segment

get_segment_surface_area(segment_id: str) float#

Get the surface area of the segment.

Parameters:

segment_id – ID of the segment

Returns:

surface area of segment

get_segment_volume(segment_id: str) float#

Get volume of segment

Parameters:

segment_id – ID of the segment

Returns:

volume of the segment

get_segments_at_distance(distance, src_seg=0)#

Get all segments at distance from the provided src_seg.

For each segment, it returns the fraction along the segment that the provided distance is at. For example, if segment N is 500 units long, and the distance cut-off is at 200, the fraction along is: 200/500.

Parameters:
  • src_seg (int) – id of segment to get distances from

  • distance (float) – distance to get segments at

Returns:

dict with segment ids as keys, and fraction along at which the cut off is as values

get_segments_by_substring(substring: str) dict#

Get a dictionary of segment IDs and the segment matching the specified substring

Parameters:

substring (str) – substring to match

Returns:

dictionary with segment ID as key, and segment as value

Raises:

Exception – if no segments are found

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

morphinfo(segment_detail=False)#

Show info on morphology of the cell. By default, since cells can have large numbers of segments and segment groups, it only provides metrics on the total numbers. To see details, pass segment_detail=True.

See also: get_segment_group_info.

Parameters:

segment_detail (bool) – toggle whether to show detailed information on segment groups and their segments

Returns:

None

optimise_segment_group(seg_group_id)#

Optimise segment group with id seg_group_id.

Parameters:

seg_group_id (str) – id of segment group to optimise

optimise_segment_groups()#

Optimise all segment groups in the cell.

This will:

  • deduplicate members and includes in segment groups

  • remove members that have already been included using a segment group

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

reorder_segment_groups()#

Move default segment groups to the end.

This is required so that the segment groups included in the default groups are defined before they are used.

Returns:

None

set_init_memb_potential(v, group_id='all')#

Set the initial membrane potential of the cell.

Parameters:
  • v (str) – value to set for membrane potential with units

  • group_id (str) – id of segment group to modify

set_resistivity(resistivity, group_id='all') None#

Set the resistivity of the cell

Parameters:

group_id (str) – segment group to modify

set_specific_capacitance(spec_cap, group_id='all')#

Set the specific capacitance for the cell.

Parameters:
  • spec_cap (str) – value of specific capacitance with units

  • group_id (str) – segment group to modify

set_spike_thresh(v, group_id='all')#

Set the spike threshold of the cell.

Parameters:
  • v (str) – value to set for spike threshold with units

  • group_id (str) – id of segment group to modify

setup_default_segment_groups(use_convention=True, default_groups=['all', 'soma_group'])#

Create default segment groups for the cell.

If use_convention is True, it also creates the provided default_groups SegmentGroups for convenience. By default, it creates the “all”, and “soma_group” groups since each cell must at least have a soma. Allowed values are: “all”, “soma_group”, “axon_group”, “dendrite_group”.

Parameters:
  • use_convention (bool) – whether helper segment groups should be created using the default convention

  • default_groups (list of strings) – list of default segment groups to create

Returns:

list of created segment groups (or empty list if none created)

Return type:

list

setup_nml_cell(use_convention=True, overwrite=False, default_groups=['all', 'soma_group'])#

Correctly initialise a NeuroML cell.

To be called after a new component has been created to initialise the cell with these properties:

  • Morphology: id=”morphology”

  • BiophysicalProperties: id=”biophys”:

    • MembraneProperties

    • IntracellularProperties

If use_convention is True, it also creates the provided default_groups SegmentGroups for convenience. By default, it creates the “all”, and “soma_group” groups since each cell must at least have a soma.

When dendritic and axonal segments are added, the add_segment function will create dendrite_group and axon_group groups as required.

Note that since this cell does not currently include a segment in its morphology, it is not a valid NeuroML construct. Use the add_segment and add_unbranched_segments functions to add segments and branches. They will also populate the default segment groups.

Parameters:
  • id (str) – id of the cell

  • use_convention (bool) – whether helper segment groups should be created using the default convention

  • overwrite (bool) – overwrite existing components

  • default_groups (list of strings) – list of default segment groups to create

Returns:

None

Return type:

None

summary(morph=True, biophys=True)#

Print cell summary.

Shows the number of segments and segment groups, and information on the biophysical properties of the cell. See the morphinfo and biophysinfo methods for more details.

Parameters:
  • morph (bool) – toggle showing/hiding morphology information

  • biophys (bool) – toggle showing/hiding biophysology information

Returns:

None

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

Cell2CaPools#

class neuroml.nml.nml.Cell2CaPools(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, morphology_attr: a NmlId (optional) = None, biophysical_properties_attr: a NmlId (optional) = None, morphology: a Morphology (optional) = None, biophysical_properties: a BiophysicalProperties (optional) = None, biophysical_properties2_ca_pools: a BiophysicalProperties2CaPools (optional) = None, gds_collector_=None, **kwargs_)#

Bases: Cell

Cell2CaPools – Variant of cell with two independent Ca2+ pools. Cell with segment s specified in a morphology element along with details on its biophysicalProperties . NOTE: this can only be correctly simulated using jLEMS when there is a single segment in the cell, and v of this cell represents the membrane potential in that isopotential segment.

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

add_channel_density(nml_cell_doc, cd_id, ion_channel, cond_density, erev='0.0 mV', group_id='all', ion='non_specific', ion_chan_def_file='')#

Add channel density.

Parameters:
  • nml_cell_doc (NeuroMLDocument) – cell NeuroML document to which channel density is to be added

  • cd_id (str) – id for channel density

  • ion_channel (str) – name of ion channel

  • cond_density (str) – value of conductance density with units

  • erev (str) – value of reversal potential with units

  • group_id (str) – segment groups to add to

  • ion (str) – name of ion

  • ion_chan_def_file (str) – path to NeuroML2 file defining the ion channel, if empty, it assumes the channel is defined in the same file

Returns:

added channel density

Return type:

ChannelDensity

add_channel_density_v(channel_density_type, nml_cell_doc, ion_chan_def_file='', **kwargs)#

Generic function to add channel density components to a Cell.

Parameters:
  • channel_density_type (str) – type of channel density to add. See https://docs.neuroml.org/Userdocs/Schemas/Cells.html for the complete list.

  • nml_cell_doc (NeuroMLDocument) – cell NeuroML document to which channel density is to be added

  • ion_chan_def_file (str) – path to NeuroML2 file defining the ion channel, if empty, it assumes the channel is defined in the same file

  • kwargs (Any) – named arguments for required channel density type

Returns:

added channel density

add_intracellular_property(property_name, **kwargs)#

Generic function to add an intracellular property to the cell.

For a full list of membrane properties, see: https://docs.neuroml.org/Userdocs/Schemas/Cells.html?#intracellularproperties

Parameters:
  • property_name (str) – name of intracellular property to add

  • kwargs (Any) – named arguments for intracellular property to be added

Returns:

added property

add_membrane_property(property_name, **kwargs)#

Generic function to add a membrane property to the cell.

For a full list of membrane properties, see: https://docs.neuroml.org/Userdocs/Schemas/Cells.html?#membraneproperties

Please also see specific functions in this module, which are designed to be easier to use than this generic function.

Parameters:
  • property_name (str) – name of membrane to add

  • kwargs (Any) – named arguments for membrane property to be added

Returns:

added property

add_segment(prox, dist, seg_id=None, name=None, parent=None, fraction_along=1.0, group_id=None, use_convention=True, seg_type=None, reorder_segment_groups=True, optimise_segment_groups=True)#

Add a segment to the cell, to the provided segment group, creating it if required.

Parameters:
  • prox (list with 4 float entries: [x, y, z, diameter]) – proximal segment information

  • dist (list with 4 float entries: [x, y, z, diameter]) – dist segment information

  • seg_id (str) – explicit ID to set for segment When not provided, the function will automatically add an ID based on the number of segments already included in the cell. It is best to either always set an explicit ID or let the function set it automatically, but not to mix the two. A ValueError is raised if a segment with the provided ID already exists

  • name (str) – name of segment If a name is given, it is used. If no name is given, but a segment group is provided, the segment is named: “Seg<number>_<group name>” where <number> is the number of the segment in the segment group. (to be read as “segment <number> in <group>”; the group name should indicate the type here) If no name is given, and no segment group is provided, the segment is simply named: “Seg<segment id>”.

  • parent (Segment) – parent segment object

  • fraction_along (float) – where the new segment is connected to the parent (0: distal point, 1: proximal point)

  • group_id (str) –

    id of segment group to add the segment to If a segment group with this id does not exist, a new segment group will be created.

    The suggested convention is: axon_, soma_, dend_ for axonal, somatic, and dendritic segment groups respectively.

    Note that a newly created segment group will not be marked as an unbranched segment group. If you wish to add a segment to an unbranched segment group, please create one using add_unbranched_segment_group and then add segments to it.

  • use_convention (bool) – whether the segment or its group should be added to the global segment groups. The seg_type notes what global group this segment or its segment group should also be added to.

  • reorder_segment_groups (bool) –

    whether the groups should be reordered to put the default segment groups last after the segment has been added. This is required for a valid NeuroML file because segment groups included in the default groups should be declared before they are used in the default groups. When adding lots of segments, one may want to only reorder at the end of the process instead of after each segment is added.

    This is only relevant if use_convention=True.

  • optimise_segment_groups (bool) – toggle whether segment groups should be optimised after operation

Seg_type:

type of segment (“axon”, “dendrite”, “soma”) If use_convention is True, and a group_id is provided, the segment group will also be added to the default segment groups if it has not been previously added. If group_id is None, the segment will be added to the default groups instead.

If use_convention is False, this is unused.

Returns:

the created segment

Return type:

Segment

Raises:

ValueError – if seg_id is provided and a segment with this ID already exists

add_segment_group(group_id, neuro_lex_id=None, notes=None)#

Add a new general segment group.

The segments included in this group do not need to be contiguous. This segment group will not be automatically marked as a section using the required NeuroLex ID.

If a segment group with provided ID already exists, it will not be overwritten.

Parameters:
  • group_id (str) – ID of segment group

  • neuro_lex_id (str) – NeuroLex ID to use for segment group

  • notes (str) – Notes text to add

Returns:

new segment group

Return type:

SegmentGroup

add_unbranched_segment_group(group_id, notes=None)#

Add a new unbranched segment group.

This is similar to the add_segment_group method, but this segment group will be used to store contiguous segments, which form an unbranched section of a cell. It adds the NeuroLex ID for a neuronal branch to the segment group.

Parameters:
  • group_id (str) – ID of segment group

  • notes (str) – notes to add

Returns:

new segment group

Return type:

SegmentGroup

add_unbranched_segments(points, parent=None, fraction_along=1.0, group_id=None, use_convention=True, seg_type=None, reorder_segment_groups=True, optimise_segment_groups=True)#

Add an unbranched list of segments to the cell.

The list of points will include the first proximal point where this should be joined to the cell, followed by a list of distal points:

|-----|-----|-----|------|.....---|
p1    d1    d2    d3     d4       d N-1

So, a list of N points will create a list of N-1 segments

The list of points will be of the form:

[[x1, y1, z1, d1], [x2, y2, z2, d2] ...]

Please ensure that the first point, p1, is correctly set to ensure that this segment list is correctly connected to the rest of the cell.

Parameters:
  • points (list of [x, y, z, d] points) – 3D points to create the segments

  • parent (SegmentParent) – parent segment where first segment of list is to be attached

  • fraction_along (float) – where the new segment list is connected to the parent (0: distal point, 1: proximal point) Note that the second and following segments will all be added at the distal point of the previous segment

  • group_id (SegmentGroup) – segment group to add the segment to if a segment group does not already exist, it will be created

  • use_convention (bool) – whether helper segment groups should be created using the default convention See the documentation of the add_segment method for more information on the convention

  • seg_type (str) – type of segments (“axon”, “soma”, “dendrite”)

  • reorder_segment_groups (bool) –

    whether the groups should be reordered to put the default segment groups last after the segment has been added. This is required for a valid NeuroML file because segment groups included in the default groups should be declared before they are used in the default groups. When adding lots of segments, one may want to only reorder at the end of the process instead of after each segment is added.

    This is only relevant if use_convention=True.

  • optimise_segment_groups (bool) – toggle whether segment groups should be optimised after operation

Returns:

the segment group containing this new list of segments

Return type:

SegmentGroup

biophysinfo()#

Get information on the biophysical properties of the cell. :returns: None

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

create_unbranched_segment_group_branches(root_segment_id: int, use_convention: bool = True, reorder_segment_groups=True, optimise_segment_groups=True)#

Organise the segments of the cell into new segment groups that each form a single contiguous unbranched cell branch.

Note that the first segment (root segment) of a branch must have a proximal point that connects it to the rest of the neuronal morphology. If, when constructing these branches, a root segment is found that does not include a proximal point, one will be added using the get_actual_proximal method.

No other changes will be made to any segments, or to any pre-existing segment groups.

Parameters:
  • root_segment_id (int) – id of segment considered the root of the tree, generally the first soma segment

  • use_convention (bool) – toggle using NeuroML convention for segment groups

  • reorder_segment_groups (bool) –

    whether the groups should be reordered to put the default segment groups last after the segment has been added. This is required for a valid NeuroML file because segment groups included in the default groups should be declared before they are used in the default groups. When adding lots of segments, one may want to only reorder at the end of the process instead of after each segment is added.

    This is only relevant if use_convention=True.

  • optimise_segment_groups (bool) – toggle whether segment groups should be optimised after operation

Returns:

modified cell with new section groups

Return type:

neuroml.Cell

get_actual_proximal(segment_id: str) Point3DWithDiam#

Get the proximal point of a segment.

If the proximal for the segment is set to None, calculate the proximal on the parent using fraction_along and return it.

Parameters:

segment_id – ID of segment

Returns:

proximal point

get_all_distances_from_segment(seg_id=0)#

Get distances of all segments from the segment with id seg_id.

Useful to get distances of segments from the soma.

Uses networkx.single_source_dijkstra on the cell graph, without a target.

Parameters:

seg_id (int) – id of segment to get distances from

Returns:

pair of dictionaries for distance, path The return value is a tuple of two dictionaries keyed by target nodes. The first dictionary stores distance to each target node. The second stores the path to each target node.

get_all_segments_in_group(segment_group: SegmentGroup, assume_all_means_all: bool = True) List[int]#

Get all the segments in a segment group of the cell.

Parameters:
  • segment_group – segment group to get all segments of

  • assume_all_means_all – return all segments if the “all” segment group wasn’t explicitly defined

Returns:

list of segment ids

Return type:

list[int]

Raises:

Exception – if no segment group is found in the cell.

get_branching_points()#

Get segments where the cell morphology branches.

That is, the out-degree of the segment is > 1

Returns:

list of segment ids

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

get_distance(dest, source=0)#

Get path length between between two segments on a cell.

Uses networkx.dijkstra_path_length to compute the shortest path between source and dest

Parameters:
  • from (int) – id of segment to get distance from

  • to (int) – id of segment to get distance to

Returns:

float

get_extremeties()#

Get segments that are at the ends/tips of the neuronal morphology, with their distances from the soma.

Returns:

dict of segment ids and their distances from cell root as values

get_graph()#

Get a networkx DiGraph of the morphology of the cell with distances between the proximal point of a parent and the point where a child connects to it as the weights of the edges of the graph.

Please see https://networkx.org/documentation/stable/reference for information on networkx routines that can be used on this graph.

This method also stores the graph in the self.cell_graph attribute for future use.

Returns:

networkx.Graph

get_morphology_root()#

Return the root of the complete cell morphology.

This is usually the first segment of the soma, and there should only be one such segment.

Returns:

id of the root segment

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

get_ordered_segments_in_groups(group_list: List, check_parentage: bool = False, include_cumulative_lengths: bool = False, include_path_lengths: bool = False, path_length_metric: str = 'Path Length from root') Any#

Get ordered list of segments in specified groups, with additional information.

Note that this method orders segments by id, so the assumption is that all segment with id N + m will be a descendent of segment with id N in the segment group.

Parameters:
  • group_list (str or list(str)) – a group id or list of group ids to get segments from

  • check_parentage (bool) – verify parentage

  • include_cumulative_lengths (bool) – also include cummulative length of each segment from root

  • include_path_lengths (bool) – also include path lengths from segment group’s root segment to proximal and distal points of each segment

  • path_length_metric (str) – metric to use for path length (“Path Length from root” is currently the only supported option, and the default)

Returns:

depending on provided arguments:

  • if no additional options are provided, returns a dictionary with segment group ids as keys, and lists of ordered segments in those segment groups as values (ord_segs)

  • if only include_path_lengths is set, returns a tuple: [ord_segs, path_lengths_to_proximal , path_lengths_to_distal]

  • if only include_cumulative_lengths is set, returns a tuple: [ord_segs, cumulative_lengths]

  • if both include_path_lengths and include_cumulative_lengths are set, returns a tuple: [ord_segs, cumulative_lengths, path_lengths_to_proximal , path_lengths_to_distal]

Raises:

Exception if check_parentage is True and parentage cannot be verified

get_segment(segment_id: int) Segment#

Get segment object by its id

Parameters:

segment_id – ID of segment

Returns:

segment

Raises:

ValueError – if the segment is not found in the cell

get_segment_adjacency_list()#

Get the adjacency list of all segments in the cell morphology. Returns a dict where each key is a parent segment, and the value is the list of its children segments.

Segment without children (leaf segments) are not included as parents in the adjacency list.

This method also stores the computed adjacency list in self.adjacency_list for future use by other methods.

self.adjacency_list is populated each time this method is run, to ensure that users can regenerate it after making modifications to the cell morphology. If the morphology has not changed, one only needs to populate it once and then re-use it as required.

Returns:

dict with parent segment ids as keys and ids of their children as values

Return type:

dict[int, list[int]]

get_segment_group(sg_id: str) SegmentGroup#

Return the SegmentGroup object for the specified segment group id.

Parameters:

sg_id (str) – id of segment group to find

Returns:

SegmentGroup object of specified ID

Raises:

ValueError – if segment group is not found in cell

get_segment_group_info(group_id)#

Get information about a segment group

Parameters:

group_id (int) – id of segment group

Returns:

None

get_segment_groups_by_substring(substring: str) dict#

Get a dictionary of segment group IDs and the segment groups matching the specified substring

Parameters:

substring (str) – substring to match

Returns:

dictionary with segment group ID as key, and segment group as value

Raises:

ValueError – if no matching segment groups are found in cell

get_segment_ids_vs_segments() Dict#

Get a dictionary of segment IDs and the segments in the cell.

Returns:

dictionary with segment ID as key, and segment as value

get_segment_length(segment_id: str) float#

Get the length of the segment.

Parameters:

segment_id – ID of segment

Returns:

length of segment

get_segment_location_info(seg_id)#

Get location information about a particular segment.

Parameters:

seg_id (int) – id of segment to get information for

Returns:

a dictionary with various metrics about the segment

  • length of segment

  • distance from cell root

  • distance from nearest branching point

  • name of unbranched segment group segment belongs to (if any)

  • id of root segment of the unbranched segment group

  • distance from the segment group root segment

get_segment_surface_area(segment_id: str) float#

Get the surface area of the segment.

Parameters:

segment_id – ID of the segment

Returns:

surface area of segment

get_segment_volume(segment_id: str) float#

Get volume of segment

Parameters:

segment_id – ID of the segment

Returns:

volume of the segment

get_segments_at_distance(distance, src_seg=0)#

Get all segments at distance from the provided src_seg.

For each segment, it returns the fraction along the segment that the provided distance is at. For example, if segment N is 500 units long, and the distance cut-off is at 200, the fraction along is: 200/500.

Parameters:
  • src_seg (int) – id of segment to get distances from

  • distance (float) – distance to get segments at

Returns:

dict with segment ids as keys, and fraction along at which the cut off is as values

get_segments_by_substring(substring: str) dict#

Get a dictionary of segment IDs and the segment matching the specified substring

Parameters:

substring (str) – substring to match

Returns:

dictionary with segment ID as key, and segment as value

Raises:

Exception – if no segments are found

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

morphinfo(segment_detail=False)#

Show info on morphology of the cell. By default, since cells can have large numbers of segments and segment groups, it only provides metrics on the total numbers. To see details, pass segment_detail=True.

See also: get_segment_group_info.

Parameters:

segment_detail (bool) – toggle whether to show detailed information on segment groups and their segments

Returns:

None

optimise_segment_group(seg_group_id)#

Optimise segment group with id seg_group_id.

Parameters:

seg_group_id (str) – id of segment group to optimise

optimise_segment_groups()#

Optimise all segment groups in the cell.

This will:

  • deduplicate members and includes in segment groups

  • remove members that have already been included using a segment group

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

reorder_segment_groups()#

Move default segment groups to the end.

This is required so that the segment groups included in the default groups are defined before they are used.

Returns:

None

set_init_memb_potential(v, group_id='all')#

Set the initial membrane potential of the cell.

Parameters:
  • v (str) – value to set for membrane potential with units

  • group_id (str) – id of segment group to modify

set_resistivity(resistivity, group_id='all') None#

Set the resistivity of the cell

Parameters:

group_id (str) – segment group to modify

set_specific_capacitance(spec_cap, group_id='all')#

Set the specific capacitance for the cell.

Parameters:
  • spec_cap (str) – value of specific capacitance with units

  • group_id (str) – segment group to modify

set_spike_thresh(v, group_id='all')#

Set the spike threshold of the cell.

Parameters:
  • v (str) – value to set for spike threshold with units

  • group_id (str) – id of segment group to modify

setup_default_segment_groups(use_convention=True, default_groups=['all', 'soma_group'])#

Create default segment groups for the cell.

If use_convention is True, it also creates the provided default_groups SegmentGroups for convenience. By default, it creates the “all”, and “soma_group” groups since each cell must at least have a soma. Allowed values are: “all”, “soma_group”, “axon_group”, “dendrite_group”.

Parameters:
  • use_convention (bool) – whether helper segment groups should be created using the default convention

  • default_groups (list of strings) – list of default segment groups to create

Returns:

list of created segment groups (or empty list if none created)

Return type:

list

setup_nml_cell(use_convention=True, overwrite=False, default_groups=['all', 'soma_group'])#

Correctly initialise a NeuroML cell.

To be called after a new component has been created to initialise the cell with these properties:

  • Morphology: id=”morphology”

  • BiophysicalProperties: id=”biophys”:

    • MembraneProperties

    • IntracellularProperties

If use_convention is True, it also creates the provided default_groups SegmentGroups for convenience. By default, it creates the “all”, and “soma_group” groups since each cell must at least have a soma.

When dendritic and axonal segments are added, the add_segment function will create dendrite_group and axon_group groups as required.

Note that since this cell does not currently include a segment in its morphology, it is not a valid NeuroML construct. Use the add_segment and add_unbranched_segments functions to add segments and branches. They will also populate the default segment groups.

Parameters:
  • id (str) – id of the cell

  • use_convention (bool) – whether helper segment groups should be created using the default convention

  • overwrite (bool) – overwrite existing components

  • default_groups (list of strings) – list of default segment groups to create

Returns:

None

Return type:

None

summary(morph=True, biophys=True)#

Print cell summary.

Shows the number of segments and segment groups, and information on the biophysical properties of the cell. See the morphinfo and biophysinfo methods for more details.

Parameters:
  • morph (bool) – toggle showing/hiding morphology information

  • biophys (bool) – toggle showing/hiding biophysology information

Returns:

None

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

CellSet#

class neuroml.nml.nml.CellSet(id: a NmlId (required) = None, select: a string (required) = None, anytypeobjs_=None, gds_collector_=None, **kwargs_)#

Bases: Base

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ChannelDensity#

class neuroml.nml.nml.ChannelDensity(id: a NmlId (required) = None, ion_channel: a NmlId (required) = None, cond_density: a Nml2Quantity_conductanceDensity (optional) = None, erev: a Nml2Quantity_voltage (required) = None, segment_groups: a NmlId (optional) = 'all', segments: a NonNegativeInteger (optional) = None, ion: a NmlId (required) = None, variable_parameters: list of VariableParameter(s) (optional) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: Base

ChannelDensity – Specifies a time varying ohmic conductance density, gDensity, which is distributed on an area of the cell ( specified in membraneProperties ) with fixed reversal potential erev producing a current density iDensity

Parameters:
  • erev (voltage) – The reversal potential of the current produced

  • condDensity (conductanceDensity) –

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ChannelDensityGHK#

class neuroml.nml.nml.ChannelDensityGHK(id: a NmlId (required) = None, ion_channel: a NmlId (required) = None, permeability: a Nml2Quantity_permeability (required) = None, segment_groups: a NmlId (optional) = 'all', segments: a NonNegativeInteger (optional) = None, ion: a NmlId (required) = None, gds_collector_=None, **kwargs_)#

Bases: Base

ChannelDensityGHK – Specifies a time varying conductance density, gDensity, which is distributed on an area of the cell, producing a current density iDensity and whose reversal potential is calculated from the Goldman Hodgkin Katz equation. Hard coded for Ca only! See OpenSourceBrain/ghk-nernst.

Parameters:

permeability (permeability) –

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ChannelDensityGHK2#

class neuroml.nml.nml.ChannelDensityGHK2(id: a NmlId (required) = None, ion_channel: a NmlId (required) = None, cond_density: a Nml2Quantity_conductanceDensity (optional) = None, segment_groups: a NmlId (optional) = 'all', segments: a NonNegativeInteger (optional) = None, ion: a NmlId (required) = None, gds_collector_=None, **kwargs_)#

Bases: Base

ChannelDensityGHK2 – Time varying conductance density, gDensity, which is distributed on an area of the cell, producing a current density iDensity. Modified version of Jaffe et al. 1994 ( used also in Lawrence et al. 2006 ). See OpenSourceBrain/ghk-nernst.

Parameters:

condDensity (conductanceDensity) –

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ChannelDensityNernst#

class neuroml.nml.nml.ChannelDensityNernst(id: a NmlId (required) = None, ion_channel: a NmlId (required) = None, cond_density: a Nml2Quantity_conductanceDensity (optional) = None, segment_groups: a NmlId (optional) = 'all', segments: a NonNegativeInteger (optional) = None, ion: a NmlId (required) = None, variable_parameters: list of VariableParameter(s) (optional) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#

Bases: Base

ChannelDensityNernst – Specifies a time varying conductance density, gDensity, which is distributed on an area of the cell, producing a current density iDensity and whose reversal potential is calculated from the Nernst equation. Hard coded for Ca only! See OpenSourceBrain/ghk-nernst.

Parameters:

condDensity (conductanceDensity) –

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ChannelDensityNernstCa2#

class neuroml.nml.nml.ChannelDensityNernstCa2(id: a NmlId (required) = None, ion_channel: a NmlId (required) = None, cond_density: a Nml2Quantity_conductanceDensity (optional) = None, segment_groups: a NmlId (optional) = 'all', segments: a NonNegativeInteger (optional) = None, ion: a NmlId (required) = None, variable_parameters: list of VariableParameter(s) (optional) = None, gds_collector_=None, **kwargs_)#

Bases: ChannelDensityNernst

ChannelDensityNernstCa2 – This component is similar to the original component type channelDensityNernst but it is changed in order to have a reversal potential that depends on a second independent Ca++ pool ( ca2 ). See OpenSourceBrain/ghk-nernst.

Parameters:

condDensity (conductanceDensity) –

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ChannelDensityNonUniform#

class neuroml.nml.nml.ChannelDensityNonUniform(id: a NmlId (required) = None, ion_channel: a NmlId (required) = None, erev: a Nml2Quantity_voltage (required) = None, ion: a NmlId (required) = None, variable_parameters: list of VariableParameter(s) (optional) = None, gds_collector_=None, **kwargs_)#

Bases: Base

ChannelDensityNonUniform – Specifies a time varying ohmic conductance density, which is distributed on a region of the cell. The conductance density of the channel is not uniform, but is set using the variableParameter . Note, there is no dynamical description of this in LEMS yet, as this type only makes sense for multicompartmental cells. A ComponentType for this needs to be present to enable export of NeuroML 2 multicompartmental cells via LEMS/jNeuroML to NEURON

Parameters:

erev (voltage) – The reversal potential of the current produced

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ChannelDensityNonUniformGHK#

class neuroml.nml.nml.ChannelDensityNonUniformGHK(id: a NmlId (required) = None, ion_channel: a NmlId (required) = None, ion: a NmlId (required) = None, variable_parameters: list of VariableParameter(s) (optional) = None, gds_collector_=None, **kwargs_)#

Bases: Base

ChannelDensityNonUniformGHK – Specifies a time varying conductance density, which is distributed on a region of the cell, and whose current is calculated from the Goldman-Hodgkin-Katz equation. Hard coded for Ca only!. The conductance density of the channel is not uniform, but is set using the variableParameter . Note, there is no dynamical description of this in LEMS yet, as this type only makes sense for multicompartmental cells. A ComponentType for this needs to be present to enable export of NeuroML 2 multicompartmental cells via LEMS/jNeuroML to NEURON

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ChannelDensityNonUniformNernst#

class neuroml.nml.nml.ChannelDensityNonUniformNernst(id: a NmlId (required) = None, ion_channel: a NmlId (required) = None, ion: a NmlId (required) = None, variable_parameters: list of VariableParameter(s) (optional) = None, gds_collector_=None, **kwargs_)#

Bases: Base

ChannelDensityNonUniformNernst – Specifies a time varying conductance density, which is distributed on a region of the cell, and whose reversal potential is calculated from the Nernst equation. Hard coded for Ca only!. The conductance density of the channel is not uniform, but is set using the variableParameter . Note, there is no dynamical description of this in LEMS yet, as this type only makes sense for multicompartmental cells. A ComponentType for this needs to be present to enable export of NeuroML 2 multicompartmental cells via LEMS/jNeuroML to NEURON

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ChannelDensityVShift#

class neuroml.nml.nml.ChannelDensityVShift(id: a NmlId (required) = None, ion_channel: a NmlId (required) = None, cond_density: a Nml2Quantity_conductanceDensity (optional) = None, erev: a Nml2Quantity_voltage (required) = None, segment_groups: a NmlId (optional) = 'all', segments: a NonNegativeInteger (optional) = None, ion: a NmlId (required) = None, variable_parameters: list of VariableParameter(s) (optional) = None, v_shift: a Nml2Quantity_voltage (required) = None, gds_collector_=None, **kwargs_)#

Bases: ChannelDensity

ChannelDensityVShift – Same as channelDensity , but with a vShift parameter to change voltage activation of gates. The exact usage of vShift in expressions for rates is determined by the individual gates.

Parameters:
  • vShift (voltage) –

  • erev (voltage) – The reversal potential of the current produced

  • condDensity (conductanceDensity) –

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ChannelPopulation#

class neuroml.nml.nml.ChannelPopulation(id: a NmlId (required) = None, ion_channel: a NmlId (required) = None, number: a NonNegativeInteger (required) = None, erev: a Nml2Quantity_voltage (required) = None, segment_groups: a NmlId (optional) = 'all', segments: a NonNegativeInteger (optional) = None, ion: a NmlId (required) = None, variable_parameters: list of VariableParameter(s) (optional) = None, gds_collector_=None, **kwargs_)#

Bases: Base

ChannelPopulation – Population of a number of ohmic ion channels. These each produce a conductance channelg across a reversal potential erev, giving a total current i. Note that active membrane currents are more frequently specified as a density over an area of the cell using channelDensity

Parameters:
  • number (none) – The number of channels present. This will be multiplied by the time varying conductance of the individual ion channel ( which extends baseIonChannel ) to produce the total conductance

  • erev (voltage) – The reversal potential of the current produced

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ClosedState#

class neuroml.nml.nml.ClosedState(id: a NmlId (required) = None, gds_collector_=None, **kwargs_)#

Bases: Base

ClosedState – A KSState with relativeConductance of 0

Parameters:

relativeConductance (none) –

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ComponentType#

class neuroml.nml.nml.ComponentType(name: a string (required) = None, extends: a string (optional) = None, description: a string (optional) = None, Property: list of Property(s) (optional) = None, Parameter: list of Parameter(s) (optional) = None, DerivedParameter: list of DerivedParameter(s) (optional) = None, Constant: list of Constant(s) (optional) = None, Exposure: list of Exposure(s) (optional) = None, Requirement: list of Requirement(s) (optional) = None, InstanceRequirement: list of InstanceRequirement(s) (optional) = None, Dynamics: list of Dynamics(s) (optional) = None, gds_collector_=None, **kwargs_)#

Bases: GeneratedsSuper

ComponentType – Contains an extension to NeuroML by creating custom LEMS ComponentType.

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

CompoundInput#

class neuroml.nml.nml.CompoundInput(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, pulse_generators: list of PulseGenerator(s) (optional) = None, sine_generators: list of SineGenerator(s) (optional) = None, ramp_generators: list of RampGenerator(s) (optional) = None, gds_collector_=None, **kwargs_)#

Bases: Standalone

CompoundInput – Generates a current which is the sum of all its child basePointCurrent element, e. g. can be a combination of pulseGenerator , sineGenerator elements producing a single i. Scaled by weight, if set

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

CompoundInputDL#

class neuroml.nml.nml.CompoundInputDL(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, pulse_generator_dls: list of PulseGeneratorDL(s) (optional) = None, sine_generator_dls: list of SineGeneratorDL(s) (optional) = None, ramp_generator_dls: list of RampGeneratorDL(s) (optional) = None, gds_collector_=None, **kwargs_)#

Bases: Standalone

CompoundInputDL – Generates a current which is the sum of all its child basePointCurrentDL elements, e. g. can be a combination of pulseGeneratorDL , sineGeneratorDL elements producing a single i. Scaled by weight, if set

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ConcentrationModel_D#

class neuroml.nml.nml.ConcentrationModel_D(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, ion: a NmlId (required) = None, resting_conc: a Nml2Quantity_concentration (required) = None, decay_constant: a Nml2Quantity_time (required) = None, shell_thickness: a Nml2Quantity_length (required) = None, type: a string (required) = 'decayingPoolConcentrationModel', gds_collector_=None, **kwargs_)#

Bases: DecayingPoolConcentrationModel

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

ConditionalDerivedVariable#

class neuroml.nml.nml.ConditionalDerivedVariable(name: a string (required) = None, dimension: a string (required) = None, description: a string (optional) = None, exposure: a string (optional) = None, Case: list of Case(s) (required) = None, gds_collector_=None, **kwargs_)#

Bases: NamedDimensionalVariable

ConditionalDerivedVariable – LEMS ComponentType for ConditionalDerivedVariable

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.

Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.

See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.

Parameters:
  • show_contents (bool or str) – toggle to print out the contents of the members

  • return_format (str) –

    select what format to return information in “string” (default), or “dict” or “list”.

    If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.

Returns:

info string, or list of members or dict with members as keys and member values as values

Return type:

str, list/dict

parentinfo(return_format='string')#

Show the list of possible parents.

This object can then be added to objects of the parents using the add method.

It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.

So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.

Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.

Parameters:

return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.

Returns:

info string, or list of parents or dict with parents as keys and member information as values

Return type:

str, list/dict

validate(recursive=False)#

Validate the component.

Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.

Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.

Note: that this is different from the validate_ method, which does not validate inherited members.

Parameters:

recursive (bool) – toggle recursive validation (default: False)

Returns:

None

Return type:

None

Raises:

ValueError – if component is invalid

Connection#

class neuroml.nml.nml.Connection(id: a NonNegativeInteger (required) = None, neuro_lex_id: a NeuroLexId (optional) = None, pre_cell_id: a Nml2PopulationReferencePath (required) = None, pre_segment_id: a NonNegativeInteger (optional) = '0', pre_fraction_along: a ZeroToOne (optional) = '0.5', post_cell_id: a Nml2PopulationReferencePath (required) = None, post_segment_id: a NonNegativeInteger (optional) = '0', post_fraction_along: a ZeroToOne (optional) = '0.5', gds_collector_=None, **kwargs_)#

Bases: BaseConnectionOldFormat

Connection – Event connection directly between named components, which gets processed via a new instance of a synapse component which is created on the target component. Normally contained inside a projection element.

add(obj=None, hint=None, force=False, validate=True, **kwargs)#

Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.

Please use the info() method directly for more information on the current contents of this component object.

When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.

Parameters:
  • obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None

  • hint (string) – member name to add to when there are multiple members that obj can be added to

  • force (bool) – boolean to force addition when an obj has already been added previously

  • validate (bool) – validate component after adding (default: True)

Returns obj:

the provided or created object

Raises:
  • Exception – if a member compatible to obj could not be found

  • Exception – if multiple members can accept the object and no hint is provided.

classmethod component_factory(component_type, validate=True, **kwargs)#

Factory function to create a NeuroML Component object.

Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.

Users can use the add() helper function to further modify components

This factory runs two checks while creating the component object:

  • that all arguments given do belong to the ComponentType (useful for caching typos)

  • that the created component is valid NeuroML

It is therefore less error prone than creating Components directly using the ComponentType constructors.

It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.

Parameters:
  • component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.

  • validate (bool) – toggle validation (default: True)

  • kwargs (named arguments) – named arguments to be passed to ComponentType constructor

Returns:

new Component (object) of provided ComponentType

Return type:

object

Raises:

ValueError – if validation/checks fail

classmethod get_class_hierarchy()#

Get the class hierarchy for a component classs.

Reference: https://stackoverflow.com/a/75161393/375067

See the methods in neuroml.utils to use this generated hierarchy.

Returns:

nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents

classmethod get_nml2_class_hierarchy()#

Return the NeuroML class hierarchy.

The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.

This caches the value as a class variable so that it is not re-calculated when used multiple times.

get_post_cell_id()#

Get the ID of the post-synaptic cell

Returns:

ID of post-synaptic cell

Return type:

str

get_post_fraction_along()#

Get post-synaptic fraction along information

get_post_info()#

Get post-synaptic information summary

get_post_segment_id()#

Get the ID of the post-synpatic segment

Returns:

ID of post-synaptic segment.

Return type:

str

get_pre_cell_id()#

Get the ID of the pre-synaptic cell

Returns:

ID of pre-synaptic cell

Return type:

str

get_pre_fraction_along()#

Get pre-synaptic fraction along information

get_pre_info()#

Get pre-synaptic information summary

get_pre_segment_id()#

Get the ID of the pre-synpatic segment

Returns:

ID of pre-synaptic segment.

Return type:

str

has__content()#
info(show_contents=False, return_format='string')#

Provide information on NeuroML component.

This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.

To get a list of possible parents, use the parentinfo() method.

By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents