pyneuroml.lems package#

pyneuroml.lems.generate_lems_file_for_neuroml(sim_id, neuroml_file, target, duration, dt, lems_file_name, target_dir, nml_doc=None, include_extra_files=[], gen_plots_for_all_v=True, plot_all_segments=False, gen_plots_for_quantities={}, gen_plots_for_only_populations=[], gen_saves_for_all_v=True, save_all_segments=False, gen_saves_for_only_populations=[], gen_saves_for_quantities={}, gen_spike_saves_for_all_somas=False, gen_spike_saves_for_only_populations=[], gen_spike_saves_for_cells={}, spike_time_format='ID_TIME', copy_neuroml=True, report_file_name=None, lems_file_generate_seed=None, verbose=False, simulation_seed=12345)#
pyneuroml.lems.get_pop_index(quantity)#
pyneuroml.lems.load_sim_data_from_lems_file(lems_file_name: str, base_dir: str = '.', get_events: bool = True, get_traces: bool = True) Tuple[Dict, Dict] | Dict#

Load simulation outputs using the LEMS simulation file

New in version 1.2.2.

Parameters:
  • lems_file_name (str) – name of LEMS file that was used to generate the data

  • base_dir (str) – directory to run in

Returns:

if both get_events and get_traces are selected, a tuple with two dictionaries, one for traces, one for events, is returned.

Otherwise one dictionary for whichever was selected.

The events dictionary has the following format:

{
    '<value of select attribute>': [<events>]
}

The traces dictionary has the following format:

{
    't': [<values>],
    'col 1': [<values>]
}

Raises:
  • ValueError – if neither traces nor events are selected for loading

  • ValueError – if no traces are found

  • ValueError – if no events are found

pyneuroml.lems.safe_variable(quantity)#

pyneuroml.lems.LEMSSimulation module#

Helper class for generating LEMS xml files for simulations

class pyneuroml.lems.LEMSSimulation.LEMSSimulation(sim_id: str, duration: float, dt: float, target: str | None = None, comment: str = '\n\n        This LEMS file has been automatically generated using PyNeuroML v1.2.8 (libNeuroML v0.5.8)\n\n    ', lems_file_generate_seed: Any | None = None, simulation_seed: int = 12345, meta: Dict[str, str] | None = None)#

Bases: object

Helper class for creating LEMS Simulations for running NeuroML2 models.

TEMPLATE_FILE = '/home/docs/checkouts/readthedocs.org/user_builds/pyneuroml/checkouts/development/pyneuroml/lems/LEMS_TEMPLATE.xml'#
add_column_to_output_file(output_file_id: str, column_id: str, quantity: str) None#

Add a column to the output file with id output_file_id

Parameters:
  • output_file_id (str) – id of output file (must be created first using create_output_file)

  • column_id (str) – id of column to add

  • quantity (str) – quantity to add

Returns:

None

Raises:

ValueError – if provided output_file_id has not been created yet.

add_line_to_display(display_id: str, line_id: str, quantity: str, scale: str = '1', color: str | None = None, timeScale: str = '1ms') None#

Add a new line to the display

Parameters:
  • display_id (str) – id of display

  • line_id (str) – id of line

  • quantity – name of quantity being represented

  • scale (str) – scale of line

  • color (str) – color of line, randomly chosen if None

  • timeScale (str) – scale of time axis

Returns:

None

Raises:

ValueError – if provided display_id has not been created yet.

add_selection_to_event_output_file(event_output_file_id: str, event_id: str, select: str, event_port: str) None#

Add a column to the event output file with id event_output_file_id.

Parameters:
  • event_output_file_id (str) – id of output file (must be created first using create_output_file)

  • event_id (str) – id of event to add

  • select (str) – selection to add

  • event_port (str) – event port to add

Returns:

None

Raises:

ValueError – if provided event_output_file_id has not been created yet.

assign_simulation_target(target: str) None#

Assign a simulation target.

Parameters:

target (str) – id of target component

Returns:

None

create_display(id: str, title: str, ymin: str, ymax: str, timeScale: str = '1ms') None#

Create a new display

Parameters:
  • id (str) – id of display

  • title (str) – title of display

  • ymin (str) – min y value of display

  • ymax (str) – max y value of display

  • timeScale (str) – time scale of display

Returns:

None

create_event_output_file(id, file_name, format='ID_TIME')#

Create a new output file for storing events recorded from simulations.

For storing other outputs (not events), please see create_output_file instead.

TODO: list what formats are available

Parameters:
  • id (str) – id of output file

  • file_name (str) – name of output file

  • format (str) – format of file

Returns:

None

create_output_file(id: str, file_name: str)#

Create a new output file for storing values recorded for a simulation.

For storing events, such as spikes, please see create_event_output_file.

Parameters:
  • id (str) – id of output file

  • file_name (str) – name of output file

Returns:

None

include_lems_file(lems_file_name: str, include_included: bool = True) None#

Include additional LEMS file in the simulation.

Parameters:
  • lems_file_name (str) – name of LEMS file to include

  • include_included (bool) – toggle to include files included by provided LEMS file

Returns:

None

include_neuroml2_file(nml2_file_name: str, include_included: bool = True, relative_to_dir: str = '.') None#

Include additional NeuroML2 file.

This will only add the provided file if it has not already been included.

Parameters:
  • nml2_file_name (str) – name of NeuroML2 file to include

  • include_included (bool) – toggle to include any files included in the provided file

  • relative_to_dir (str) – directory relative to which the provided nml2_file_name is being provided

Returns:

None

lems_info: dict[str, Any] = {}#
my_random = <random.Random object>#
save_to_file(file_name: str | None = None)#

Save LEMSSimulation to a file.

Parameters:

file_name (str) – name of file to store to. LEMS_<some id string>.xml is the suggested format. Leave empty to use LEMS_<sim_id>.xml

Returns:

name of file

Return type:

str

set_report_file(report_file_name: str) None#

Set a report file.

The report file is a short file saved after simulation with run time, simulator version etc.

Parameters:

report_file_name (str) – name of report file

Returns:

None

to_xml() str#

Export simulation to XML.

Returns:

XML representation

Return type:

str