brian2tools.nmlexport.supporting module

class brian2tools.nmlexport.supporting.NeuroMLPoissonGenerator(poissid, average_rate)[source]

Bases: object

Makes XML of spikeGeneratorPoisson for NeuroML2/LEMS simulation.

build()[source]

Builds NeuroML DOM structure of spikeGeneratorPoisson and returns it.

Returns:generator – DOM representation of generator.
Return type:xml.minidom.dom
class brian2tools.nmlexport.supporting.NeuroMLSimpleNetwork(id_)[source]

Bases: object

NeuroMLSimpleNetwork class representing network tag in NeuroML syntax as a XML DOM representation.

add_component(id_, type_, **attributes)[source]

Adds a component to a network.

Parameters:
  • id (str) – component id
  • type (str) – type of component
  • attributes (.., optional) – more attributes
build()[source]

Builds NeuroML DOM structure of network. It returns DOM object.

Returns:network – DOM representation of network.
Return type:xml.minidom.dom
class brian2tools.nmlexport.supporting.NeuroMLSimulation(simid, target, length='1s', step='0.1ms')[source]

Bases: object

NeuroMLSimulation class representing Simulation tag in NeuroML syntax as a XML DOM representation.

add_display(dispid, title='', time_scale='1ms', xmin='0', xmax='1000', ymin='0', ymax='11')[source]

Adds a Display element to Simulation.

Parameters:
  • dispid (str) – display id
  • title (str) – title printed on display window
  • time_scale (str) – time scale of a plot
  • xmax, ymin, ymax (xmin,) – limits of plot
add_eventoutputfile(outfileid, filename='recordings.spikes', format_='TIME_ID')[source]

Adds an EventOutputFile element to a recently added Display.

Parameters:
  • outfileid (str) – EventOutputFile id
  • filename (str) – name of an output file
  • format (str, optional) – format of data storage, default TIME_ID
add_eventselection(esid, select, event_port='spike')[source]

Adds an EventSelection element to a recently added EventOutputFile.

Parameters:
  • esid (str) – EventSelection id
  • select (str) – index of selected neuron
  • event_port (str) – event port name, default ‘spike’
add_line(linid, quantity, scale='1mV', time_scale='1ms')[source]

Adds a Line element to a recently added Display.

Parameters:
  • linid (str) – line id
  • quantity (str) – measure to plot
  • scale (str) – scale of a function
  • time_scale (str) – time scale of a line
add_outputcolumn(ocid, quantity)[source]

Adds an OutputColumn element to a recently added OutputFile tag.

Parameters:
  • ocid (str) – OutputColumn id
  • quantity (str) – measure to store in a column
add_outputfile(outfileid, filename='recordings.dat')[source]

Adds an OutputFile to Simulation.

Parameters:
  • outfileid (str) – OutputFile id
  • filename (str) – name of an output file
build()[source]

Builds NeuroML DOM structure of Simulation. It returns DOM object or it can be accessed by object.simulation.

Returns:simulation – DOM representation of simulation.
Return type:xml.minidom.dom
create_simulation(simid, target, length, step)[source]

Adds a Simulation element to DOM structure at init.

Parameters:
  • simid (str) – simulation id.
  • target (str) – target NeuroML object: component or network
  • length (str, optional) – length of simulation, default 1 sec
  • step (str, optional) – step of integration, default 0.1 ms
update_simulation_attribute(attr_name, attr_value)[source]

Updates simulation attributes.

Parameters:
  • attr_name (str) – attribute name
  • attr_value (str or int or float) – attribute value
class brian2tools.nmlexport.supporting.NeuroMLTarget(component)[source]

Bases: object

Makes XML of target of NeuroML2/LEMS simulation.

build()[source]

Builds NeuroML DOM structure of target and returns it.

Returns:target – DOM representation of target.
Return type:xml.minidom.dom
brian2tools.nmlexport.supporting.brian_unit_to_lems(valunit)[source]

Returns string representation of LEMS unit where * is between value and unit e.g. “20. mV” -> “20.*mV”.

Parameters:valunit (Quantity or str) – text or brian2.Quantity representation of a value with unit
Returns:valstr – string representation of LEMS unit
Return type:str
brian2tools.nmlexport.supporting.from_string(rep)[source]

Returns Quantity object from text representation of a value.

Parameters:rep (str) – text representation of a value with unit
Returns:q – Brian Quantity object
Return type:Quantity
brian2tools.nmlexport.supporting.read_nml_dims(nmlcdpath='')[source]

Read from NeuroMLCoreDimensions.xml all supported by LEMS dimensions and store it as a Python dict with name as a key and Brian2 unit as value.

Parameters:nmlcdpath (str, optional) – Path to ‘NeuroMLCoreDimensions.xml’
Returns:lems_dimenssions – Dictionary with LEMS dimensions.
Return type:dict
brian2tools.nmlexport.supporting.read_nml_units(nmlcdpath='')[source]

Read from ‘NeuroMLCoreDimensions.xml’ all supported by LEMS units.

Parameters:nmlcdpath (str, optional) – Path to ‘NeuroMLCoreDimensions.xml’
Returns:lems_units – List with LEMS units.
Return type:list