Model module

Base class for a forward model whose parameters are to be fitted

class svb.model.Model(data_model, **options)[source]

A forward model

Attr params:Sequence of Parameter objects
Attr nparams:Number of model parameters
evaluate(params, tpts)[source]

Evaluate the model

Parameters:t – Time values to evaluate the model at, supplied as a tensor of shape [1x1xB] (if time values at each voxel are identical) or [Vx1xB] otherwise.
:param params Sequence of parameter values arrays, one for each parameter.
Each array is WxSx1 tensor where W is the number of parameter vertices and S is the number of samples per parameter. This may be supplied as a PxVxSx1 tensor where P is the number of parameters.
Returns:[VxSxB] tensor containing model output at the specified time values for each voxel, and each sample (set of parameter values).
ievaluate(params, tpts)[source]

Evaluate the model outside of a TensorFlow session

Same as evaluate() but will run the evaluation within a session and return the evaluated output tensor

log_config(log=None)[source]

Write model configuration to a log stream

Param:log Optional logger to use - defaults to class instance logger
nparams

Number of parameters in the model

param_idx(name)[source]
Returns:the index of a named parameter
test_data(tpts, params_map)[source]

Generate test data by evaluating the model on known parameter values with optional added noise

FIXME this is non-functional at present.

Parameters:
  • tpts – 1xN or MxN tensor of time values (possibly varying by voxel)
  • params_map – Mapping from parameter name either a single parameter value or a sequence of M parameter values. The special key noise_sd, if present, should containing the standard deviation of Gaussian noise to add to the output.
:return If noise is present, a tuple of two MxN Numpy arrays. The first
contains the ‘clean’ output data without noise, the second contains the noisy data. If noise is not present, only a single array is returned.
tpts()[source]

Get the full set of timeseries time values

Parameters:
  • n_tpts – Number of time points required for the data to be fitted
  • shape – Shape of source data which may affect the times assigned

By default this is a linear space using the attributes t0 and dt. Some models may have time values fixed by some other configuration. If the number of time points is fixed by the model it must match the supplied value n_tpts.

Returns:Either a Numpy array of shape [n_tpts] or a Numpy array of shape shape + [n_tpts] for voxelwise timepoints
svb.model.get_model_class(model_name)[source]

Get a model class by name