pyhrf.jde.hrf module

class pyhrf.jde.hrf.HRFARSampler(do_sampling=True, use_true_value=False, val_ini=None, duration=25.0, zero_constraint=True, normalise=1.0, deriv_order=2, covar_hack=False, prior_type='voxelwiseIID', do_voxelwise_outputs=False, compute_ah_online=False, output_ah=False)

Bases: pyhrf.jde.hrf.HRFSampler

#THis class implements the sampling of the HRF when modelling a serially AR(1) noise process in the data. The structure of this noise is spatially varying in the sense that there is one AR parameter in combination with one noise variance per voxel.

computeStDS_StDY(reps, noiseInvCov, nrls, varMBYPl)
finalizeSampling()
linkToData(dataInput)
sampleNextInternal(variables)
class pyhrf.jde.hrf.HRFSampler(do_sampling=True, use_true_value=False, val_ini=None, duration=25.0, zero_constraint=True, normalise=1.0, deriv_order=2, covar_hack=False, prior_type='voxelwiseIID', do_voxelwise_outputs=False, compute_ah_online=False, output_ah=False)

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

#TODO : HRF sampler for BiGaussian NLR mixture

calcXh(hrf)
checkAndSetInitValue(variables)
computeStDS_StDY(rb, nrls, aa)
detectSignError()
finalizeSampling()
getCurrentVar()
getFinalVar()
getOutputs()
getScaleFactor()
get_accuracy(abs_error, rel_error, fv, tv, atol, rtol)
get_final_value()

Used to compare with simulated value

initObservables()
linkToData(dataInput)
parametersComments = {'prior_type': 'Type of prior:\n - "singleHRF": one HRF modelled for the whole parcel ~N(0,v_h*R).\n - "voxelwiseIID": one HRF per voxel, all HRFs are iid ~N(0,v_h*R).', 'do_sampling': 'Flag for the HRF estimation (True or False).\nIf set to False then the HRF is fixed to a canonical form.', 'normalise': 'If 1. : Normalise samples of Hrf and NRLs when they are sampled.\nIf 0. : Normalise posterior means of Hrf and NRLs when they are sampled.\nelse : Do not normalise.', 'duration': 'HRF length in seconds', 'covar_hack': 'Divide the term coming from the likelihood by the nb of voxels\n when computing the posterior covariance. The aim is to balance\n the contribution coming from the prior with that coming from the likelihood.\n Note: this hack is only taken into account when "singleHRf" is used for "prior_type"', 'zero_constraint': 'If True: impose first and last value = 0.\nIf False: no constraint.'}
parametersToShow = ['do_sampling', 'duration', 'zero_constraint']
reportCurrentVal()
sampleNextAlt(variables)
sampleNextInternal(variables)
samplingWarmUp(variables)
setFinalValue()
updateNorm()
updateObsersables()
updateXh()
class pyhrf.jde.hrf.HRFSamplerWithRelVar(do_sampling=True, use_true_value=False, val_ini=None, duration=25.0, zero_constraint=True, normalise=1.0, deriv_order=2, covar_hack=False, prior_type='voxelwiseIID', do_voxelwise_outputs=False, compute_ah_online=False, output_ah=False)

Bases: pyhrf.jde.hrf.HRFSampler

This class introduce a new variable w (Relevant Variable) w take its value in {0, 1} with :

w = 1 condition m is relevant in the studied parcel w = 1 otherwise
computeStDS_StDY_WithRelVar(rb, nrls, aa, w)
finalizeSampling()
linkToData(dataInput)
sampleNextInternal(variables)
class pyhrf.jde.hrf.HRF_Drift_Sampler(do_sampling=True, use_true_value=False, val_ini=None, duration=25.0, zero_constraint=True, normalise=1.0, deriv_order=2, covar_hack=False, prior_type='voxelwiseIID', do_voxelwise_outputs=False, compute_ah_online=False, output_ah=False)

Bases: pyhrf.jde.hrf.HRFSampler

Class handling the Gibbs sampling of Neural Response Levels in the case of joint drift sampling.

computeStDS_StDY(rb, nrls, aa)
class pyhrf.jde.hrf.HRF_Drift_SamplerWithRelVar(do_sampling=True, use_true_value=False, val_ini=None, duration=25.0, zero_constraint=True, normalise=1.0, deriv_order=2, covar_hack=False, prior_type='voxelwiseIID', do_voxelwise_outputs=False, compute_ah_online=False, output_ah=False)

Bases: pyhrf.jde.hrf.HRFSamplerWithRelVar

Class handling the Gibbs sampling of Neural Response Levels in the case of joint drift sampling.

computeStDS_StDY_WithRelVar(rb, nrls, aa, w)
class pyhrf.jde.hrf.HRF_two_parts_Sampler(do_sampling=True, use_true_value=False, val_ini=None, duration=25.0, zero_constraint=True, normalise=1.0, deriv_order=2, covar_hack=False, prior_type='voxelwiseIID', do_voxelwise_outputs=False, compute_ah_online=False, output_ah=False)

Bases: pyhrf.jde.hrf.HRFSampler

calcXh(hrf)
checkAndSetInitValue(variables)
computeStDS_StDY(rb, nrls, aa)
detectSignError()
finalizeSampling()
getCurrentVar()
getFinalVar()
getOutputs()
getScaleFactor()
initObservables()
linkToData(dataInput)
reportCurrentVal()
sampleNextAlt(variables)
sampleNextInternal(variables)
samplingWarmUp(variables)
setFinalValue()
updateNorm()
updateObsersables()
updateXh()
class pyhrf.jde.hrf.HRFwithHabSampler(do_sampling=True, use_true_value=False, val_ini=None, duration=25.0, zero_constraint=True, normalise=1.0, deriv_order=2, covar_hack=False, prior_type='voxelwiseIID', do_voxelwise_outputs=False, compute_ah_online=False, output_ah=False)

Bases: pyhrf.jde.hrf.HRFSampler

computeStDS_StDY(rb, sumaX, Q)
finalizeSampling()
getScaleFactor()
linkToData(dataInput)
sampleNextInternal(variables)
updateNorm()
class pyhrf.jde.hrf.RHSampler(do_sampling=True, use_true_value=False, val_ini=array([ 0.1]), prior_mean=0.001, prior_var=10)

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

#TODO : comment

checkAndSetInitValue(variables)
getOutputs()
get_final_value()
linkToData(dataInput)
parametersToShow = ['do_sampling', 'val_ini']
sampleNextInternal(variables)
class pyhrf.jde.hrf.ScaleSampler(do_sampling=False, use_true_value=False, val_ini=array([ 1.]))

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

getOutputs()
linkToData(dataInput)
sampleNextInternal(variables)
pyhrf.jde.hrf.buildDiagGaussianMat(size, width)
pyhrf.jde.hrf.msqrt(cov)

sig = msqrt(cov)

Return a matrix square root of a covariance matrix. Tries Cholesky factorization first, and factorizes by diagonalization if that fails.

pyhrf.jde.hrf.sampleHRF_single_hrf(stLambdaS, stLambdaY, varR, rh, nbColX, nbVox)
pyhrf.jde.hrf.sampleHRF_single_hrf_hack(stLambdaS, stLambdaY, varR, rh, nbColX, nbVox)
pyhrf.jde.hrf.sampleHRF_voxelwise_iid(stLambdaS, stLambdaY, varR, rh, nbColX, nbVox)