neurodsp.sim.params.SimSamplers¶
- class neurodsp.sim.params.SimSamplers(n_seconds=None, fs=None, n_samples=None)[source]¶
Object for sampling simulation parameter definitions.
- Parameters:
- n_secondsfloat
Simulation time, in seconds.
- fsfloat
Sampling rate of simulated signal, in Hz.
- n_samplesint, optional
The number of parameter iterations to set as max. If None, samplers are created as infinite generators.
Methods
__init__
([n_seconds, fs, n_samples])Initialize SimSamplers objects.
clear
([clear_samplers, clear_params, clear_base])"Clear sampler and/or parameter definitions.
copy
()Return a copy of the current object.
make_params
([params])Make a simulation parameter definition from given parameters.
make_sampler
(label, samplers[, n_samples])Create sampler to sample simulation parameter values.
register
(label[, params])Register a new simulation parameter definition.
register_group
(group[, clear])Register multiple simulation parameter definitions.
register_group_samplers
(group[, clear])Register a group of simulation samplers.
register_sampler
(name, label, samplers)Register a sampler 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_param
(label, attribute, new_value)Update a simulation parameter definition.
update_sampler
(label, attribute, new_value)Update the definition of a sampler.
Attributes
Get the base parameters, common across all simulations.
Get the set of labels for the defined iterators.
Get the set of currently defined simulation parameters.
Get the set of currently defined simulation samplers.
- property base¶
Get the base parameters, common across all simulations.
- Returns:
- base_paramsdict
Definition of the current base parameters.
- clear(clear_samplers=True, clear_params=False, clear_base=False)[source]¶
“Clear sampler and/or parameter definitions.
- Parameters:
- clear_samplersbool, optional, default: True
Whether to clear the currently defined samplers.
- 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 labels¶
Get the set of labels for the defined iterators.
- 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.
- make_sampler(label, samplers, n_samples=None)[source]¶
Create sampler to sample simulation parameter values.
- Parameters:
- labelstr
Label for the simulation parameters.
- samplersdict
Sampler definitions to update parameters with. Each key should be a callable, a parameter updater function. Each value should be a generator, to sample updated parameter values from.
- Returns:
- ParamSampler
Generator object for sampling simulation parameters.
- 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_samplers(group, clear=False)[source]¶
Register a group of simulation samplers.
- Parameters:
- grouplist of list or list of dict
Set of simulation iterator definitions.
- clearbool, optional, default: False
If True, clears current parameter samplers before adding new group.
- register_sampler(name, label, samplers)[source]¶
Register a sampler definition.
- Parameters:
- namestr
Name to give the registered iterator.
- labelstr
Label for the simulation parameters.
- samplersdict
Sampler definitions to update parameters with. Each key should be a callable, a parameter updater function. Each value should be a generator, to sample updated parameter values from.
- property samplers¶
Get the set of currently defined simulation samplers.
- Returns:
- samplersdict
Dictionary of currently defined simulation samplers. Each key is a label for the parameter sampler. Each value is a ParamSampler object.
- 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_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.