pyneuroml.lems package#
- pyneuroml.lems.generate_lems_file_for_neuroml(sim_id: str, neuroml_file: str, target: str, duration: str | float | int, dt: str | float | int, lems_file_name: str, target_dir: str, nml_doc: NeuroMLDocument | None = None, include_extra_files: List[str] = [], gen_plots_for_all_v: bool = True, plot_all_segments: bool = False, gen_plots_for_quantities: Dict[str, List[str]] = {}, gen_plots_for_only_populations: List[str] = [], gen_saves_for_all_v: bool = True, save_all_segments: bool = False, gen_saves_for_only_populations: List[str] = [], gen_saves_for_quantities: Dict[str, List[str]] = {}, gen_spike_saves_for_all_somas: bool = False, gen_spike_saves_for_only_populations: List[str] = [], gen_spike_saves_for_cells: Dict[str, List[str]] = {}, spike_time_format: str = 'ID_TIME', copy_neuroml: bool = True, report_file_name: str | None = None, lems_file_generate_seed: int | None = None, verbose: bool = False, simulation_seed: int = 12345) Tuple[List[str], LEMSSimulation] #
Generate a LEMS simulation file for a NeuroML model file. This wraps around the LEMSSimulation class and provides an easy interface for creating the LEMS simulation file.
- Parameters:
sim_id (str) – simulation id
neuroml_file (str) – name/path to NeuroML file
target (str) – target element
duration (str or float or int) – simulation duration
dt (str or float or int) – integration time step
lems_file_name (str) – name of LEMS file
target_dir (str) – directory to place LEMS file in
nml_doc (neuroml.Document) – NeuroMLDocument object containing model for simulation Useful if the NeuroML file has already been loaded as it prevents re-loading of the NeuroMLDocument from the file. If this is not provided, the provided NeuroML file will be assumed to be a NeuroMLDocument and loaded.
include_extra_files (list) – list of extra files to include in the LEMS simulation file
gen_plots_for_all_v (bool) – toggle generation of plots for all membrane potentials
plot_all_segments (bool) – toggle whether values for all segments should be plotted
gen_plots_for_quantities (dict) – dict of quantities to display the key is the “display” and the value will be the list of quantity paths
gen_plots_for_only_populations (list) – list of populations to limit plotting for, If the list is empty, all populations are considered.
gen_saves_for_all_v (bool) – toggle whether data files should be saved for all membrane potentials
save_all_segments (bool) – toggle whether data files should be saved for all segments
gen_saves_for_only_populations (list of populations to save data) – list of populations to save data files for, if list is empty, all populations are considered
gen_saves_for_quantities (dict) – dict of quantities to save data files for the key is the filename and the value will be the list of quantitiy paths to save to it
gen_spike_saves_for_all_somas (bool) – toggle if spikes should be saved for all somas
gen_spike_saves_for_only_populations (list) – list of populations spikes should be saved in data files for
gen_spike_saves_for_cells (dict) – dict of cells to save spikes for the key is the name of the file and the value will be the list of quantitiy paths
spike_time_format (str) – spike time format
copy_neuroml (bool) – toggle whether NeuroML files should be copied to target directory
report_file_name (str) – name of report file
lems_file_generate_seed (int) – seed to use for LEMS file generation
verbose (bool) – toggle verbosity
simulation_seed (int) – simulation seed
- Returns:
tuple (list of saved quantities, LEMSSimulation object)
- Return type:
(list, LEMSSimulation)
- 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 | None #
Load simulation outputs using the LEMS simulation file
Added 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>': { 'cell id': [<events>] } }
The traces dictionary has the following format:
{ 't': [<values>], 'col 1': [<values>] 'col 2': [<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)#
Make a variable safe.
It replaces [, ], /, . with _.
- Parameters:
quantity – quantitiy to make safe
quantity – str
- Returns:
quantity after it was made safe
- Return type:
str
pyneuroml.lems.LEMSSimulation module#
Helper class for generating LEMS xml files for simulations
- class pyneuroml.lems.LEMSSimulation.LEMSSimulation(sim_id: str, duration: float | str, dt: float | str, target: str | None = None, comment: str = '\n\n This LEMS file has been automatically generated using PyNeuroML v1.3.14 (libNeuroML v0.6.5)\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
- property lems_info#
Return the attributes
- 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. If provided, this also sets the lems_file_name attribute of the class so that it can be accessed later.
- 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