pyhrf.boldsynth.scenarios module¶
-
pyhrf.boldsynth.scenarios.build_ctrl_tag_matrix(asl_shape)¶
-
pyhrf.boldsynth.scenarios.calc_asl_shape(bold_stim_induced, dsf)¶
-
pyhrf.boldsynth.scenarios.createBiGaussCovarNRL(condition_defs, labels, covariance)¶
-
pyhrf.boldsynth.scenarios.create_3Dlabels_Potts(condition_defs, beta, dims, mask)¶
-
pyhrf.boldsynth.scenarios.create_AR_noise(bold_shape, v_noise, order=2, v_corr=0.1)¶
-
pyhrf.boldsynth.scenarios.create_Xh(nrls, rastered_paradigm, hrf, condition_defs, dt, hrf_territories=None)¶ Retrieve the product X.h
-
pyhrf.boldsynth.scenarios.create_alpha_for_hrfgroup(alpha_var)¶ Create alpha from a normal distribution, for one subject
-
pyhrf.boldsynth.scenarios.create_asl_from_stim_induced(bold_stim_induced, perf_stim_induced, ctrl_tag_mat, dsf, perf_baseline, noise, drift=None, outliers=None)¶ Downsample stim_induced signal according to downsampling factor ‘dsf’ and add noise and drift (nuisance signals) which has to be at downsampled temporal resolution.
-
pyhrf.boldsynth.scenarios.create_bigaussian_nrls(labels, mean_act, var_act, var_inact)¶ Simulate bi-Gaussian NRLs (zero-centered inactive component)
-
pyhrf.boldsynth.scenarios.create_bold(stim_induced_signal, dsf, noise, drift=None, outliers=None)¶ a short-cut for function create_bold_from_stim_induced
-
pyhrf.boldsynth.scenarios.create_bold_controlled_variance(stim_induced_signal, alpha, nb_voxels, dsf, nrls, Xh, drift=None, outliers=None)¶ Create BOLD with controlled explained variance alpha: percentage of explained variance on total variance
-
pyhrf.boldsynth.scenarios.create_bold_from_stim_induced(stim_induced_signal, dsf, noise, drift=None, outliers=None)¶ Downsample stim_induced signal according to downsampling factor ‘dsf’ and add noise and drift (nuisance signals) which has to be at downsampled temporal resolution.
-
pyhrf.boldsynth.scenarios.create_bold_from_stim_induced_RealNoise(stim_induced_signal, dsf, noise, drift)¶ Downsample stim_induced signal according to downsampling factor ‘dsf’ and add noise and drift (nuisance signals) which has to be at downsampled temporal resolution.
-
pyhrf.boldsynth.scenarios.create_bold_stim_induced_signal(brls, rastered_paradigm, brf, condition_defs, dt, hrf_territories=None)¶ - Create a stimulus induced signal for ASL from BOLD response levels,
- paradigm and BRF
(sum_{m=1}^M a^m X^m h + sum_{m=1}^M c^m W X^m g) For each condition, compute the convolution of the paradigm binary sequence ‘rastered_paradigm’ with the given BRF and multiply by brls. Finally compute the sum over conditions.
Return a asl array of shape (nb scans, nb voxels)
-
pyhrf.boldsynth.scenarios.create_canonical_hrf(hrf_duration=25.0, dt=0.5)¶
-
pyhrf.boldsynth.scenarios.create_connected_label_clusters(condition_defs, activ_label_graph)¶
-
pyhrf.boldsynth.scenarios.create_drift_coeffs(bold_shape, drift_order, drift_coeff_var)¶
-
pyhrf.boldsynth.scenarios.create_drift_coeffs_asl(asl_shape, drift_order, drift_var)¶
-
pyhrf.boldsynth.scenarios.create_gaussian_hrf_subject(hrf_group, var_subject_hrf, dt, alpha=0.0)¶ Creation of hrf by subject. Use group level hrf and variance for each subject (var_subjects_hrfs must be a list) Simulated hrfs must be smooth enough: correlation between temporal coeffcients
-
pyhrf.boldsynth.scenarios.create_gaussian_noise(bold_shape, v_noise, m_noise=0.0)¶
-
pyhrf.boldsynth.scenarios.create_gaussian_noise_asl(asl_shape, v_gnoise, m_noise=0.0)¶
-
pyhrf.boldsynth.scenarios.create_gaussian_nrls_sessions_and_mean(nrls, condition_defs, labels, var_sess)¶ Creation of nrls by session (and by voxel and cond) - for one session n° sess The nrls by session vary around an nrl mean (nrls_bar) defined by voxel and cond (var_sess corresponds to the variation of session defined nrls around the nrl_bar) Here “nrls” is nrls_bar, mean over subjects!
-
pyhrf.boldsynth.scenarios.create_gsmooth_hrf(hrf_duration=25.0, dt=0.5, order=2, hrf_var=1.0, zc=True, normalize_hrf=True)¶ Create a smooth HRF according to the multivariate gaussian prior used in JDE hrf_duration and dt are the HRF duration and temporal resolution, respectively (in sec.). order is derivative order constraining the covariance matrix. hrf_var is the HRF variance. zc is a flag to impose zeros at the begining and the end of the HRF
return: a np array of HRF coefficients
-
pyhrf.boldsynth.scenarios.create_hrf(picw, pic, under=2, hrf_duration=25.0, dt=0.5)¶
-
pyhrf.boldsynth.scenarios.create_hrf_from_territories(hrf_territories, primary_hrfs)¶
-
pyhrf.boldsynth.scenarios.create_labels_Potts(condition_defs, beta, nb_voxels)¶
-
pyhrf.boldsynth.scenarios.create_labels_vol(condition_defs)¶ Create a seet labels from the field “label_map” in condition_defs Available choices for the field label_map: - ‘random_small’ : binary labels are randomly generated with shape (1,5,5) - a tag (str) : corresponds to a png file in pyhrf data files - a 3D np containing the labels
-
pyhrf.boldsynth.scenarios.create_language_paradigm(condition_defs)¶
-
pyhrf.boldsynth.scenarios.create_localizer_paradigm(condition_defs, paradigm_label='av')¶
-
pyhrf.boldsynth.scenarios.create_localizer_paradigm_a(condition_defs)¶
-
pyhrf.boldsynth.scenarios.create_localizer_paradigm_avd(condition_defs)¶
-
pyhrf.boldsynth.scenarios.create_multisess_stim_induced_signal(nrls_session, rastered_paradigm, hrf, condition_defs, dt, hrf_territories=None)¶ Create a stimulus induced signal from neural response levels, paradigm and HRF (sum_{m=1}^M a^m X^m h) For each condition, compute the convolution of the paradigm binary sequence ‘rastered_paradigm’ with the given HRF and multiply by nrls. Finally compute the sum over conditions.
Return a bold array of shape (nb scans, nb voxels)
-
pyhrf.boldsynth.scenarios.create_multisess_stim_induced_signal_asl(prls_session, rastered_paradigm, prf, condition_defs, dt, hrf_territories=None)¶ Create a stimulus induced signal from neural response levels, paradigm and HRF (sum_{m=1}^M a^m X^m h) For each condition, compute the convolution of the paradigm binary sequence ‘rastered_paradigm’ with the given HRF and multiply by nrls. Finally compute the sum over conditions.
Return a bold array of shape (nb scans, nb voxels)
-
pyhrf.boldsynth.scenarios.create_null_drift(bold_shape)¶
-
pyhrf.boldsynth.scenarios.create_outliers(bold_shape, stim_induced_signal, nb_outliers, outlier_scale=5.0)¶
-
pyhrf.boldsynth.scenarios.create_paradigm_un_evnt(condition_defs)¶
-
pyhrf.boldsynth.scenarios.create_perf_baseline(asl_shape, perf_baseline_var, perf_baseline_mean=0.0)¶
-
pyhrf.boldsynth.scenarios.create_perf_stim_induced_signal(prls, rastered_paradigm, prf, condition_defs, dt, hrf_territories=None)¶ - Create a stimulus induced signal for ASL from perfusion response levels,
- paradigm and PRF
(sum_{m=1}^M c^m X^m g) For each condition, compute the convolution of the paradigm binary sequence ‘rastered_paradigm’ with the given PRF and multiply by prls. Finally compute the sum over conditions.
Return a asl array of shape (nb scans, nb voxels)
-
pyhrf.boldsynth.scenarios.create_polynomial_drift(bold_shape, tr, drift_order, drift_var)¶
-
pyhrf.boldsynth.scenarios.create_polynomial_drift_from_coeffs(bold_shape, tr, drift_order, drift_coeffs, drift_mean=0.0, drift_amplitude=1.0)¶
-
pyhrf.boldsynth.scenarios.create_polynomial_drift_from_coeffs_asl(asl_shape, tr, drift_order, drift_coeffs)¶
-
pyhrf.boldsynth.scenarios.create_prf(prf_duration=25.0, dt=0.5)¶
-
pyhrf.boldsynth.scenarios.create_small_bold_simulation(snr='high', output_dir=None, simu_items=None)¶
-
pyhrf.boldsynth.scenarios.create_stim_induced_signal(nrls, rastered_paradigm, hrf, dt)¶ Create a stimulus induced signal from neural response levels, paradigm and HRF (sum_{m=1}^M a^m X^m h) For each condition, compute the convolution of the paradigm binary sequence ‘rastered_paradigm’ with the given HRF and multiply by nrls. Finally compute the sum over conditions.
Return a bold array of shape (nb scans, nb voxels)
-
pyhrf.boldsynth.scenarios.create_stim_induced_signal_Parsi(nrls, rastered_paradigm, hrf, condition_defs, dt, w)¶ Create a stimulus induced signal from neural response levels, paradigm and HRF (sum_{m=1}^M a^m w^m X^m h) For each condition, compute the convolution of the paradigm binary sequence ‘rastered_paradigm’ with the given HRF and multiply by nrls and W. Finally compute the sum over conditions.
Return a bold array of shape (nb scans, nb voxels)
-
pyhrf.boldsynth.scenarios.create_time_invariant_gaussian_brls(condition_defs, labels)¶ BOLD response levels for ASL
-
pyhrf.boldsynth.scenarios.create_time_invariant_gaussian_nrls(condition_defs, labels)¶
-
pyhrf.boldsynth.scenarios.create_time_invariant_gaussian_prls(condition_defs, labels)¶ Perfusion response levels for ASL
-
pyhrf.boldsynth.scenarios.create_varying_hrf(hrf_duration=25.0, dt=0.5)¶
-
pyhrf.boldsynth.scenarios.duplicate_brf(nb_voxels, primary_brf)¶ Duplicate brf over all voxels. Return an array of shape (nb_voxels, len(brf))
-
pyhrf.boldsynth.scenarios.duplicate_hrf(nb_voxels, primary_hrf)¶ Duplicate hrf over all voxels. Return an array of shape (nb_voxels, len(hrf))
-
pyhrf.boldsynth.scenarios.duplicate_noise_var(nb_voxels, v_gnoise)¶ Duplicate variance of noise over all voxels. Return an array of shape (nb_voxels, var noise)
-
pyhrf.boldsynth.scenarios.duplicate_prf(nb_voxels, primary_prf)¶ Duplicate prf over all voxels. Return an array of shape (nb_voxels, len(prf))
-
pyhrf.boldsynth.scenarios.flatten_labels_vol(labels_vol)¶
-
pyhrf.boldsynth.scenarios.get_bold_shape(stim_induced_signal, dsf)¶
-
pyhrf.boldsynth.scenarios.load_drawn_labels(name)¶
-
pyhrf.boldsynth.scenarios.load_hrf_territories(nb_hrf_territories=0, hrf_territories_name=None)¶
-
pyhrf.boldsynth.scenarios.load_many_hrf_territories(nb_hrf_territories)¶
-
pyhrf.boldsynth.scenarios.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.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:sigma * np.random.randn(...) + muExamples
>>> 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.boldsynth.scenarios.rasterize_paradigm(paradigm, dt, condition_defs)¶ Return binary sequences of onsets approximated on temporal grid of temporal resolution dt, for all conditions. ‘paradigm’ is expected to be an instance of ‘pyhrf.paradigm.mpar.Paradigm’
-
pyhrf.boldsynth.scenarios.save_simulation(simulation, output_dir)¶ short-hand for simulation_save_vol_outputs
-
pyhrf.boldsynth.scenarios.simulation_save_vol_outputs(simulation, output_dir, bold_3D_vols_dir=None, simulation_graph_output=None, prefix=None, vol_meta=None)¶ simulation_graph_output : None, ‘simple’, ‘thumbnails’ #TODO