コード例 #1
0
def build_param(index):
    """Get one of the parameters of the Kurtosis matrix as an object.

    Args:
        tuple: index, 4 integers specyfing the location of this parameter in the matrix.

    Returns:
        Parameter: a constructed parameter to be used in a compartment model.
    """
    if len(set(index)) == 1:
        _lower_bound = 0
        _init_value = 0.001
        _sampling_prior = UniformWithinBoundsPrior()
    else:
        _lower_bound = -1e20
        _init_value = 0
        _sampling_prior = AlwaysOne()

    class matrix_element_param(FreeParameterTemplate):
        name = 'W_{}{}{}{}'.format(*index)
        init_value = _init_value
        lower_bound = _lower_bound
        upper_bound = 1e20
        parameter_transform = ScaleTransform(100)
        sampling_prior = _sampling_prior
        sampling_proposal_std = 0.01

    return ParameterBuilder().create_class(matrix_element_param)()
コード例 #2
0
ファイル: free.py プロジェクト: stijnimaging/MDT
class w(FreeParameterTemplate):

    init_value = 0.5
    lower_bound = 0
    upper_bound = 1
    sampling_proposal_std = 0.01
    sampling_prior = UniformWithinBoundsPrior()
    numdiff_info = {'scale_factor': 10}
コード例 #3
0
class FreeParameterTemplate(ParameterTemplate):
    """The default template options for free parameters.

    Attributes:
        init_value (float): the initial value
        fixed (boolean or ndarray of float): if this parameter is fixed or not. If not fixed this should
            hold a reference to a value or a matrix
        lower_bound (float): the lower bounds
        upper_bound (float): the upper bounds
        parameter_transform
            (str or :class:`~mdt.model_building.parameter_functions.transformations.AbstractTransformation`): the
            parameter transformation, this is used for automatic range transformation of the parameters during
            optimization. See Harms 2017 NeuroImage for details. Typical elements are:

            * ``Identity``: no transformation
            * ``Positivity``: ensures the parameters are positive
            * ``Clamp``: limits the parameter between its lower and upper bounds
            * ``CosSqrClamp``: changes the range of the optimized parameters to [0, 1] and ensures boundary constraints
            * ``SinSqrClamp``: same as ``CosSqrClamp``
            * ``SqrClamp``: same as clamp but with an additional square root to change the magnitude of the range
            * ``AbsModPi``: ensures absolute modulus of the input parameters between zero and pi.
            * ``AbsModTwoPi``: ensures absolute modulus of the input parameters between zero and two pi.

        sampling_proposal_std (float): the default proposal standard deviation for this parameter. This is used
            in some MCMC sampling routines.
        sampling_proposal_modulus (float or None): if given, a modulus we will use when finalizing the proposal
            distributions. That is, when we are finalizing the proposals we will take, if set, the absolute
            modulus of that parameter to ensure the parameter is within [0, <modulus>].
        sampling_prior: the prior function
        numdiff_info (dict or :class:`~mdt.model_building.parameter_functions.numdiff_info.NumDiffInfo`):
            the information necessary to take the numerical derivative of a model with respect to this parameter.
            Either a dictionary with the keyword arguments to
            :class:`~mdt.model_building.parameter_functions.numdiff_info.SimpleNumDiffInfo` or an information
            object directly. If None, we use an empty dictionary. Please note that if you override this, you will have
            to specify all of the items (no automatic inheritance of sub-items).
    """
    data_type = 'mot_float_type'
    fixed = False
    init_value = 0.03
    lower_bound = 0.0
    upper_bound = 4.0
    parameter_transform = 'Identity'
    sampling_proposal_std = 1
    sampling_proposal_modulus = None
    sampling_prior = UniformWithinBoundsPrior()
    numdiff_info = {
        'max_step': 0.1,
        'scale_factor': 1,
        'use_bounds': True,
        'modulus': None,
        'use_upper_bound': True,
        'use_lower_bound': True
    }