class gamma_nmr_cyl(FreeParameterConfig): init_value = 5 lower_bound = 1 upper_bound = 10 parameter_transform = SinSqrClampTransform() sampling_proposal = GaussianProposal(1)
class Dt(FreeParameterConfig): init_value = 1.7e-10 lower_bound = 0 upper_bound = 1.0e-8 parameter_transform = SinSqrClampTransform() sampling_proposal = GaussianProposal(1e-14)
class gamma_beta(FreeParameterConfig): init_value = 1 lower_bound = 1.0e-7 upper_bound = 3.0e-7 parameter_transform = SinSqrClampTransform() sampling_proposal = GaussianProposal(1e-7)
class gamma_k(FreeParameterConfig): init_value = 1 lower_bound = 0 upper_bound = 20 parameter_transform = SinSqrClampTransform() sampling_proposal = GaussianProposal(1.0)
class kappa(FreeParameterConfig): init_value = 1 lower_bound = 1e-5 upper_bound = 2 * np.pi parameter_transform = CosSqrClampTransform() sampling_proposal = GaussianProposal(0.01)
class s0(FreeParameterConfig): init_value = 1e4 lower_bound = 1e-5 upper_bound = 1e10 parameter_transform = ClampTransform() sampling_proposal = GaussianProposal(std=25.0)
class T2s(FreeParameterConfig): init_value = 0.01 lower_bound = 0.0 upper_bound = 1.0 parameter_transform = ClampTransform() sampling_proposal = GaussianProposal(0.0001)
class FreeParameterConfig(ParameterConfig): """The default config options for free parameters. This sets the attribute type to free. 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: the parameter transformation sampling_proposal: the proposal function sampling_prior: the prior function sampling_statistics: the sampling statistic, used after the sampling """ type = 'free' data_type = 'mot_float_type' fixed = False init_value = 0.03 lower_bound = 0.0 upper_bound = 4.0 parameter_transform = IdentityTransform() sampling_proposal = GaussianProposal(1.0) sampling_prior = UniformWithinBoundsPrior() sampling_statistics = GaussianPSS()
def __init__(self): r"""This is a collapsed form of the Beta PDF meant for use in Automatic Relevance Detection sampling. In this prior the ``alpha`` parameter of the Beta prior is set to 1 which simplifies the equation. The parameter ``beta`` is still free and can be changed as desired. The implemented prior is: .. math:: B(x; 1, \beta) = \beta * (1 - x)^{\beta - 1} """ from mot.model_building.cl_functions.parameters import FreeParameter params = [ FreeParameter(SimpleCLDataType.from_string('mot_float_type'), 'beta', False, 1, 1e-4, 1000, sampling_prior=ReciprocalPrior(), sampling_proposal=GaussianProposal(0.01)) ] body = ''' if(value < 0 || value > 1){ return 0; } return beta * pow(1 - value, beta - 1); ''' super(ARDBeta, self).__init__(body, 'ard_beta_pdf', params)
def __init__(self): """This is a Gaussian prior meant for use in Automatic Relevance Detection sampling. This uses a Gaussian prior with mean at zero and a standard deviation determined by the ``alpha`` parameter with the relationship :math:`\sigma = 1/\\sqrt(\\alpha)`. """ from mot.model_building.cl_functions.parameters import FreeParameter params = [ FreeParameter(SimpleCLDataType.from_string('mot_float_type'), 'alpha', False, 8, 1e-5, 1e4, sampling_prior=UniformWithinBoundsPrior(), sampling_proposal=GaussianProposal(20)) ] body = ''' if(value < 0 || value > 1){ return 0; } mot_float_type sigma = 1.0/sqrt(alpha); return exp(-pown(value, 2) / (2 * pown(sigma, 2))) / (sigma * sqrt(2 * M_PI)); ''' super(ARDGaussian, self).__init__(body, 'ard_beta_pdf', params)
class R(FreeParameterConfig): init_value = 2.0e-6 lower_bound = 1e-6 upper_bound = 20e-6 parameter_transform = CosSqrClampTransform() sampling_proposal = GaussianProposal(1e-6)
class R2s(FreeParameterConfig): """R2s = 1/T2s, for lineaR T2sDec or other models.""" init_value = 10 lower_bound = 1 upper_bound = 50.0 parameter_transform = ClampTransform() sampling_proposal = GaussianProposal(0.0001)
class R2(FreeParameterConfig): """R2 = 1/T2, for linear T2Dec or other models.""" init_value = 5 lower_bound = 0.5 upper_bound = 500.0 parameter_transform = ClampTransform() sampling_proposal = GaussianProposal(0.0001)
class R1(FreeParameterConfig): """R1 = 1/T1, for linear T1Dec or other models. """ init_value = 2 lower_bound = 0.25 upper_bound = 100.0 parameter_transform = ClampTransform() sampling_proposal = GaussianProposal(0.0001)
class E1(FreeParameterConfig): """This parameter is defined *only* for linear decay T1 fitting in GRE data *with* TR constant. This parameter is also defined in the SSFP equation. However, in SSFP this parameter is from the protocol (!) E1 = exp( -TR / T1 ). After estimation of this parameter, T1 can be recovered by applying the next equation: -TR / log( E1 ). """ init_value = 0.37 lower_bound = 0.0 upper_bound = 1.0 parameter_transform = ClampTransform() sampling_proposal = GaussianProposal(0.0001)
def __init__(self, data_type, name, fixed, value, lower_bound, upper_bound, parameter_transform=None, sampling_proposal=None, sampling_prior=None, sampling_statistics=None): """This are the kind of parameters that are generally meant to be optimized. These parameters may optionally be fixed to a value or list of values for all voxels. Args: data_type (mot.cl_data_type.SimpleCLDataType): the data type expected by this parameter name (str): The name of this parameter fixed (boolean): If this parameter is fixed to the value given value (double or ndarray): A single value for all voxels or a list of values for each voxel lower_bound (double): The lower bound of this parameter upper_bound (double): The upper bound of this parameter parameter_transform (AbstractTransformation): The parameter transformation function sampling_proposal (ParameterProposal): The proposal function for use in model sampling sampling_prior (ParameterPrior): The prior function for use in model sampling sampling_statistics (ParameterSampleStatistics): The statistic functions used to get statistics out of the samples Attributes: value (number or ndarray): The value of this state lower_bound (number or ndarray): The lower bound upper_bound (number or ndarray): The upper bound fixed (boolean): If this free parameter is fixed to its value. parameter_transform (AbstractTransformation): The parameter transformation (codec information) sampling_proposal (ParameterProposal): The proposal function for use in model sampling sampling_prior (ParameterPrior): The prior function for use in model sampling sampling_statistics (ParameterSampleStatistics): The statistic functions used to get statistics out of the samples """ super(FreeParameter, self).__init__(data_type, name) self._value = value self._lower_bound = lower_bound self._upper_bound = upper_bound self._fixed = fixed self._parameter_transform = parameter_transform or IdentityTransform() self._sampling_proposal = sampling_proposal or GaussianProposal(1.0) self._sampling_prior = sampling_prior or UniformWithinBoundsPrior() self._sampling_statistics = sampling_statistics or GaussianPSS()
def __init__(self, name='Weight', value=0.5, lower_bound=0.0, upper_bound=1.0, parameter_kwargs=None): """Implements Scalar model function to add the semantics of representing a Weight. Some of the code checks for type Weight, be sure to use this model function if you want to represent a Weight. A weight is meant to be a model volume fraction. Args: name (str): The name of the model value (number or ndarray): The initial value for the single free parameter of this function. lower_bound (number or ndarray): The initial lower bound for the single free parameter of this function. upper_bound (number or ndarray): The initial upper bound for the single free parameter of this function. """ parameter_settings = dict(parameter_transform=CosSqrClampTransform(), sampling_proposal=GaussianProposal(0.01), sampling_prior=UniformWithinBoundsPrior()) parameter_settings.update(parameter_kwargs or {}) super(Weight, self).__init__(name=name, param_name='w', value=value, lower_bound=lower_bound, upper_bound=upper_bound, parameter_kwargs=parameter_settings)
def __init__(self, name='Scalar', param_name='s', value=0.0, lower_bound=0.0, upper_bound=float('inf'), parameter_kwargs=None): """A Scalar model function to be used during optimization. Args: name (str): The name of the model value (number or ndarray): The initial value for the single free parameter of this function. lower_bound (number or ndarray): The initial lower bound for the single free parameter of this function. upper_bound (number or ndarray): The initial upper bound for the single free parameter of this function. parameter_kwargs (dict): additional settings for the parameter initialization """ parameter_settings = dict(parameter_transform=ClampTransform(), sampling_proposal=GaussianProposal(1.0)) parameter_settings.update(parameter_kwargs or {}) super(Scalar, self).__init__( name, 'cmScalar', (FreeParameter(SimpleCLDataType.from_string('mot_float_type'), param_name, False, value, lower_bound, upper_bound, **parameter_settings),))