Fork me on GitHub

pyhrf.jde.asl module

class pyhrf.jde.asl.ASLSampler(nb_iterations=3000, obs_hist_pace=-1.0, glob_obs_hist_pace=-1, smpl_hist_pace=-1.0, burnin=0.3, callback=<pyhrf.jde.samplerbase.GSDefaultCallbackHandler object>, bold_response_levels=<pyhrf.jde.asl.BOLDResponseLevelSampler object>, perf_response_levels=<pyhrf.jde.asl.PerfResponseLevelSampler object>, labels=<pyhrf.jde.asl.LabelSampler object>, noise_var=<pyhrf.jde.asl.NoiseVarianceSampler object>, brf=<pyhrf.jde.asl.BOLDResponseSampler object>, brf_var=<pyhrf.jde.asl.BOLDResponseVarianceSampler object>, prf=<pyhrf.jde.asl.PerfResponseSampler object>, prf_var=<pyhrf.jde.asl.PerfResponseVarianceSampler object>, bold_mixt_params=<pyhrf.jde.asl.BOLDMixtureSampler object>, perf_mixt_params=<pyhrf.jde.asl.PerfMixtureSampler object>, drift=<pyhrf.jde.asl.DriftCoeffSampler object>, drift_var=<pyhrf.jde.asl.DriftVarianceSampler object>, perf_baseline=<pyhrf.jde.asl.PerfBaselineSampler object>, perf_baseline_var=<pyhrf.jde.asl.PerfBaselineVarianceSampler object>, check_final_value=None, output_fit=False)

Bases: pyhrf.xmlio.Initable, pyhrf.jde.samplerbase.GibbsSampler

computeFit()
default_nb_its = 3000
finalizeSampling()
getGlobalOutputs()
inputClass

alias of WN_BiG_ASLSamplerInput

parametersToShow = ['nb_its', 'bold_response_levels', 'brf', 'brf_var', 'prf', 'prf_var']
class pyhrf.jde.asl.BOLDMixtureSampler(val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.asl.MixtureParamsSampler, pyhrf.xmlio.Initable

get_true_values_from_simulation_cdefs(cdefs)
class pyhrf.jde.asl.BOLDResponseLevelSampler(val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.asl.ResponseLevelSampler, pyhrf.xmlio.Initable

computeVarYTildeOpt(update_perf=False)

if update_perf is True then also update sumcXg and prl.ytilde update_perf should only be used at init of variable values.

getOutputs()
samplingWarmUp(v)
class pyhrf.jde.asl.BOLDResponseSampler(smooth_order=2, zero_constraint=True, duration=25.0, normalise=1.0, val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.asl.ResponseSampler, pyhrf.xmlio.Initable

computeYTilde()

y - sum cWXg - Pl - wa

get_mat_X()
get_mat_XtX()
get_stackX()
class pyhrf.jde.asl.BOLDResponseVarianceSampler(val_ini=array([ 0.001]), do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.asl.ResponseVarianceSampler, pyhrf.xmlio.Initable

class pyhrf.jde.asl.DriftCoeffSampler(val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.samplerbase.GibbsSamplerVariable, pyhrf.xmlio.Initable

checkAndSetInitValue(variables)
compute_y_tilde()
get_accuracy(abs_error, rel_error, fv, tv, atol, rtol)

Return the accuray of the estimate fv, compared to the true value tv

Output:
axes_names (list of str), accuracy (numpy array of booleans)
get_final_value()
get_true_value()
linkToData(dataInput)
sampleNextInternal(variables)

Define the behaviour of the variable at each sampling step when its sampling is not activated. Must be overriden in child classes.

updateNorm()
class pyhrf.jde.asl.DriftVarianceSampler(val_ini=array([ 1.]), do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.samplerbase.GibbsSamplerVariable, pyhrf.xmlio.Initable

checkAndSetInitValue(variables)
linkToData(dataInput)
sampleNextInternal(variables)

Define the behaviour of the variable at each sampling step when its sampling is not activated. Must be overriden in child classes.

class pyhrf.jde.asl.LabelSampler(val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.samplerbase.GibbsSamplerVariable, pyhrf.xmlio.Initable

CLASSES = array([0, 1])
CLASS_NAMES = ['inactiv', 'activ']
L_CA = 1
L_CI = 0
checkAndSetInitValue(variables)
compute_ext_field()
countLabels()
get_MAP_labels()
linkToData(dataInput)
sampleNextInternal(v)

Define the behaviour of the variable at each sampling step when its sampling is not activated. Must be overriden in child classes.

samplingWarmUp(v)

Called before the launch of the main sampling loop by the sampler engine. Should be overriden and perform precalculations.

class pyhrf.jde.asl.MixtureParamsSampler(name, response_level_name, val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.samplerbase.GibbsSamplerVariable

I_MEAN_CA = 0
I_VAR_CA = 1
I_VAR_CI = 2
L_CA = 1
L_CI = 0
NB_PARAMS = 3
PARAMS_NAMES = ['Mean_Activ', 'Var_Activ', 'Var_Inactiv']
checkAndSetInitValue(variables)
computeWithJeffreyPriors(j, cardCIj, cardCAj)
get_current_means()
get_current_vars()
get_true_values_from_simulation_dict()
linkToData(dataInput)
sampleNextInternal(variables)
class pyhrf.jde.asl.NoiseVarianceSampler(val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.samplerbase.GibbsSamplerVariable, pyhrf.xmlio.Initable

checkAndSetInitValue(variables)
compute_y_tilde()
linkToData(dataInput)
sampleNextInternal(variables)

Define the behaviour of the variable at each sampling step when its sampling is not activated. Must be overriden in child classes.

class pyhrf.jde.asl.PerfBaselineSampler(val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.samplerbase.GibbsSamplerVariable, pyhrf.xmlio.Initable

checkAndSetInitValue(variables)
compute_residuals()
compute_wa(a=None)
linkToData(dataInput)
sampleNextInternal(v)

Define the behaviour of the variable at each sampling step when its sampling is not activated. Must be overriden in child classes.

class pyhrf.jde.asl.PerfBaselineVarianceSampler(val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.samplerbase.GibbsSamplerVariable, pyhrf.xmlio.Initable

checkAndSetInitValue(variables)
linkToData(dataInput)
sampleNextInternal(v)

Define the behaviour of the variable at each sampling step when its sampling is not activated. Must be overriden in child classes.

class pyhrf.jde.asl.PerfMixtureSampler(val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.asl.MixtureParamsSampler, pyhrf.xmlio.Initable

checkAndSetInitValue(variables)
get_true_values_from_simulation_cdefs(cdefs)
class pyhrf.jde.asl.PerfResponseLevelSampler(val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.asl.ResponseLevelSampler, pyhrf.xmlio.Initable

checkAndSetInitValue(variables)
computeVarYTildeOpt()
class pyhrf.jde.asl.PerfResponseSampler(smooth_order=2, zero_constraint=True, duration=25.0, normalise=1.0, val_ini=None, do_sampling=True, use_true_value=False, diff_res=True)

Bases: pyhrf.jde.asl.ResponseSampler, pyhrf.xmlio.Initable

computeYTilde()

y - sum aXh - Pl - wa

get_mat_X()
get_mat_XtX()
get_stackX()
class pyhrf.jde.asl.PerfResponseVarianceSampler(val_ini=array([ 0.001]), do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.asl.ResponseVarianceSampler, pyhrf.xmlio.Initable

class pyhrf.jde.asl.ResponseLevelSampler(name, response_name, mixture_name, val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.samplerbase.GibbsSamplerVariable

checkAndSetInitValue(variables)
computeRR()
computeVarYTildeOpt()
getOutputs()
linkToData(dataInput)
sampleNextInternal(variables)
samplingWarmUp(variables)
updateObsersables()
class pyhrf.jde.asl.ResponseSampler(name, response_level_name, variance_name, smooth_order=2, zero_constraint=True, duration=25.0, normalise=1.0, val_ini=None, do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.samplerbase.GibbsSamplerVariable

Generic parent class to perfusion response & BOLD response samplers

calcXResp(resp, stackX=None)
checkAndSetInitValue(variables)
computeYTilde()
get_mat_X()
get_mat_XtX()
get_rlrl()
get_stackX()
get_ybar()
linkToData(dataInput)
sampleNextInternal(variables)
setFinalValue()
updateNorm()
updateXResp()
class pyhrf.jde.asl.ResponseVarianceSampler(name, response_name, val_ini=array([ 0.001]), do_sampling=True, use_true_value=False)

Bases: pyhrf.jde.samplerbase.GibbsSamplerVariable

checkAndSetInitValue(v)
linkToData(dataInput)
sampleNextInternal(v)
class pyhrf.jde.asl.WN_BiG_ASLSamplerInput(data, dt, typeLFD, paramLFD, hrfZc, hrfDuration)

Bases: pyhrf.jde.models.WN_BiG_Drift_BOLDSamplerInput

cleanPrecalculations()
makePrecalculations()
pyhrf.jde.asl.b()
pyhrf.jde.asl.compute_StS_StY(rls, v_b, mx, mxtx, ybar, rlrl, yaj, ajak_vb)

yaj and ajak_vb are only used to store intermediate quantities, they’re not inputs.

pyhrf.jde.asl.randn(d0, d1, ..., dn)

Return a sample (or samples) from the “standard normal” distribution.

If positive, int_like or int-convertible arguments are provided, randn generates an array of shape (d0, d1, ..., dn), filled with random floats sampled from a univariate “normal” (Gaussian) distribution of mean 0 and variance 1 (if any of the d_i are floats, they are first converted to integers by truncation). A single float randomly sampled from the distribution is returned if no argument is provided.

This is a convenience function. If you want an interface that takes a tuple as the first argument, use numpy.random.standard_normal instead.

Parameters:d1, .., dn (d0,) – The dimensions of the returned array, should be all positive. If no argument is given a single Python float is returned.
Returns:Z – A (d0, d1, ..., dn)-shaped array of floating-point samples from the standard normal distribution, or a single such float if no parameters were supplied.
Return type:ndarray or float

See also

random.standard_normal()
Similar, but takes a tuple as its argument.

Notes

For random samples from N(\mu, \sigma^2), use:

sigma * np.random.randn(...) + mu

Examples

>>> np.random.randn()
2.1923875335537315 #random

Two-by-four array of samples from N(3, 6.25):

>>> 2.5 * np.random.randn(2, 4) + 3
array([[-4.49401501,  4.00950034, -1.81814867,  7.29718677],  #random
       [ 0.39924804,  4.68456316,  4.99394529,  4.84057254]]) #random
pyhrf.jde.asl.simulate_asl(output_dir=None, noise_scenario='high_snr', spatial_size='tiny', v_noise=None, dt=0.5, tr=2.5)