pyhrf.jde.jde_multi_sujets_alpha module¶
- 
class pyhrf.jde.jde_multi_sujets_alpha.AlphaVar_Sampler(val_ini=None, do_sampling=True, use_true_value=False)¶
- Bases: - pyhrf.xmlio.Initable,- pyhrf.jde.samplerbase.GibbsSamplerVariable- Gibbs sampler of the variance of the Inverse Gamma prior used to regularise the estimation of the low frequency drift embedded in the fMRI time course - 
checkAndSetInitValue(variables)¶
 - 
linkToData(dataInput)¶
 - 
sampleNextInternal(variables)¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.Alpha_hgroup_Sampler(val_ini=None, do_sampling=True, use_true_value=False)¶
- Bases: - pyhrf.xmlio.Initable,- pyhrf.jde.samplerbase.GibbsSamplerVariable- 
checkAndSetInitValue(variables)¶
 - 
linkToData(dataInput)¶
 - 
parametersToShow= []¶
 - 
sampleNextInternal(variables)¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.BOLDGibbs_Multi_SubjSampler(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_subj=<pyhrf.jde.jde_multi_sujets_alpha.NRLs_Sampler object>, labels=<pyhrf.jde.jde_multi_sujets_alpha.LabelSampler object>, noise_var=<pyhrf.jde.jde_multi_sujets_alpha.NoiseVariance_Drift_MultiSubj_Sampler object>, hrf_subj=<pyhrf.jde.jde_multi_sujets_alpha.HRF_Sampler object>, hrf_subj_var=<pyhrf.jde.jde_multi_sujets_alpha.HRFVarianceSubjectSampler object>, hrf_group=<pyhrf.jde.jde_multi_sujets_alpha.HRF_Group_Sampler object>, hrf_group_var=<pyhrf.jde.jde_multi_sujets_alpha.RHGroupSampler object>, mixt_params=<pyhrf.jde.jde_multi_sujets_alpha.MixtureParamsSampler object>, drift=<pyhrf.jde.jde_multi_sujets_alpha.Drift_MultiSubj_Sampler object>, drift_var=<pyhrf.jde.jde_multi_sujets_alpha.ETASampler_MultiSubj object>, alpha=<pyhrf.jde.jde_multi_sujets_alpha.Alpha_hgroup_Sampler object>, alpha_var=<pyhrf.jde.jde_multi_sujets_alpha.AlphaVar_Sampler object>, check_final_value=None)¶
- Bases: - pyhrf.xmlio.Initable,- pyhrf.jde.samplerbase.GibbsSampler- 
cleanObservables()¶
 - 
computeFit()¶
 - 
computePMStimInducedSignal()¶
 - 
compute_crit_diff(old_vals, means=None)¶
 - 
default_nb_its= 3000¶
 - 
finalizeSampling()¶
 - 
getGlobalOutputs()¶
 - 
initGlobalObservables()¶
 - 
inputClass¶
- alias of - BOLDSampler_MultiSujInput
 - 
saveGlobalObservables(it)¶
 - 
stop_criterion(it)¶
 - 
updateGlobalObservables()¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.BOLDSampler_MultiSujInput(GroupData, dt, typeLFD, paramLFD, hrfZc, hrfDuration)¶
- Class holding data needed by the sampler : BOLD time courses for each voxel, onsets and voxel topology. It also perform some precalculation such as the convolution matrix based on the onsests (L{stackX}) —- Multi-subjects version (cf. merge_fmri_subjects in core.py) - 
buildCosMat(paramLFD, ny)¶
 - 
buildOtherMatX()¶
 - 
buildParadigmConvolMatrix(zc, estimDuration, availableDataIndex, parData)¶
 - 
buildPolyMat(paramLFD, n)¶
 - 
calcDt(dtMin)¶
 - 
chewUpOnsets(dt, hrfZc, hrfDuration)¶
 - 
cleanMem()¶
 - 
makePrecalculations()¶
 - 
setLFDMat(paramLFD, typeLFD)¶
- Build the low frequency basis from polynomial basis functions. 
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.BiGaussMixtureParamsSampler(val_ini=None, do_sampling=True, use_true_value=False, prior_type='Jeffrey', var_ci_pr_alpha=2.04, var_ci_pr_beta=2.08, var_ca_pr_alpha=2.01, var_ca_pr_beta=0.5, mean_ca_pr_mean=5.0, mean_ca_pr_var=20.0, mean_activation_threshold=4.0)¶
- Bases: - pyhrf.xmlio.Initable,- 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)¶
 - 
computeWithProperPriors(j, cardCIj, cardCAj)¶
 - 
finalizeSampling()¶
 - 
getCurrentMeans()¶
 - 
getCurrentVars()¶
 - 
getOutputs()¶
 - 
get_string_value(v)¶
 - 
linkToData(dataInput)¶
 - 
parametersComments= {'prior_type': "Either 'proper' or 'Jeffrey'", 'mean_activation_threshold': 'Threshold for the max activ mean above which the region is considered activating'}¶
 - 
sampleNextInternal(variables)¶
 - 
updateObsersables()¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.Drift_MultiSubj_Sampler(val_ini=None, do_sampling=True, use_true_value=False)¶
- Bases: - pyhrf.xmlio.Initable,- pyhrf.jde.samplerbase.GibbsSamplerVariable- Gibbs sampler of the parameters modelling the low frequency drift in the fMRI time course, in the case of white noise. - 
P_SAMPLE_FLAG= 'sampleFlag'¶
 - 
P_USE_TRUE_VALUE= 'useTrueValue'¶
 - 
P_VAL_INI= 'initialValue'¶
 - 
checkAndSetInitValue(variables)¶
 - 
defaultParameters= {'useTrueValue': False, 'initialValue': None, 'sampleFlag': True}¶
 - 
getOutputs()¶
 - 
get_accuracy(abs_error, rel_error, fv, tv, atol, rtol)¶
 - 
get_final_value()¶
 - 
get_true_value()¶
 - 
linkToData(dataInput)¶
 - 
sampleNextAlt(variables)¶
 - 
sampleNextInternal(variables)¶
 - 
updateNorm()¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.ETASampler_MultiSubj(val_ini=None, do_sampling=True, use_true_value=False)¶
- Bases: - pyhrf.xmlio.Initable,- pyhrf.jde.samplerbase.GibbsSamplerVariable- Gibbs sampler of the variance of the Inverse Gamma prior used to regularise the estimation of the low frequency drift embedded in the fMRI time course - 
checkAndSetInitValue(variables)¶
 - 
linkToData(dataInput)¶
 - 
sampleNextInternal(variables)¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.HRFVarianceSubjectSampler(val_ini=array([ 0.05]), do_sampling=False, use_true_value=False, pr_mean=0.001, pr_var=10.0)¶
- Bases: - pyhrf.xmlio.Initable,- pyhrf.jde.samplerbase.GibbsSamplerVariable- 
PR_MEAN= 0.001¶
 - 
PR_VAR= 10.0¶
 - 
VAL_INI= 0.05¶
 - 
checkAndSetInitValue(variables)¶
 - 
getOutputs()¶
 - 
linkToData(dataInput)¶
 - 
sampleNextInternal(variables)¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.HRF_Group_Sampler(val_ini=None, do_sampling=True, use_true_value=False, duration=25.0, zero_constraint=True, normalise=1.0, derivOrder=2, output_hrf_pm=True, hack_covar_apost=False, prior_type='voxelwiseIID', compute_ah_online=False, regularize_hrf=True, model_subjects_only=False, voxelwise_outputs=False)¶
- Bases: - pyhrf.xmlio.Initable,- pyhrf.jde.samplerbase.GibbsSamplerVariable- HRF sampler for multisubjects model - 
checkAndSetInitValue(variables)¶
 - 
finalizeSampling()¶
 - 
getCurrentVar()¶
 - 
getFinalVar()¶
 - 
getOutputs()¶
 - 
getScaleFactor()¶
 - 
get_accuracy(abs_error, rel_error, fv, tv, atol, rtol)¶
 - 
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).', 'hack_covar_apost': '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"', '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, NRLs and Mixture Parameters when they are sampled.\nIf 0. : Normalise posterior means of Hrf, NRLs and Mixture Parameters when they are sampled.\nelse : Do not normalise.', 'model_subjects_only': 'If 1: Put hrf group at zero and only estimate hrf by subjects.If 0: Perform group hemodynamic estimation, hrf group sampled', 'duration': 'HRF length in seconds', 'zero_constraint': 'If True: impose first and last value = 0.\nIf False: no constraint.'}¶
 - 
parametersToShow= ['duration', 'zero_constraint', 'do_sampling', 'output_hrf_pm']¶
 - 
reportCurrentVal()¶
 - 
sampleNextAlt(variables)¶
 - 
sampleNextInternal(variables)¶
 - 
samplingWarmUp(variables)¶
 - 
setFinalValue()¶
 - 
updateNorm()¶
 - 
updateObsersables()¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.HRF_Sampler(val_ini=None, do_sampling=True, use_true_value=False, duration=25.0, zero_constraint=True, normalise=1.0, derivOrder=2, output_hrf_pm=True, hack_covar_apost=False, prior_type='voxelwiseIID', compute_ah_online=False, regularize_hrf=True, model_subjects_only=False, voxelwise_outputs=False)¶
- Bases: - pyhrf.xmlio.Initable,- pyhrf.jde.samplerbase.GibbsSamplerVariable- HRF sampler for multisession model - 
calcXh(hrfs)¶
 - 
checkAndSetInitValue(variables)¶
 - 
computeStDS_StDY(rb_allSubj, nrls_allSubj, aa_allSubj)¶
 - 
computeStDS_StDY_one_subject(rb, nrls, aa, subj)¶
 - 
finalizeSampling()¶
 - 
getCurrentVar()¶
 - 
getFinalVar()¶
 - 
getOutputs()¶
 - 
getScaleFactor()¶
 - 
get_accuracy(abs_error, rel_error, fv, tv, atol, rtol)¶
 - 
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).', 'hack_covar_apost': '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"', '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, NRLs and Mixture Parameters when they are sampled.\nIf 0. : Normalise posterior means of Hrf, NRLs and Mixture Parameters when they are sampled.\nelse : Do not normalise.', 'duration': 'HRF length in seconds', 'zero_constraint': 'If True: impose first and last value = 0.\nIf False: no constraint.'}¶
 - 
parametersToShow= ['duration', 'zero_constraint', 'do_sampling', 'output_hrf_pm']¶
 - 
reportCurrentVal()¶
 - 
sampleNextAlt(variables)¶
 - 
sampleNextInternal(variables)¶
 - 
samplingWarmUp(variables)¶
 - 
setFinalValue()¶
 - 
updateNorm()¶
 - 
updateObsersables()¶
 - 
updateXh()¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.LabelSampler(val_ini=None, do_sampling=True, use_true_value=False)¶
- Bases: - pyhrf.xmlio.Initable,- pyhrf.jde.samplerbase.GibbsSamplerVariable- 
CLASSES= array([0, 1])¶
 - 
CLASS_NAMES= ['inactiv', 'activ']¶
 - 
L_CA= 1¶
 - 
L_CI= 0¶
 - 
checkAndSetInitValue(variables)¶
 - 
compute_ext_field()¶
 - 
countLabels()¶
 - 
linkToData(dataInput)¶
 - 
sampleNextInternal(v)¶
 - 
samplingWarmUp(v)¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.MixtureParamsSampler(val_ini=None, do_sampling=True, use_true_value=False)¶
- Bases: - pyhrf.xmlio.Initable,- 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, s, cardCIj, cardCAj)¶
 - 
get_current_means()¶
- return array of shape (class, subject, condition) 
 - 
get_current_vars()¶
- return array of shape (class, subject, condition) 
 - 
get_true_values_from_simulation_cdefs(cdefs)¶
 - 
linkToData(dataInput)¶
 - 
sampleNextInternal(variables)¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.NRLs_Sampler(val_ini=None, do_sampling=True, use_true_value=False)¶
- Bases: - pyhrf.xmlio.Initable,- pyhrf.jde.samplerbase.GibbsSamplerVariable- 
CLASSES= array([0, 1])¶
 - 
CLASS_NAMES= ['inactiv', 'activ']¶
 - 
FALSE_NEG= 3¶
 - 
FALSE_POS= 2¶
 - 
L_CA= 1¶
 - 
L_CI= 0¶
 - 
checkAndSetInitValue(variables)¶
 - 
computeAA()¶
 - 
computeVarYTildeOpt(varXh, s)¶
 - 
linkToData(dataInput)¶
 - 
sampleNextInternal(variables)¶
 - 
samplingWarmUp(variables)¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.NoiseVariance_Drift_MultiSubj_Sampler(val_ini=None, do_sampling=True, use_true_value=False)¶
- Bases: - pyhrf.jde.noise.NoiseVariance_Drift_Sampler- 
checkAndSetInitValue(variables)¶
 - 
linkToData(dataInput)¶
 - 
parametersToShow= []¶
 - 
sampleNextInternal(variables)¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.RHGroupSampler(val_ini=array([ 0.05]), do_sampling=False, use_true_value=False, pr_mean=0.001, pr_var=10.0)¶
- Bases: - pyhrf.xmlio.Initable,- pyhrf.jde.samplerbase.GibbsSamplerVariable- #TODO : comment - 
PR_MEAN= 0.001¶
 - 
PR_VAR= 10.0¶
 - 
VAL_INI= 0.05¶
 - 
checkAndSetInitValue(variables)¶
 - 
getOutputs()¶
 - 
linkToData(dataInput)¶
 - 
sampleNextInternal(variables)¶
 
- 
- 
class pyhrf.jde.jde_multi_sujets_alpha.Variance_GaussianNRL_Multi_Subj(val_ini=array([ 1.]), do_sampling=True, use_true_value=False)¶
- Bases: - pyhrf.xmlio.Initable,- pyhrf.jde.samplerbase.GibbsSamplerVariable- 
checkAndSetInitValue(variables)¶
 - 
linkToData(dataInput)¶
 - 
sampleNextInternal(variables)¶
 
- 
- 
pyhrf.jde.jde_multi_sujets_alpha.b()¶
- 
pyhrf.jde.jde_multi_sujets_alpha.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 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. 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  , use: , 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.jde_multi_sujets_alpha.sampleHRF_single_hrf(stLambdaS, stLambdaY, varR, rh, nbColX, nbVox, hgroup, reg)¶
- 
pyhrf.jde.jde_multi_sujets_alpha.sampleHRF_single_hrf_hack(stLambdaS, stLambdaY, varR, rh, nbColX, nbVox, hgroup)¶
- 
pyhrf.jde.jde_multi_sujets_alpha.sampleHRF_voxelwise_iid(stLambdaS, stLambdaY, varR, rh, nbColX, nbVox, hgroup, only_hrf_subj, reg, nbsubj)¶
- 
pyhrf.jde.jde_multi_sujets_alpha.simulate_single_subject(output_dir, cdefs, var_subject_hrf, labels, labels_vol, v_noise, drift_coeff_var, drift_amplitude, hrf_group_level, alpha_var, dt=0.6, dsf=4)¶
- 
pyhrf.jde.jde_multi_sujets_alpha.simulate_subjects(output_dir, snr_scenario='high_snr', spatial_size='tiny', hrf_group=array([ 0. , 0.00078678, 0.01381744, 0.0575847 , 0.13317542, 0.22304737, 0.30459629, 0.36130416, 0.38656651, 0.38221983, 0.35502768, 0.3133342 , 0.26480303, 0.21531699, 0.16874149, 0.12718515, 0.09146061, 0.06155495, 0.03701372, 0.01720819, 0.00149434, -0.01071142, -0.01991078, -0.02653129, -0.03094522, -0.03348818, -0.03447231, -0.03419243, -0.0329265 , -0.03093224, -0.02844234, -0.02565985, -0.02275507, -0.01986438, -0.01709107, -0.0145079 , -0.01216086, -0.01007359, -0.00825211, -0.00668921, -0.00536856, -0.00426813, 0. ]), nbSubj=10, vars_hrfs=[0.0006, 0.0004, 9e-05, 2e-05, 1.5e-05, 2e-05, 0.0001, 3e-05, 7.5e-05, 3.2e-05], vars_noise=[0.2, 0.5, 0.4, 0.8, 0.6, 2.1, 2.5, 3.1, 2.75, 7.3], alpha_var=0.6)¶
- Simulate data for multiple subjects (5 subjects by default) 
 
    
   
