Validating NeuroML Models#
Validate NeuroML 2 files before using them.
It is good practice to validate NeuroML 2 files to check them for correctness before using them.
Models described in NeuroML must adhere to the NeuroML specification. This allows all NeuroML models to be checked for correctness: validation. There are a number of ways of validating NeuroML model files.
Using the command line tools#
Both pynml
(provided by pyNeuroML) and jnml
(provided by jNeuroML) can validate individual NeuroML files:
Usage:
# For NeuroML 2
jnml -validate <NML file(s)>
pynml <NML file(s)> -validate
# For NeuroML 1 (deprecated)
jnml -validatev1 <NML file>
pynml <NML file(s)> -validatev1
Using the Python API#
The pyNeuroML Python API provides a number of methods to validate NeuroML 2 files.
The first is the aptly named validate_neuroml2
function:
from pyneuroml.pynml import validate_neuroml2
...
validate_neuroml2(nml_filename)
Similarly, the validate_neuroml1
function can be used to validate NeuroML v1 files.
If you are loading NeuroML files into your Python script, the read_neuroml2_file
function also includes validation:
from pyneuroml.pynml import read_neuroml2_file
....
read_neuroml2_file(nml_filename, include_includes=True, check_validity_pre_include=True)
This will read (load) the provided NeuroML 2 file and all the files that are recursively included by it, and validate them all while it loads them.
List of validation tests#
These tests are made against the Schema document.
Test |
Description |
---|---|
Check names |
Check that names of all elements, attributes, parameters match those provided in the schema |
Check types |
Check that the types of all included elements |
Check values |
Check that values follow given restrictions |
Check inclusion |
Check that required elements are included |
Check cardinality |
Check the number of elements |
Check hierarchy |
Check that child/children elements are included in the correct parent elements |
Check sequence order |
Check that child/children elements are included in the correct order |
These are additional validation tests that are run on models (defined here):
Test |
Description |
---|---|
Check top level ids |
Check that top level (root) elements have unique ids |
Check Network level ids |
Check that child/children of the Network element have unique ids |
Check single Segment without parent |
Check that only one Segment is without parents (the soma Segment) |
Check SegmentGroup ids |
Check that all SegmentGroups in a Cell have unique ids |
Check Member segment ids exist |
Check that Segments referred to in SegmentGroup Members exist |
Check SegmentGroup definition |
Check that SegmentGroups being referenced are defined |
Check SegmentGroup definition order |
Check that SegmentGroups are defined before being referenced |
Check included SegmentGroups |
Check that SegmentGroups referenced by Include elements of other SegmentGroups exist |
Check |
Check that SegmentGroups define |
Check included model files |
Check that model files included by other files exist |
Check Population component |
Check that a component id provided to a Population exists |
Check ion channel exists |
Check that an ion channel used to define a ChannelDensity element exists |
Check concentration model species |
Check that the species used in ConcentrationModel elements are defined |
Check Population size |
Check that the |
Check Projection component |
Check that Populations used in the Projection elements exist |
Check Connection Segment |
Check that the Segment used in Connection elements exist |
Check Connection pre/post cells |
Check that the pre- and post-synaptic cells used in Connection elements exist and are correctly specified |
Check Synapse |
Check that the Synapse component used in a Projection element exists |
Check root id |