| Title: | Estimate Brain Networks and Connectivity with Population-Derived Priors |
|---|---|
| Description: | Implements Bayesian brain mapping with population-derived priors, including the original model described in Mejia et al. (2020) <doi:10.1080/01621459.2019.1679638>, the model with spatial priors described in Mejia et al. (2022) <doi:10.1080/10618600.2022.2104289>, and the model with population-derived priors on functional connectivity described in Mejia et al. (2025) <doi:10.1093/biostatistics/kxaf022>. Population-derived priors are based on templates representing established brain network maps, for example derived from independent component analysis (ICA), parcellations, or other methods. Model estimation is based on expectation-maximization or variational Bayes algorithms. Includes direct support for 'CIFTI', 'GIFTI', and 'NIFTI' neuroimaging file formats. |
| Authors: | Amanda Mejia [aut, cre], Damon Pham [aut] (ORCID: <https://orcid.org/0000-0001-7563-4727>), Nohelia Da Silva [ctb] |
| Maintainer: | Amanda Mejia <[email protected]> |
| License: | GPL-3 |
| Version: | 0.2.0 |
| Built: | 2026-05-07 08:57:39 UTC |
| Source: | https://github.com/mandymejia/bayesbrainmap |
Bdiag m2
bdiag_m2(mat, N)bdiag_m2(mat, N)
mat |
a k x k 'matrix' |
N |
how many times to repeat |
a sparse (Nk x Nk) matrix of class "dgCMatrix".
Cholesky-based FC sampling
Chol_samp_fun(Chol_vals, p, M, chol_diag, chol_offdiag, Chol_mat_blank)Chol_samp_fun(Chol_vals, p, M, chol_diag, chol_offdiag, Chol_mat_blank)
Chol_vals |
Matrix of Cholesky factorizations (upper triangular values) for all prior sessions (nN*nM x nChol) |
p |
Pivot/reordering applied to FC matrices prior to Cholesky factorization |
M |
Number of samples to draw |
chol_diag |
Indices of diagonal upper triangular elements |
chol_offdiag |
Indices of off-diagonal upper triangular elements |
Chol_mat_blank |
A nLxnL matrix indexing the upper triangular elements |
EM Algorithms for Bayesian brain maps
EM_BBM.spatial( prior_mean, prior_var, meshes, BOLD, theta0, C_diag, H, Hinv, maxiter = 100, usePar = FALSE, epsilon = 0.001, reduce_dim = TRUE, verbose = FALSE ) EM_BBM.independent( prior_mean, prior_var, BOLD, theta0, C_diag, H, Hinv, maxiter = 100, epsilon = 0.001, reduce_dim = FALSE, usePar = FALSE, verbose )EM_BBM.spatial( prior_mean, prior_var, meshes, BOLD, theta0, C_diag, H, Hinv, maxiter = 100, usePar = FALSE, epsilon = 0.001, reduce_dim = TRUE, verbose = FALSE ) EM_BBM.independent( prior_mean, prior_var, BOLD, theta0, C_diag, H, Hinv, maxiter = 100, epsilon = 0.001, reduce_dim = FALSE, usePar = FALSE, verbose )
prior_mean |
( |
prior_var |
( |
meshes |
|
BOLD |
( |
theta0 |
(list) initial guess at parameter values: A ( |
C_diag |
( |
H, Hinv
|
For dimension reduction
of the spatial Bayesian brain map model, which assumes that all networks
have the same smoothness parameter, |
maxiter |
Maximum number of EM iterations. Default: 100. |
usePar |
Parallelize the computation? Default: |
epsilon |
Smallest proportion change between iterations. Default: 0.001. |
reduce_dim |
Reduce the temporal dimension of the data using PCA?
Default: |
verbose |
If |
EM_BBM.spatial implements the expectation-maximization
(EM) algorithm described in Mejia et al. (2019+) for estimating the
subject-level networks and unknown parameters in the Bayesian brain map
model with spatial priors on subject effects.
In both models, if original fMRI timeseries has covariance
, the prewhitened timeseries achieved by premultiplying
by () matrix from PCA has diagonal covariance
, so C_diag is .
A list: theta (list of final parameter estimates), subjNet_mean
(estimates of subject-level networks), subjNet_var (variance of subject-level networks,
for non-spatial model) or subjNet_cov (covariance matrix of subject-level networks,
for spatial model – note that only diagonal and values for neighbors are
computed), and success (flag indicating convergence (TRUE) or not
(FALSE))
Deprecated: This function is deprecated. Use id_engagements instead.
engagements(...)engagements(...)
... |
See |
Universally estimate IW dof parameter nu based on method of moments, so that no empirical variance is under-estimated
estimate_nu(var_FC, mean_FC)estimate_nu(var_FC, mean_FC)
var_FC |
Empirical between-subject variance of covariance matrices (QxQ) |
mean_FC |
Empirical mean of covariance matrices (QxQ) |
estimate for nu
Estimate IW dof parameter nu based on method of moments
estimate_nu_matrix(var_FC, mean_FC)estimate_nu_matrix(var_FC, mean_FC)
var_FC |
Empirical between-subject variance of covariance matrices (QxQ) |
mean_FC |
Empirical mean of covariance matrices (QxQ) |
QxQ matrix of estimates for nu
Estimate prior for Bayesian brain mapping based on fMRI data
estimate_prior( BOLD, BOLD2 = NULL, template, mask = NULL, inds = NULL, scale = c("local", "global", "none"), scale_sm_surfL = NULL, scale_sm_surfR = NULL, scale_sm_FWHM = 2, nuisance = NULL, scrub = NULL, drop_first = 0, hpf = 0, TR = NULL, GSR = FALSE, Q2 = 0, Q2_max = NULL, covariates = NULL, brainstructures = "all", resamp_res = NULL, keep_S = FALSE, keep_FC = FALSE, FC = TRUE, FC_nPivots = 100, FC_nSamp = 50000, FC_updateA = FALSE, varTol = 1e-06, maskTol = 0.1, missingTol = 0.1, usePar = FALSE, wb_path = NULL, verbose = TRUE ) estimate_prior.cifti( BOLD, BOLD2 = NULL, template, inds = NULL, scale = c("local", "global", "none"), scale_sm_surfL = NULL, scale_sm_surfR = NULL, scale_sm_FWHM = 2, nuisance = NULL, scrub = NULL, drop_first = 0, hpf = 0, TR = NULL, GSR = FALSE, Q2 = 0, Q2_max = NULL, brainstructures = "all", resamp_res = resamp_res, keep_S = FALSE, keep_FC = FALSE, FC = TRUE, varTol = 1e-06, maskTol = 0.1, missingTol = 0.1, usePar = FALSE, wb_path = NULL, verbose = TRUE ) estimate_prior.gifti( BOLD, BOLD2 = NULL, template, inds = NULL, scale = c("local", "global", "none"), scale_sm_surfL = NULL, scale_sm_surfR = NULL, scale_sm_FWHM = 2, nuisance = NULL, scrub = NULL, drop_first = 0, hpf = 0, TR = NULL, GSR = FALSE, Q2 = 0, Q2_max = NULL, brainstructures = "all", keep_S = FALSE, keep_FC = FALSE, FC = TRUE, varTol = 1e-06, maskTol = 0.1, missingTol = 0.1, usePar = FALSE, wb_path = NULL, verbose = TRUE ) estimate_prior.nifti( BOLD, BOLD2 = NULL, template, inds = NULL, scale = c("local", "global", "none"), nuisance = NULL, scrub = NULL, drop_first = 0, hpf = 0, TR = NULL, GSR = FALSE, Q2 = 0, Q2_max = NULL, mask = NULL, keep_S = FALSE, keep_FC = FALSE, FC = TRUE, varTol = 1e-06, maskTol = 0.1, missingTol = 0.1, usePar = FALSE, wb_path = NULL, verbose = TRUE )estimate_prior( BOLD, BOLD2 = NULL, template, mask = NULL, inds = NULL, scale = c("local", "global", "none"), scale_sm_surfL = NULL, scale_sm_surfR = NULL, scale_sm_FWHM = 2, nuisance = NULL, scrub = NULL, drop_first = 0, hpf = 0, TR = NULL, GSR = FALSE, Q2 = 0, Q2_max = NULL, covariates = NULL, brainstructures = "all", resamp_res = NULL, keep_S = FALSE, keep_FC = FALSE, FC = TRUE, FC_nPivots = 100, FC_nSamp = 50000, FC_updateA = FALSE, varTol = 1e-06, maskTol = 0.1, missingTol = 0.1, usePar = FALSE, wb_path = NULL, verbose = TRUE ) estimate_prior.cifti( BOLD, BOLD2 = NULL, template, inds = NULL, scale = c("local", "global", "none"), scale_sm_surfL = NULL, scale_sm_surfR = NULL, scale_sm_FWHM = 2, nuisance = NULL, scrub = NULL, drop_first = 0, hpf = 0, TR = NULL, GSR = FALSE, Q2 = 0, Q2_max = NULL, brainstructures = "all", resamp_res = resamp_res, keep_S = FALSE, keep_FC = FALSE, FC = TRUE, varTol = 1e-06, maskTol = 0.1, missingTol = 0.1, usePar = FALSE, wb_path = NULL, verbose = TRUE ) estimate_prior.gifti( BOLD, BOLD2 = NULL, template, inds = NULL, scale = c("local", "global", "none"), scale_sm_surfL = NULL, scale_sm_surfR = NULL, scale_sm_FWHM = 2, nuisance = NULL, scrub = NULL, drop_first = 0, hpf = 0, TR = NULL, GSR = FALSE, Q2 = 0, Q2_max = NULL, brainstructures = "all", keep_S = FALSE, keep_FC = FALSE, FC = TRUE, varTol = 1e-06, maskTol = 0.1, missingTol = 0.1, usePar = FALSE, wb_path = NULL, verbose = TRUE ) estimate_prior.nifti( BOLD, BOLD2 = NULL, template, inds = NULL, scale = c("local", "global", "none"), nuisance = NULL, scrub = NULL, drop_first = 0, hpf = 0, TR = NULL, GSR = FALSE, Q2 = 0, Q2_max = NULL, mask = NULL, keep_S = FALSE, keep_FC = FALSE, FC = TRUE, varTol = 1e-06, maskTol = 0.1, missingTol = 0.1, usePar = FALSE, wb_path = NULL, verbose = TRUE )
BOLD, BOLD2
|
Vector of subject-level fMRI data in one of the following
formats: CIFTI file paths, If |
template |
Group-level template: either a group ICA (GICA), or a parcellation. A GICA should be provided as a format compatible with A parcellation must be in CIFTI format for use with CIFTI BOLD data (other formats to be implemented in the future). The parcellation should have the same locations as the BOLD and one column, with integer values indicating the parcel to which each location belongs to. Each parcel is modeled as a brain map; instead of the first step of dual regression, the medial timecourse of each parcel is used. |
mask |
Required if |
inds |
Numeric indices of the networks in If |
scale |
|
scale_sm_surfL, scale_sm_surfR, scale_sm_FWHM
|
Only applies if
If If To create a |
nuisance |
(Optional) Nuisance matrices to regress from the BOLD data.
Should be a list of matrices, with time along the rows and nuisance signals
along the columns, where each entry corresponds to a Nuisance regression is performed in a simultaneous regression with any spike
regressors from Note that the nuisance matrices should be provided with timepoints matching
the original |
scrub |
(Optional) Numeric vectors of integers giving the indices
of volumes to scrub from the BOLD data. (List the volumes to remove, not the
ones to keep.) Should be a list of such vectors, where each entry
corresponds to a Scrubbing is performed within a nuisance regression by adding a spike regressor to the nuisance design matrix for each volume to scrub. Note that indices are counted beginning with the first index in the
|
drop_first |
(Optional) Number of volumes to drop from the start of each
BOLD session. Default: |
hpf |
The frequency at which to apply a highpass filter to the data
during pre-processing, in Hertz. Default: Note the |
TR |
The temporal resolution of the data, i.e. the time between volumes,
in seconds. |
GSR |
Center BOLD across columns (each image)? This
is equivalent to performing global signal regression. Default:
|
Q2, Q2_max
|
Obtain dual regression estimates after denoising? Denoising is based on modeling and removing nuisance ICs. It may result in a cleaner estimate for smaller datasets, but it may be unnecessary (and time-consuming) for larger datasets. Set If |
covariates |
Subjects by variables numeric matrix of covariates to take
into account for model estimation. Column names should give the name of each
variable. Default: |
brainstructures |
Only applies if the entries of |
resamp_res |
Only applies if the entries of |
keep_S |
Keep the DR estimates of S? If |
keep_FC |
Keep the DR estimates of the FC cor(A)? If |
FC |
Include the functional connectivity prior? Default: |
FC_nPivots |
Number of pivots to use in Cholesky-based FC prior estimation. Set to zero to skip Cholesky-based FC prior estimation. Default: 100. |
FC_nSamp |
Number of FC matrix samples to generate across all pivots. This should be a multiple of FC_nPivots. |
FC_updateA |
Update the timecourses before computing FC? Default:
|
varTol |
Tolerance for variance of each data location. For each scan,
locations which do not meet this threshold are masked out of the analysis.
Default: |
maskTol |
For computing the dual regression results for each subject:
tolerance for number of locations masked out due to low
variance or missing values. If more than this many locations are masked out,
a subject is skipped without calculating dual regression. If |
missingTol |
For computing the variance decomposition across all subjects:
tolerance for number of subjects masked out due to low variance or missing
values at a given location. If more than this many subjects are masked out,
the location's value will be |
usePar, wb_path
|
Parallelize the DR computations over subjects? Default:
|
verbose |
Display progress updates? Default: |
All fMRI data (entries in BOLD and BOLD2, and template) must
be in the same spatial resolution.
A list: the prior and var_decomp with entries in
matrix format; the mask of locations without prior values due to
too many low variance or missing values; the function params such as
the type of scaling and detrending performed; the dat_struct which can be
used to convert prior and var_decomp to "xifti" or
"nifti" objects if the BOLD format was CIFTI or NIFTI data;
and DR results if isTRUE(keep_S) and/or isTRUE(keep_FC).
Use summary to print a description of the prior results, and
for CIFTI-format data use plot to plot the prior mean and variance
estimates. Use export_prior to save the priors to
individual RDS, CIFTI, or NIFTI files (depending on the BOLD format).
nT <- 21 nV <- 140 nQ <- 6 mU <- matrix(rnorm(nV*nQ), nrow=nV) mS <- mU %*% diag(seq(nQ, 1)) %*% matrix(rnorm(nQ*nT), nrow=nQ) BOLD <- list(B1=mS, B2=mS, B3=mS) BOLD <- lapply(BOLD, function(x){x + rnorm(nV*nT, sd=.05)}) template <- mU estimate_prior(BOLD=BOLD, template=mU, FC_nSamp=2000, usePar=FALSE) ## Not run: estimate_prior( run1_cifti_fnames, run2_cifti_fnames, gICA_cifti_fname, brainstructures="all", scale="global", TR=0.71, Q2=NULL, varTol=10, usePar=FALSE ) ## End(Not run)nT <- 21 nV <- 140 nQ <- 6 mU <- matrix(rnorm(nV*nQ), nrow=nV) mS <- mU %*% diag(seq(nQ, 1)) %*% matrix(rnorm(nQ*nT), nrow=nQ) BOLD <- list(B1=mS, B2=mS, B3=mS) BOLD <- lapply(BOLD, function(x){x + rnorm(nV*nT, sd=.05)}) template <- mU estimate_prior(BOLD=BOLD, template=mU, FC_nSamp=2000, usePar=FALSE) ## Not run: estimate_prior( run1_cifti_fnames, run2_cifti_fnames, gICA_cifti_fname, brainstructures="all", scale="global", TR=0.71, Q2=NULL, varTol=10, usePar=FALSE ) ## End(Not run)
Estimation of effective sample size
estimate.ESS(mesh, Y, ind = NULL, trace = FALSE)estimate.ESS(mesh, Y, ind = NULL, trace = FALSE)
mesh |
INLA mesh |
Y |
data |
ind |
index of the data locations in the mesh |
trace |
If |
The functions computes the effective sample size as
as in Bretherton et al. (1999), Journal of Climate.
Estimate of the effective sample size
Export the priors (mean, variance, and FC) as separate files for
visualization or processing outside of BayesBrainMap.
export_prior(x, out_fname = NULL, var_method = c("non-negative", "unbiased"))export_prior(x, out_fname = NULL, var_method = c("non-negative", "unbiased"))
x |
The result of |
out_fname |
Use |
var_method |
|
If is.null(out_fname), the priors in data matrix,
"xifti", or "nifti" format, to match the format of the
original BOLD data. Otherwise, the paths to the new files specified by
out_fname. If prior includes functional connectivity components,
the FC prior and its mean and variance will be included.
## Not run: tm <- estimate_prior(cii1_fnames, cii2_fnames, gICA_fname, usePar=FALSE) export_prior(tm, out_fname="my_prior", var_method="unbiased") ## End(Not run)## Not run: tm <- estimate_prior(cii1_fnames, cii2_fnames, gICA_fname, usePar=FALSE) export_prior(tm, out_fname="my_prior", var_method="unbiased") ## End(Not run)
Fit Bayesian brain mapping model using variational Bayes (VB) or expectation-maximization (EM).
fit_BBM( BOLD, prior, var_method = c("non-negative", "unbiased"), scale = c("prior", "global", "local", "none"), scale_sm_surfL = NULL, scale_sm_surfR = NULL, scale_sm_FWHM = "prior", nuisance = NULL, scrub = NULL, drop_first = 0, hpf = "prior", TR = NULL, GSR = "prior", Q2 = "prior", Q2_max = "prior", covariates = NULL, brainstructures = "prior", mask = NULL, varTol = "prior", spatial_model = NULL, resamp_res = NULL, rm_mwall = TRUE, reduce_dim = FALSE, method_FC = c("VB1", "VB2", "none"), maxiter = 100, miniter = 3, epsilon = 0.001, kappa_init = 0.2, usePar = TRUE, PW = FALSE, seed = 1234, verbose = TRUE )fit_BBM( BOLD, prior, var_method = c("non-negative", "unbiased"), scale = c("prior", "global", "local", "none"), scale_sm_surfL = NULL, scale_sm_surfR = NULL, scale_sm_FWHM = "prior", nuisance = NULL, scrub = NULL, drop_first = 0, hpf = "prior", TR = NULL, GSR = "prior", Q2 = "prior", Q2_max = "prior", covariates = NULL, brainstructures = "prior", mask = NULL, varTol = "prior", spatial_model = NULL, resamp_res = NULL, rm_mwall = TRUE, reduce_dim = FALSE, method_FC = c("VB1", "VB2", "none"), maxiter = 100, miniter = 3, epsilon = 0.001, kappa_init = 0.2, usePar = TRUE, PW = FALSE, seed = 1234, verbose = TRUE )
BOLD |
Vector of subject-level fMRI data in one of the following
formats: CIFTI file paths, If multiple BOLD data are provided, they will be independently centered, scaled, detrended (if applicable), and denoised (if applicable). Then they will be concatenated together followed by computing the initial dual regression estimate. |
prior |
Prior estimates in a format compatible with |
var_method |
Which calculation of the prior variance to use:
|
scale |
|
scale_sm_surfL, scale_sm_surfR, scale_sm_FWHM
|
Only applies if
If If To create a |
nuisance |
(Optional) Signals to regress from the data, given as a
numeric matrix with the same number of rows as there are volumes in the
|
scrub |
(Optional) A numeric vector of integers giving the indices
of volumes to scrub from the BOLD data. (List the volumes to remove, not the
ones to keep.) If multiple |
drop_first |
(Optional) Number of volumes to drop from the start of each
BOLD session. Default: |
TR, hpf
|
These arguments control detrending. Be sure to set the correct Note that if multiple |
GSR |
Center BOLD across columns (each image)? This
is equivalent to performing global signal regression. Default:
|
Q2, Q2_max
|
Denoise the BOLD data? Denoising is based on modeling and removing nuisance ICs. It may result in a cleaner estimate for smaller datasets, but it may be unnecessary (and time-consuming) for larger datasets. Set If The defaults for both arguments is |
covariates |
Numeric vector of covariates to take into account for model
estimation. Names should give the name of each variable. The covariates must
match those of the prior. Default: |
brainstructures |
Only applies if the entries of |
mask |
Required only if the entries of |
varTol |
Tolerance for variance of each data location. For each scan,
locations which do not meet this threshold are masked out of the analysis.
Default: |
spatial_model |
Should spatial modeling be performed? If If If If |
resamp_res |
Only applies if |
rm_mwall |
Only applies if |
reduce_dim |
Reduce the temporal dimension of the data using PCA?
Default: |
method_FC |
Variational Bayes (VB) method for FC prior ICA model:
|
maxiter |
Maximum number of EM or VB iterations. Default: |
miniter |
Minimum number of EM or VB iterations. Default: |
epsilon |
Smallest proportion change between iterations. Default:
|
kappa_init |
Starting value for kappa. Default: |
usePar |
Parallelize the computation? Default: |
PW |
Prewhiten to account for residual autocorrelation? Default: |
seed |
(Only applicable for FC calculation and if |
verbose |
If |
A (spatial) prior ICA object, which is a list containing:
subjNet_mean, the estimated independent components
S; subjNet_se, the standard errors of S; the
mask of locations without prior values due to too many low
variance or missing values; the nuisance design matrix or matrices if
applicable; and the function params such as the type of scaling and
detrending performed.
If BOLD represented CIFTI or NIFTI data, subjNet_mean and
subjNet_se will be formatted as "xifti" or "nifti"
objects, respectively.
## Not run: tm <- estimate_prior(cii1_fnames, cii2_fnames, gICA_fname, usePar=FALSE) fit_BBM(newcii_fname, tm, spatial_model=TRUE, resamp_res=2000, usePar=FALSE) ## End(Not run)## Not run: tm <- estimate_prior(cii1_fnames, cii2_fnames, gICA_fname, usePar=FALSE) fit_BBM(newcii_fname, tm, spatial_model=TRUE, resamp_res=2000, usePar=FALSE) ## End(Not run)
Identify areas of engagement in each network from the result of (spatial) Bayesian brain mapping.
id_engagements( bMap, u = NULL, z = 2, alpha = 0.01, type = c(">", "abs >", "<", "!="), method_p = c("BH", "bonferroni"), verbose = FALSE, which.nets = NULL, deviation = FALSE )id_engagements( bMap, u = NULL, z = 2, alpha = 0.01, type = c(">", "abs >", "<", "!="), method_p = c("BH", "bonferroni"), verbose = FALSE, which.nets = NULL, deviation = FALSE )
bMap |
Fitted (spatial) Bayesian brain map from |
u, z
|
Set a threshold value for engagement? A threshold value can be
specified directly with |
alpha |
Significance level for hypothesis testing. Default: |
type |
Type of region: |
method_p |
If the input is a |
verbose |
If |
which.nets |
Indices of networks for which to identify engagements. If
|
deviation |
If |
A list containing engagement maps for each network, the joint and marginal PPMs for each network, masks of regions meeting the threshold(s) if provided, and the parameters used for computing engagement. If the input represented CIFTI- or NIFTI-format data, then the engagements maps will be formatted accordingly.
Use summary to obtain information about the engagements results.
For CIFTI-format engagements, use plot to visualize the engagement
maps.
## Not run: id_engagements(fit_BBM_result, alpha=.05, deviation=TRUE) ## End(Not run)## Not run: id_engagements(fit_BBM_result, alpha=.05, deviation=TRUE) ## End(Not run)
Compute theoretical Inverse-Wishart variance of covariance matrix elements
IW_var(nu, p, xbar_ij, xbar_ii, xbar_jj)IW_var(nu, p, xbar_ij, xbar_ii, xbar_jj)
nu |
Inverse Wishart degrees of freedom parameter |
p |
Matrix dimension for IW distribution |
xbar_ij |
Empirical mean of covariance matrices at element (i,j) |
xbar_ii |
Empirical mean of covariance matrices at the ith diagonal element |
xbar_jj |
Empirical mean of covariance matrices at the jth diagonal element |
Theoretical IW variance for covariance element (i,j)
Compute theoretical Inverse-Wishart variance of correlation matrix elements
IW_var_cor(nu, p, xbar_ij)IW_var_cor(nu, p, xbar_ij)
nu |
Inverse Wishart degrees of freedom parameter |
p |
Matrix dimension for IW distribution |
xbar_ij |
Empirical mean of covariance matrices at element (i,j) |
Theoretical IW variance for correlation element (i,j)
Compute likelihood in SPDE model for ESS estimation
lik(theta, Y, G, C, ind = NULL)lik(theta, Y, G, C, ind = NULL)
theta |
Value of hyperparameters |
Y |
Data vector |
G |
SPDE G matrix |
C |
SPDE C matrix |
ind |
Indices of data locations in the mesh |
Log likelihood value
Plot engagements
## S3 method for class 'bMap_eng.cifti' plot( x, stat = c("engaged", "pvals", "pvals_adj", "tstats", "se", "thresholded"), test_level = NULL, ... )## S3 method for class 'bMap_eng.cifti' plot( x, stat = c("engaged", "pvals", "pvals_adj", "tstats", "se", "thresholded"), test_level = NULL, ... )
x |
The engagements from |
stat |
|
test_level |
If |
... |
Additional arguments to |
The engagements plot
Plot fit_BBM estiamte
## S3 method for class 'bMap.cifti' plot(x, what = c("maps", "FC"), stat = c("mean", "se"), ...)## S3 method for class 'bMap.cifti' plot(x, what = c("maps", "FC"), stat = c("mean", "se"), ...)
x |
The result of |
what |
The If |
stat |
|
... |
Additional arguments to |
The plot
This feature is not supported yet.
## S3 method for class 'bMap.matrix' plot(x, ...)## S3 method for class 'bMap.matrix' plot(x, ...)
x |
The result of |
... |
Additional arguments |
Nothing, because an error is raised.
Plot prior
## S3 method for class 'bMap.nifti' plot( x, stat = c("mean", "se"), plane = c("axial", "sagittal", "coronal"), n_slices = 9, slices = NULL, ... )## S3 method for class 'bMap.nifti' plot( x, stat = c("mean", "se"), plane = c("axial", "sagittal", "coronal"), n_slices = 9, slices = NULL, ... )
x |
The result of |
stat |
|
plane, n_slices, slices
|
Anatomical plane and which slice indices to show. Default: 9 axial slices. |
... |
Additional arguments |
The plot
Plot prior
## S3 method for class 'prior.cifti' plot( x, what = c("maps", "FC"), stat = c("mean", "sd", "var"), var_method = c("non-negative", "unbiased"), FC_method = c("empirical", "IW", "Chol", "none"), ... )## S3 method for class 'prior.cifti' plot( x, what = c("maps", "FC"), stat = c("mean", "sd", "var"), var_method = c("non-negative", "unbiased"), FC_method = c("empirical", "IW", "Chol", "none"), ... )
x |
The prior from |
what |
The If |
stat |
Which prior statistic to plot: the |
var_method |
|
FC_method |
If |
... |
Additional arguments to |
The plot
Plot prior
## S3 method for class 'prior.gifti' plot( x, what = c("maps", "FC"), stat = c("mean", "sd", "var"), var_method = c("non-negative", "unbiased"), FC_method = c("empirical", "IW", "Chol", "none"), ... )## S3 method for class 'prior.gifti' plot( x, what = c("maps", "FC"), stat = c("mean", "sd", "var"), var_method = c("non-negative", "unbiased"), FC_method = c("empirical", "IW", "Chol", "none"), ... )
x |
The prior from |
what |
The If |
stat |
Which prior statistic to plot: the |
var_method |
|
FC_method |
If |
... |
Additional arguments to |
The plot
Plot prior
## S3 method for class 'prior.matrix' plot(x, ...)## S3 method for class 'prior.matrix' plot(x, ...)
x |
The prior from |
... |
Additional arguments |
The plot
Based on oro.nifti::image.
## S3 method for class 'prior.nifti' plot( x, what = c("maps", "FC"), stat = c("mean", "sd", "var"), FC_method = c("empirical", "IW", "Chol", "none"), var_method = c("non-negative", "unbiased"), plane = c("axial", "sagittal", "coronal"), n_slices = 9, slices = NULL, ... )## S3 method for class 'prior.nifti' plot( x, what = c("maps", "FC"), stat = c("mean", "sd", "var"), FC_method = c("empirical", "IW", "Chol", "none"), var_method = c("non-negative", "unbiased"), plane = c("axial", "sagittal", "coronal"), n_slices = 9, slices = NULL, ... )
x |
The prior from |
what |
The If |
stat |
Which prior statistic to plot: the |
FC_method |
If |
var_method |
|
plane, n_slices, slices
|
Anatomical plane and which slice indices to show. Default: 9 axial slices. |
... |
Additional arguments to |
Consider using struct_prior to obtain the 3D volumes to plot with a different
viewer function (e.g. from oro.nifti) if desired.
The plot
Estimate residual autocorrelation for prewhitening
pw_estimate(A, ar_order, aic = FALSE)pw_estimate(A, ar_order, aic = FALSE)
A |
Estimated A matrix (T x Q) |
ar_order, aic
|
Order of the AR model used to prewhiten the data at each location.
If |
Estimated AR coefficients and residual variance at every vertex
"bMap_eng.cifti" objectSummary method for class "bMap_eng.cifti"
## S3 method for class 'bMap_eng.cifti' summary(object, ...) ## S3 method for class 'summary.bMap_eng.cifti' print(x, ...) ## S3 method for class 'bMap_eng.cifti' print(x, ...)## S3 method for class 'bMap_eng.cifti' summary(object, ...) ## S3 method for class 'summary.bMap_eng.cifti' print(x, ...) ## S3 method for class 'bMap_eng.cifti' print(x, ...)
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The engagements from |
A list summarizing the data and results for the engagements analysis.
Nothing, invisibly.
Nothing, invisibly.
"bMap_eng.matrix" objectSummary method for class "bMap_eng.matrix"
## S3 method for class 'bMap_eng.matrix' summary(object, ...) ## S3 method for class 'summary.bMap_eng.matrix' print(x, ...) ## S3 method for class 'bMap_eng.matrix' print(x, ...)## S3 method for class 'bMap_eng.matrix' summary(object, ...) ## S3 method for class 'summary.bMap_eng.matrix' print(x, ...) ## S3 method for class 'bMap_eng.matrix' print(x, ...)
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The engagements from |
A list summarizing the data and results for the engagements analysis.
Nothing, invisibly.
Nothing, invisibly.
"bMap_eng.nifti" objectSummary method for class "bMap_eng.nifti"
## S3 method for class 'bMap_eng.nifti' summary(object, ...) ## S3 method for class 'summary.bMap_eng.nifti' print(x, ...) ## S3 method for class 'bMap_eng.nifti' print(x, ...)## S3 method for class 'bMap_eng.nifti' summary(object, ...) ## S3 method for class 'summary.bMap_eng.nifti' print(x, ...) ## S3 method for class 'bMap_eng.nifti' print(x, ...)
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The engagements from |
A list summarizing the data and results for the engagements analysis.
Nothing, invisibly.
Nothing, invisibly.
"bMap.cifti" objectSummary method for class "bMap.cifti"
## S3 method for class 'bMap.cifti' summary(object, ...) ## S3 method for class 'summary.bMap.cifti' print(x, ...) ## S3 method for class 'bMap.cifti' print(x, ...)## S3 method for class 'bMap.cifti' summary(object, ...) ## S3 method for class 'summary.bMap.cifti' print(x, ...) ## S3 method for class 'bMap.cifti' print(x, ...)
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The result of |
A list summarizing of the results of the BrainMap analysis.
Nothing, invisibly.
Nothing, invisibly.
"bMap.matrix" objectSummary method for class "bMap.matrix"
## S3 method for class 'bMap.matrix' summary(object, ...) ## S3 method for class 'summary.bMap.matrix' print(x, ...) ## S3 method for class 'bMap.matrix' print(x, ...)## S3 method for class 'bMap.matrix' summary(object, ...) ## S3 method for class 'summary.bMap.matrix' print(x, ...) ## S3 method for class 'bMap.matrix' print(x, ...)
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The prior from |
A list summarizing of the results of the BrainMap analysis.
Nothing, invisibly.
Nothing, invisibly.
"bMap.nifti" objectSummary method for class "bMap.nifti"
## S3 method for class 'bMap.nifti' summary(object, ...) ## S3 method for class 'summary.bMap.nifti' print(x, ...) ## S3 method for class 'bMap.nifti' print(x, ...)## S3 method for class 'bMap.nifti' summary(object, ...) ## S3 method for class 'summary.bMap.nifti' print(x, ...) ## S3 method for class 'bMap.nifti' print(x, ...)
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The prior from |
A list summarizing of the results of the BrainMap analysis.
Nothing, invisibly.
Nothing, invisibly.
"prior.cifti" objectSummary method for class "prior.cifti"
## S3 method for class 'prior.cifti' summary(object, ...) ## S3 method for class 'summary.prior.cifti' print(x, ...) ## S3 method for class 'prior.cifti' print(x, ...)## S3 method for class 'prior.cifti' summary(object, ...) ## S3 method for class 'summary.prior.cifti' print(x, ...) ## S3 method for class 'prior.cifti' print(x, ...)
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The prior from |
A list summarizing the prior: data dimensions, options used for prior estimation, etc.
Nothing, invisibly.
Nothing, invisibly.
"prior.gifti" objectSummary method for class "prior.gifti"
## S3 method for class 'prior.gifti' summary(object, ...) ## S3 method for class 'summary.prior.gifti' print(x, ...) ## S3 method for class 'prior.gifti' print(x, ...)## S3 method for class 'prior.gifti' summary(object, ...) ## S3 method for class 'summary.prior.gifti' print(x, ...) ## S3 method for class 'prior.gifti' print(x, ...)
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The prior from |
A list summarizing the prior: data dimensions, options used for prior estimation, etc.
Nothing, invisibly.
Nothing, invisibly.
"prior.matrix" objectSummary method for class "prior.matrix"
## S3 method for class 'prior.matrix' summary(object, ...) ## S3 method for class 'summary.prior.matrix' print(x, ...) ## S3 method for class 'prior.matrix' print(x, ...)## S3 method for class 'prior.matrix' summary(object, ...) ## S3 method for class 'summary.prior.matrix' print(x, ...) ## S3 method for class 'prior.matrix' print(x, ...)
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The prior from |
A list summarizing the prior: data dimensions, options used for prior estimation, etc.
Nothing, invisibly.
Nothing, invisibly.
"prior.nifti" objectSummary method for class "prior.nifti"
## S3 method for class 'prior.nifti' summary(object, ...) ## S3 method for class 'summary.prior.nifti' print(x, ...) ## S3 method for class 'prior.nifti' print(x, ...)## S3 method for class 'prior.nifti' summary(object, ...) ## S3 method for class 'summary.prior.nifti' print(x, ...) ## S3 method for class 'prior.nifti' print(x, ...)
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The prior from |
A list summarizing the prior: data dimensions, options used for prior estimation, etc.
Nothing, invisibly.
Nothing, invisibly.
Parameter Estimates in EM Algorithm for Bayesian brain map
UpdateTheta_BBM( prior_mean, prior_var, meshes, BOLD, theta, C_diag, H, Hinv, s0_vec, D, Dinv_s0, verbose = FALSE, return_MAP = FALSE, update = c("all", "kappa", "A") ) UpdateTheta_iBM( prior_mean, prior_var, BOLD, theta, C_diag, H, Hinv, update_nu0sq = TRUE, return_MAP = FALSE, verbose = TRUE )UpdateTheta_BBM( prior_mean, prior_var, meshes, BOLD, theta, C_diag, H, Hinv, s0_vec, D, Dinv_s0, verbose = FALSE, return_MAP = FALSE, update = c("all", "kappa", "A") ) UpdateTheta_iBM( prior_mean, prior_var, BOLD, theta, C_diag, H, Hinv, update_nu0sq = TRUE, return_MAP = FALSE, verbose = TRUE )
prior_mean |
( |
prior_var |
( |
meshes |
|
BOLD |
( |
theta |
(list) current parameter estimates |
C_diag |
|
H, Hinv
|
For dimension reduction |
s0_vec |
Vectorized prior means |
D |
Sparse diagonal matrix of prior standard deviations |
Dinv_s0 |
The inverse of D times s0_vec |
verbose |
If |
return_MAP |
If |
update |
Which parameters to update. Either |
update_nu0sq |
For non-spatial model: updating |
An updated list of parameter estimates, theta, OR if
return_MAP=TRUE, the posterior mean and precision of the latent fields
Compute the error between empirical and theoretical variance of covariance matrix elements
var_sq_err(nu, p, var_ij, xbar_ij, xbar_ii, xbar_jj)var_sq_err(nu, p, var_ij, xbar_ij, xbar_ii, xbar_jj)
nu |
Inverse Wishart degrees of freedom parameter |
p |
Matrix dimension for IW distribution |
var_ij |
Empirical between-subject variance of covariance matrices at element (i,j) |
xbar_ij |
Empirical mean of covariance matrices at element (i,j) |
xbar_ii |
Empirical mean of covariance matrices at the ith diagonal element |
xbar_jj |
Empirical mean of covariance matrices at the jth diagonal element |
Squared difference between the empirical and theoretical IW variance of covariance matrices at element (i,j)
Compute the overall error between empirical and theoretical variance of CORRELATION matrix elements
var_sq_err_constrained(nu, p, var, xbar, M = 10000)var_sq_err_constrained(nu, p, var, xbar, M = 10000)
nu |
Inverse Wishart degrees of freedom parameter |
p |
Matrix dimension for IW distribution |
var |
Empirical between-subject variances of CORRELATION matrix (upper triangle) |
xbar |
Empirical mean of CORRELATION matrix (upper triangle) |
M |
Penalty to assign if theoretical variance is smaller than empirical variance |
Sum of squared difference between the empirical and theoretical IW variance of CORRELATION matrix, but with constraint that theoretical variances must not be smaller than empirical variances