neurodsp.sim.params.SimIters¶
- class neurodsp.sim.params.SimIters(n_seconds=None, fs=None)[source]¶
Object for managing simulation iterators.
- Parameters:
- n_secondsfloat
Simulation time, in seconds.
- fsfloat
Sampling rate of simulated signal, in Hz.
Methods
__init__
([n_seconds, fs])Initialize SimIters objects.
clear
([clear_iters, clear_params, clear_base])"Clear iterator and/or parameter definitions.
copy
()Return a copy of the current object.
make_iter
(label, update, values[, component])Create iterator to step across simulation parameter values.
make_params
([params])Make a simulation parameter definition from given parameters.
register
(label[, params])Register a new simulation parameter definition.
register_group
(group[, clear])Register multiple simulation parameter definitions.
register_group_iters
(group[, clear])Register a group of simulation iterators.
register_iter
(name, label, update, values[, ...])Register an iterator definition.
to_iters
()Convert to a SimIters object.
to_samplers
([n_samples])Convert to a SimSamplers object.
update_base
([n_seconds, fs])Update base parameters.
update_iter
(label, attribute, new_value)Update the definition of an iterator.
update_param
(label, attribute, new_value)Update a simulation parameter definition.
Attributes
Get the base parameters, common across all simulations.
Get the set of currently defined simulation iterators.
Get the set of labels for the defined iterators.
Get the set of currently defined simulation parameters.
- property base¶
Get the base parameters, common across all simulations.
- Returns:
- base_paramsdict
Definition of the current base parameters.
- clear(clear_iters=True, clear_params=False, clear_base=False)[source]¶
“Clear iterator and/or parameter definitions.
- Parameters:
- clear_itersbool, optional, default: True
Whether to clear the currently defined iterators.
- clear_paramsbool, optional, default: False
Whether to clear the currently defined simulation parameters.
- clear_basebool, optional, default: False
Whether to also clear base parameters. Only applied if clear_params is True.
- copy()¶
Return a copy of the current object.
- property iters¶
Get the set of currently defined simulation iterators.
- Returns:
- itersdict
Dictionary of currently defined simulation iterators. Each key is a label for the parameter iterator. Each value is a ParamIter object.
- property labels¶
Get the set of labels for the defined iterators.
- Returns:
- labelslist of str
Labels for all defined iterators.
- make_iter(label, update, values, component=None)[source]¶
Create iterator to step across simulation parameter values.
- Parameters:
- labelstr
Label for the simulation parameters.
- updatestr
Name of the parameter to update.
- values1d array
Values to iterate across.
- componentstr, optional
Which component to update the parameter in. Only used if the parameter definition is for a multi-component simulation.
- Returns:
- ParamIter
Generator object for iterating across simulation parameters.
- make_params(params=None, **kwargs)¶
Make a simulation parameter definition from given parameters.
- Parameters:
- paramsdict or list of dict
Parameter definition(s) to create simulation parameter definition.
- **kwargs
Additional keyword arguments to create the simulation definition.
- Returns:
- paramsdict
Parameter definition.
- property params¶
Get the set of currently defined simulation parameters.
- Returns:
- paramsdict
Dictionary of currently defined simulation parameters. Each key is a label for the parameter definition. Each value is a dictionary of simulations parameters.
- register(label, params=None, **kwargs)¶
Register a new simulation parameter definition.
- Parameters:
- labelstr
Label to set simulation parameters under in params.
- paramsdict or list of dict
Parameter definition(s) to create simulation parameter definition.
- **kwargs
Additional keyword arguments to create the simulation definition.
- register_group(group, clear=False)¶
Register multiple simulation parameter definitions.
- Parameters:
- groupdict
Dictionary of simulation parameters. Each key should be a label, and each set of values a dictionary of parameters.
- clearbool, optional, default: False
If True, clears current parameter definitions before adding new group.
- register_group_iters(group, clear=False)[source]¶
Register a group of simulation iterators.
- Parameters:
- grouplist of list or list of dict
Set of simulation iterator definitions.
- clearbool, optional, default: False
If True, clears current parameter iterators before adding new group.
- register_iter(name, label, update, values, component=None)[source]¶
Register an iterator definition.
- Parameters:
- namestr
Name to give the registered iterator.
- labelstr
Label for the simulation parameters.
- updatestr
Name of the parameter to update.
- values1d array
Values to iterate across.
- componentstr, optional
Which component to update the parameter in. Only used if the parameter definition is for a multi-component simulation.
- to_iters()¶
Convert to a SimIters object.
- Returns:
- itersSimIters
A converted object, initialized with the current base parameters.
- to_samplers(n_samples=None)¶
Convert to a SimSamplers object.
- Parameters:
- n_samplesint, optional
The number of parameter iterations to set as max. If None, samplers are created as infinite generators.
- Returns:
- samplersSimSamplers
A converted object, initialized with the current base parameters.
- update_base(n_seconds=False, fs=False)¶
Update base parameters.
- Parameters:
- n_secondsfloat, optional
Simulation time, in seconds.
- fsfloat, optional
Sampling rate of simulated signal, in Hz.
Notes
If set as False, value will not be updated. If set as None, value will be updated to None.
- update_iter(label, attribute, new_value)[source]¶
Update the definition of an iterator.
- Parameters:
- labelstr
Label for the iterator.
- attributestr
Name of the attribute to update.
- new_valueobj
New value to give the attribute.
- update_param(label, attribute, new_value)¶
Update a simulation parameter definition.
- Parameters:
- labelstr
Label for the parameter definition.
- attributestr
Name of the attribute to update.
- new_valueobj
New value to give the attribute.