peri.models

class peri.models.Model(modelstr, varmap, registry={})

An abstraction for defining how to combine components into a complete model as well as derivatives with respect to different variables.

Parameters:
  • modelstr (dict of strings) –

    (Using a custom model) The actual equations used to defined the model. At least one eq. is required under the key full. Other partial update equations can be added where the variable name (e.g. ‘dI’) denotes a partial update of I, for example:

    {'full': 'H(P)', 'dP': 'H(dP)'}
    
  • varmap (dict) –

    (Using a custom model) The mapping of variables in the modelstr equations to actual component types. For example:

    {'P': 'obj', 'H': 'psf'}
    
  • registry (dict) –

    A mapping of categories to components which this model will accept. For example:

    {
        'obj': [objs.PlatonicSpheresCollection],
        'psf': [psfs.Gaussian4DPoly, psfs.GaussianMomentExpansion]
    }
    
check_consistency()

Make sure that the required comps are included in the list of components supplied by the user. Also check that the parameters are consistent across the many components.

check_inputs(comps)

Check that the list of components comp is compatible with both the varmap and modelstr for this Model

diffname(name)

Transform a variable name into a derivative

evaluate(comps, funcname=’get’, diffmap=None, **kwargs)

Calculate the output of a model. It is recommended that at some point before using evaluate, that you make sure the inputs are valid using check_inputs

Parameters:
  • comps (list of Component) – Components which will be used to evaluate the model
  • funcname (string (default: 'get')) – Name of the function which to evaluate for the components which represent their output. That is, when each component is used in the evaluation, it is really their attr(comp, funcname) which is used.
  • diffmap (dictionary) – Extra mapping of derivatives or other symbols to extra variables. For example, the difference in a component has been evaluated as diff_obj so we set {'I': diff_obj}
  • **kwargs – Arguments passed to funcname of component objects
get_base_model()

The complete model, no derivatives

get_difference_model(category)

Get the equation corresponding to a variation wrt category. For example if:

modelstr = {
    'full' :'H(I) + B',
    'dH' : 'dH(I)',
    'dI' : 'H(dI)',
    'dB' : 'dB'
}

varmap = {'H': 'psf', 'I': 'obj', 'B': 'bkg'}

then get_difference_model('obj') == modelstr['dI'] == 'H(dI)'

map_vars(comps, funcname=’get’, diffmap=None, **kwargs)

Map component function funcname result into model variables dictionary for use in eval of the model. If diffmap is provided then that symbol is translated into ‘d’+diffmap.key and is replaced by diffmap.value. **kwargs` are passed to the ``comp.funcname(**kwargs).

class peri.models.ConfocalImageModel

Confocal microscope image with simplifications made for performance. In particular, the sensing and illumination point spread functions are combined into one:

\[\mathcal{M} = H(I(1-P) + CP) + B\]