Type: | Package |
Title: | Estimate Brain Networks and Connectivity with Population-Derived Priors |
Version: | 0.1.3 |
Maintainer: | Amanda Mejia <mandy.mejia@gmail.com> |
Description: | Implements Bayesian brain mapping models, including the prior ICA (independent components analysis) model proposed in Mejia et al. (2020) <doi:10.1080/01621459.2019.1679638> and the spatial prior ICA model proposed in proposed in Mejia et al. (2022) <doi:10.1080/10618600.2022.2104289>. Both models estimate subject-level brain as deviations from known population-level networks, which are estimated using standard ICA algorithms. Both models employ an expectation-maximization algorithm for estimation of the latent brain networks and unknown model parameters. Includes direct support for 'CIFTI', 'GIFTI', and 'NIFTI' neuroimaging file formats. |
Depends: | R (≥ 3.6.0) |
License: | GPL-3 |
Additional_repositories: | https://inla.r-inla-download.org/R/testing |
Encoding: | UTF-8 |
Imports: | abind, fMRItools (≥ 0.5.3), fMRIscrub (≥ 0.14.5), foreach, Matrix, matrixStats, methods, pesel, SQUAREM, stats, utils |
Suggests: | ciftiTools (≥ 0.13.2), excursions, RNifti, oro.nifti, gifti, parallel, doParallel, knitr, rmarkdown, INLA, testthat (≥ 3.0.0) |
RoxygenNote: | 7.3.2 |
URL: | https://github.com/mandymejia/BayesBrainMap |
BugReports: | https://github.com/mandymejia/BayesBrainMap/issues |
NeedsCompilation: | no |
Packaged: | 2025-06-28 21:13:52 UTC; ddpham |
Author: | Amanda Mejia [aut, cre],
Damon Pham |
Repository: | CRAN |
Date/Publication: | 2025-07-04 18:40:02 UTC |
Bayesian brain mapping
Description
Fit Bayesian brain mapping model using variational Bayes (VB) or expectation-maximization (EM).
Usage
BrainMap(
BOLD,
prior,
tvar_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
)
Arguments
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 |
tvar_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. 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 |
Value
A (spatial) prior ICA object, which is a list containing:
subjNet_mean
, the V \times L
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.
Examples
## Not run:
tm <- estimate_prior(cii1_fnames, cii2_fnames, gICA_fname, usePar=FALSE)
BrainMap(newcii_fname, tm, spatial_model=TRUE, resamp_res=2000, usePar=FALSE)
## End(Not run)
Cholesky-based FC sampling
Description
Cholesky-based FC sampling
Usage
Chol_samp_fun(Chol_vals, p, M, chol_diag, chol_offdiag, Chol_mat_blank)
Arguments
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
Description
EM Algorithms for Bayesian brain maps
Usage
EM_BrainMap.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_BrainMap.independent(
prior_mean,
prior_var,
BOLD,
theta0,
C_diag,
H,
Hinv,
maxiter = 100,
epsilon = 0.001,
reduce_dim = FALSE,
usePar = FALSE,
verbose
)
Arguments
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 |
Details
EM_BrainMap.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
\sigma^2 I_T
, the prewhitened timeseries achieved by premultiplying
by (QxT
) matrix H
from PCA has diagonal covariance
\sigma^2HH'
, so C_diag is diag(HH')
.
Value
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
))
GSR
Description
GSR
Arguments
GSR |
Center BOLD across columns (each image)? This
is equivalent to performing global signal regression. Default:
|
Check for INLA
Description
Check for INLA
Usage
INLA_check()
Value
NULL
, invisibly
Compute theoretical Inverse-Wishart variance of covariance matrix elements
Description
Compute theoretical Inverse-Wishart variance of covariance matrix elements
Usage
IW_var(nu, p, xbar_ij, xbar_ii, xbar_jj)
Arguments
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 |
Value
Theoretical IW variance for covariance element (i,j)
Compute theoretical Inverse-Wishart variance of correlation matrix elements
Description
Compute theoretical Inverse-Wishart variance of correlation matrix elements
Usage
IW_var_cor(nu, p, xbar_ij)
Arguments
nu |
Inverse Wishart degrees of freedom parameter |
p |
Matrix dimension for IW distribution |
xbar_ij |
Empirical mean of covariance matrices at element (i,j) |
Value
Theoretical IW variance for correlation element (i,j)
Compute part of kappa log-likelihood
Description
Compute part of log-likelihood involving kappa (or kappa_q) for numerical optimization
Usage
LL2_kappa(
kappa,
Amat,
Fmat,
Gmat,
GFinvG,
OplusW,
u,
v,
C1 = 1/(4 * pi),
Q = NULL
)
Arguments
kappa |
Value of kappa for which to compute log-likelihood |
Amat |
Mesh projection matrix |
Fmat |
Matrix used in computation of SPDE precision |
Gmat |
Matrix used in computation of SPDE precision |
GFinvG |
Matrix used in computation of SPDE precision |
OplusW |
Sparse matrix containing estimated values of RHS of trace in part 2 of log-likelihood. In common smoothness model, represents the sum over q=1,...,Q. |
u |
Vector needed for part 3 of log-likelihood |
v |
Vector needed for part 3 of log-likelihood |
C1 |
For the unit variance case, |
Q |
Equal to the number of networks for the common smoothness model, or NULL for the network-specific smoothness model |
Details
This is the function to be maximized in order to determine the MLE for \kappa
or the \kappa_q
's in the M-step of the EM algorithm in spatial
model. In the model where \kappa_q
can be different for each network q
, the optimization function factorizes over the \kappa_q
's. This function computes
the value of the part of the optimization function pertaining to one of the \kappa_q
's.
Value
Value of log-likelihood at logkappa
Log-likelihood SQUAREM
Description
Helper function for SQUAREM for extracting log likelihood
Usage
LL_SQUAREM(theta_vec, ...)
Arguments
theta_vec |
Vector of current parameter values |
Value
Negative log-likelihood given current values of parameters
Check Q2_max
Description
Check Q2_max
and set it if NULL
.
Usage
Q2_max_check(Q2_max, nQ, nT)
Arguments
Q2_max , nQ , nT |
The args |
Value
Q2_max
, clamped to acceptable range of values.
TR
Description
TR
Arguments
TR |
The temporal resolution of the data, i.e. the time between volumes,
in seconds. |
Update theta SQUAREM
Description
Helper function for SQUAREM for estimating parameters
Usage
UpdateThetaSQUAREM_BrainMap(
theta_vec,
prior_mean,
prior_var,
meshes,
BOLD,
C_diag,
H,
Hinv,
s0_vec,
D,
Dinv_s0,
update_nu0sq,
verbose
)
Arguments
theta_vec |
Vector of initial parameter values |
prior_mean |
Passed to UpdateTheta_BrainMap function |
prior_var |
Passed to UpdateTheta_BrainMap function |
meshes |
Passed to UpdateTheta_BrainMap function |
BOLD |
Passed to UpdateTheta_BrainMap function |
C_diag |
Passed to UpdateTheta_BrainMap function |
s0_vec |
Passed to UpdateTheta_BrainMap function |
D |
Passed to UpdateTheta_BrainMap function |
Dinv_s0 |
Passed to UpdateTheta_BrainMap function |
update_nu0sq |
For non-spatial model: updating |
verbose |
Passed to UpdateTheta_BrainMap function |
Value
Vector of updated parameter values
Parameter Estimates in EM Algorithm for Bayesian brain map
Description
Parameter Estimates in EM Algorithm for Bayesian brain map
Usage
UpdateTheta_BrainMap.spatial(
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_BrainMap.independent(
prior_mean,
prior_var,
BOLD,
theta,
C_diag,
H,
Hinv,
update_nu0sq = TRUE,
return_MAP = FALSE,
verbose = TRUE
)
Arguments
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 |
Value
An updated list of parameter estimates, theta, OR if
return_MAP=TRUE
, the posterior mean and precision of the latent fields
VB_FCBrainMap
Description
VB Algorithm for FC Bayesian brain map
Usage
VB_FCBrainMap(
prior_mean,
prior_var,
prior_FC,
method_FC = c("VB1", "VB2"),
nsamp_u = 10000,
CI_FC = 0.95,
return_FC_samp = FALSE,
prior_params = c(0.001, 0.001),
BOLD,
TR = NULL,
A0,
S0,
S0_var,
maxiter = 100,
miniter = 3,
epsilon = 0.001,
usePar = FALSE,
PW = FALSE,
seed = 1234,
verbose = FALSE
)
Arguments
prior_mean |
( |
prior_var |
( |
prior_FC |
(list) Parameters of functional connectivity prior. |
method_FC |
Variational Bayes (VB) method for FC Bayesian brain mapping:
|
nsamp_u |
For VB1, the number of samples to generate from u ~ Gamma, where
A is Gaussian conditional on u. Default: |
CI_FC |
Level of posterior credible interval to construct for each FC element.
Default: |
return_FC_samp |
Should the FC samples ( |
prior_params |
Alpha and beta parameters of IG prior on |
BOLD |
( |
A0 , S0 , S0_var |
Initial guesses at latent variables: |
maxiter |
Maximum number of VB iterations. Default: |
miniter |
Minimum number of VB iterations. Default: |
epsilon |
Smallest proportion change in parameter estimates between iterations.
Default: |
usePar |
Parallelize the computation? Default: |
PW |
Prewhiten to account for residual autocorrelation? Default: |
seed |
(Only applicable if |
verbose |
If |
Value
A list of computed values, including the final parameter estimates.
Combine additive terms in string
Description
Combine two terms with "+" or "-" in a string
Usage
add_str(a, b)
Arguments
a , b |
The two terms. Each is a length-one character vector. |
Value
The result as a length-one character vector.
Block diagonal matrix
Description
Code for function provided in examples of bdiag function from Matrix package
Usage
bdiag_m(lmat)
Arguments
lmat |
List of matrices |
Details
Construct block diagonal matrix of many small blocks
Value
A sparse matrix obtained by combining the arguments into a block diagonal matrix
Bdiag m2
Description
Bdiag m2
Usage
bdiag_m2(mat, N)
Arguments
mat |
a k x k 'matrix' |
N |
how many times to repeat |
Value
a sparse (Nk x Nk) matrix of class "dgCMatrix"
.
Check for required parallel packages
Description
Check that required packages for parallel computation are available. If not, stop execution with a helpful error message.
Usage
check_parallel_packages()
Value
NULL
, invisibly
Check required packages for the data format
Description
Check required packages for the data format
Usage
check_req_ifti_pkg(FORMAT)
Arguments
FORMAT |
The data FORMAT |
Value
NULL
, invisibly
Compute LL for EM Bayesian brain mapping
Description
Compute the expected log posterior for EM Standard Bayesian brain mapping
Usage
compute_LL_std(theta, prior_mean, prior_var, C_diag, BOLD, verbose)
Arguments
theta |
The current parameter estimates |
prior_mean , prior_var |
The prior |
C_diag |
The C matrix |
BOLD |
( |
verbose |
Print LL components? |
Value
The expected log posterior at the current values
Compute SPDE and prior precision matrices for S
Description
Compute SPDE matrices (F, G and GFinvG) and prior precision matrix for S
Usage
compute_R_inv(meshes, kappa, C1 = 1/(4 * pi), rm_extra = FALSE)
Arguments
meshes |
|
kappa |
Current estimates of SPDE parameter kappa for each latent field |
C1 |
Constant, equal to |
rm_extra |
If |
Value
A list containing R inverse and SPDE matrices
Compute posterior mean and precision of s
Description
Compute posterior mean and precision matrix of s
Usage
compute_mu_s(y_vec, D, Dinv_s0, R_inv, theta, P, C_diag)
Arguments
y_vec |
Vectorized, dimension-reduced fMRI data, grouped by locations. A vector of length |
D |
Sparse diagonal matrix of prior standard deviations |
Dinv_s0 |
The inverse of D times s0_vec |
R_inv |
Estimate of inverse spatial correlation matrix (sparse) |
theta |
List of current parameter estimates |
P |
Permutation matrix for regrouping by locations (instead of by networks.) |
C_diag |
Diagonals of residual covariance of the first level model. A vector of length |
Value
A list containing the posterior mean \mu
(mu) and precision
\Omega
(Omega) of s=(s1,...,sQ), along with the supporting vector m,
where \mu = \Omega^{-1}m
.
PCA-based Dimension Reduction and Prewhitening
Description
Performs dimension reduction and prewhitening based on probabilistic PCA using SVD. If dimensionality is not specified, it is estimated using the method described in Minka (2008).
Usage
dim_reduce(X, Q = NULL, Q_max = 100)
Arguments
X |
A numeric matrix, with each column being a centered timeseries.
For fMRI data, |
Q |
Number of latent dimensions to estimate. If |
Q_max |
Maximal number of principal components for automatic
dimensionality selection with PESEL. Default: |
Value
A list containing the dimension-reduced data (data_reduced
, a
V \times Q
matrix), prewhitening/dimension reduction matrix (H
,
a QxT
matrix) and its (pseudo-)inverse (Hinv
, a TxQ
matrix), the noise variance (sigma_sq
), the correlation matrix of the
dimension-reduced data (C_diag
, a QxQ
matrix), and the
dimensionality (Q
).
Dual Regression wrapper
Description
Wrapper to dual_reg
used by estimate_prior
. The format of BOLD
(and BOLD2
) must be provided, and template
must be vectorized if applicable.
Usage
dual_reg2(
BOLD,
BOLD2 = NULL,
format = c("CIFTI", "xifti", "GIFTI", "gifti", "NIFTI", "nifti", "RDS", "data"),
template,
template_parc_table = NULL,
mask = NULL,
keepA = FALSE,
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,
NA_limit = 0.1,
brainstructures = "all",
resamp_res = NULL,
varTol = 1e-06,
maskTol = 0.1,
verbose = TRUE
)
Arguments
BOLD , BOLD2 |
Subject-level fMRI data in one of the following formats:
a CIFTI file path, a If If |
format |
Expected format of |
template |
The group ICA map or parcellation as a (vectorized) numeric
matrix ( |
template_parc_table |
If the template is a parcellation, provide the
parcellation table here. Default: |
mask |
Required if and only if the entries of |
keepA |
Keep the resulting A matrices, or only return the S matrices (default)? |
scale |
|
scale_sm_surfL , scale_sm_surfR , scale_sm_FWHM |
Only applies if
If If To create a |
nuisance |
(Optional) Nuisance matrix to regress from the BOLD data.
If 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 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 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 |
brainstructures |
Only applies if the entries of |
resamp_res |
Only applies 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: |
maskTol |
Tolerance for number of locations masked out due to low
variance or missing values. If more than this many locations are masked out,
this subject is skipped without calculating dual regression. If |
verbose |
Display progress updates? Default: |
Value
The dual regression S matrices, or both the S
and A matrices if keepA
, or NULL
if dual
regression was skipped due to too many masked data locations.
Engagements of (spatial) Bayesian brain mapping
Description
Identify areas of engagement in each network from the result of (spatial) Bayesian brain mapping.
Usage
engagements(
bMap,
u = NULL,
z = NULL,
alpha = 0.01,
type = c(">", "abs >", "<", "!="),
method_p = "BH",
verbose = FALSE,
which.nets = NULL,
deviation = FALSE
)
Arguments
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 |
Value
A list containing engagement maps for each network, the joint and marginal PPMs for each network, 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.
Examples
## Not run:
engagements(bMap_result, alpha=.05, deviation=TRUE)
## End(Not run)
Estimation of effective sample size
Description
Estimation of effective sample size
Usage
estimate.ESS(mesh, Y, ind = NULL, trace = FALSE)
Arguments
mesh |
INLA mesh |
Y |
data |
ind |
index of the data locations in the mesh |
trace |
If |
Details
The functions computes the effective sample size as trace(Q^{-1})/trace(Q*Q)
as in Bretherton et al. (1999), Journal of Climate.
Value
Estimate of the effective sample size
Universally estimate IW dof parameter nu based on method of moments, so that no empirical variance is under-estimated
Description
Universally estimate IW dof parameter nu based on method of moments, so that no empirical variance is under-estimated
Usage
estimate_nu(var_FC, mean_FC)
Arguments
var_FC |
Empirical between-subject variance of covariance matrices (QxQ) |
mean_FC |
Empirical mean of covariance matrices (QxQ) |
Value
estimate for nu
Estimate IW dof parameter nu based on method of moments
Description
Estimate IW dof parameter nu based on method of moments
Usage
estimate_nu_matrix(var_FC, mean_FC)
Arguments
var_FC |
Empirical between-subject variance of covariance matrices (QxQ) |
mean_FC |
Empirical mean of covariance matrices (QxQ) |
Value
QxQ matrix of estimates for nu
Estimate prior
Description
Estimate prior for Bayesian brain mapping based on fMRI data
Usage
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,
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
)
Arguments
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. |
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: |
Details
All fMRI data (entries in BOLD
and BOLD2
, and template
) must
be in the same spatial resolution.
Value
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).
Examples
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)
Estimate FC prior
Description
Estimate FC prior
Usage
estimate_prior_FC(FC0, nu_adjust = 1)
Arguments
FC0 |
The FC estimates from |
nu_adjust |
Factor by which to adjust estimate of nu. Values < 1 will inflate the prior variance to avoid an over-informative prior on FC. |
Estimate prior from DR
Description
Estimate variance decomposition and priors from DR estimates.
Usage
estimate_prior_from_DR(DR, LV = NULL)
Arguments
DR |
the test/retest dual regression estimates, as an array with
dimensions ( |
LV |
A length-two integer vector giving the dimensions |
Value
List of two elements: the priors and the variance decomposition.
There are two version of the variance prior: varUB
gives the
unbiased variance estimate, and varNN
gives the upwardly-biased
non-negative variance estimate. Values in varUB
will need to be
clamped above zero before using in BrainMap
.
Estimate prior from DR estimates (when there are two measurements)
Description
Legacy version of estimate_prior_from_DR
Usage
estimate_prior_from_DR_two(DR1, DR2)
Arguments
DR1 , DR2 |
the test and retest dual regression estimates ( |
Value
List of two elements: the mean and variance priors
Export prior
Description
Export the priors (mean, variance, and FC) as separate files for
visualization or processing outside of BayesBrainMap
.
Usage
export_prior(x, out_fname = NULL, var_method = c("non-negative", "unbiased"))
Arguments
x |
The result of |
out_fname |
Use |
var_method |
|
Value
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.
Examples
## 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)
Format engagement name
Description
Format the name of an engagement, given parameters of the statistical test.
Usage
format_engagement_name(u, z, type, deviation, collapse = FALSE)
Arguments
u , z , type , deviation |
See |
collapse |
If multiple |
Compute inverse covariance matrix for AR process (up to a constant scaling factor)
Description
Compute inverse covariance matrix for AR process (up to a constant scaling factor)
Usage
getInvCovAR(ar, ntime)
Arguments
ar |
vector of p AR parameters |
ntime |
number of time points in timeseries |
Value
inverse covariance matrix for AR process (up to a constant scaling factor)
Get FORMAT from format
Description
Get FORMAT from format
Usage
get_FORMAT(format)
Arguments
format |
the file format |
Value
The file FORMAT
Half log determinant
Description
Computes half log determinant of X
, by sum(log(diag(chol(X))))
.
Usage
halflogdetX(X)
Arguments
X |
A numeric matrix |
Value
The half log determinant of X
.
hpf
Description
hpf
Arguments
hpf |
The frequency at which to apply a highpass filter to the data
during pre-processing, in Hertz. Default: Note the |
Compute likelihood in SPDE model for ESS estimation
Description
Compute likelihood in SPDE model for ESS estimation
Usage
lik(theta, Y, G, C, ind = NULL)
Arguments
theta |
Value of hyperparameters |
Y |
Data vector |
G |
SPDE G matrix |
C |
SPDE C matrix |
ind |
Indices of data locations in the mesh |
Value
Log likelihood value
Kappa log-likelihood
Description
Applicable to a single latent field, or multiple latent fields if common smoothness is assumed
Usage
loglik_kappa_est(par, delta, D_diag, mesh, C1 = 1/(4 * pi), Q = NULL)
Arguments
par |
Vector of length two containing values of log kappa and log residual variance at which to compute log likelihood |
delta |
Estimate of delta (subject effect or deviation) |
D_diag |
Diagonal values of D matrix (prior standard deviations) |
mesh |
Object of class "BrainMap_mesh" containing the triangular mesh (see |
C1 |
For the unit variance case, |
Q |
Equal to the number of networks for the common smoothness model, or NULL for the network-specific smoothness model |
Details
Compute log-likelihood of kappa given an initial estimate of delta
Value
Value of negative log likelihood
Make permutation matrix
Description
Create permutation matrix P to regroup elements of s by locations instead of by networks
Usage
make_Pmat(Q, nvox)
Arguments
Q |
The number of networks |
nvox |
The number of spatial locations ( |
Details
If s=(s1,...,sQ) is grouped by networks 1,...Q, then Ps=(s(1),...,s(nvox)) is grouped by locations 1,...,nvox
Value
P Permutation matrix size QVxQV
Create a mask based on vertices that are invalid
Description
Create a mask based on vertices that are invalid
Usage
make_mask(BOLD, meanTol = -Inf, varTol = 1e-06, verbose = TRUE)
Arguments
BOLD |
A |
meanTol , varTol |
Tolerance for mean and variance of each data location.
Locations which do not meet these thresholds are masked out of the analysis.
Defaults: |
verbose |
Print messages counting how many locations are removed? |
Value
A logical vector indicating valid vertices
Make INLA mesh from "surf"
object
Description
Create INLA mesh and observation weight matrix based on a "surf"
object
Usage
make_mesh(surf = NULL, inds_data = NULL, inds_mesh = NULL)
Arguments
surf |
|
inds_data |
Subset of vertices to include in analysis, e.g. non-medial wall locations. |
inds_mesh |
Subset of vertices to retain in mesh, e.g. non-medial wall
locations. Must be a superset of |
Value
List containing INLA mesh, observation weight matrix A for translating between mesh locations and original data locations, the brain mask used to create the mesh, and the number of original and mesh data locations.
Make 2D INLA mesh
Description
Create INLA mesh and observation weight matrix based on a binary brain mask
Usage
make_mesh_2D(mask)
Arguments
mask |
Brain mask (matrix of 0 and 1 or |
Details
This function requires the INLA
package, which is not a CRAN
package. See https://www.r-inla.org/download-install for easy
installation instructions.
Value
List containing INLA mesh, observation weight matrix A for translating between mesh locations and original data locations, the brain mask used to create the mesh, and the number of original and mesh data locations.
Normalize BOLD data
Description
Center the data across space and/or time, detrend, and scale, in that order. For dual regression, row centering is required and column centering is not recommended. Scaling and detrending depend on the user preference.
Usage
norm_BOLD(
BOLD,
center_rows = TRUE,
center_cols = FALSE,
scale = c("local", "global", "none"),
scale_sm_xifti = NULL,
scale_sm_FWHM = 2,
scale_sm_xifti_mask = NULL,
hpf = 0,
TR = NULL
)
Arguments
BOLD |
fMRI numeric data matrix ( |
center_rows , center_cols |
Center BOLD data across rows (each data
location's time series) or columns (each time point's image)? Default:
|
scale |
|
scale_sm_xifti , scale_sm_FWHM |
Only applies if |
scale_sm_xifti_mask |
For local scaling with smoothing, the data must be unmasked to be mapped back to the surface. So if the data are masked, provide the mask here. |
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. |
Value
Normalized BOLD data matrix (V \times T
)
Orthonormalizes a square, invertible matrix
Description
Orthonormalizes a square, invertible matrix
Usage
orthonorm(X)
Arguments
X |
A square matrix to be orthonormalized. |
Details
Y is orthonormal if $YY'=Y'Y=I$. Orthonormalization of X is given by $X (X'X)^(-.5)$.
Value
X after orthonormalization
Plot BrainMap estiamte
Description
Plot BrainMap estiamte
Usage
## S3 method for class 'bMap.cifti'
plot(x, stat = c("mean", "se"), maps = TRUE, FC = TRUE, ...)
Arguments
x |
The result of |
stat |
|
maps |
Show the BrianMap estimates on the brain? Default: |
FC |
Show the FC estimates? Default: |
... |
Additional arguments to |
Value
The plot
Plot prior
Description
This feature is not supported yet.
Usage
## S3 method for class 'bMap.matrix'
plot(x, ...)
Arguments
x |
The result of |
... |
Additional arguments |
Value
Nothing, because an error is raised.
Plot prior
Description
Plot prior
Usage
## S3 method for class 'bMap.nifti'
plot(
x,
stat = c("mean", "se"),
plane = c("axial", "sagittal", "coronal"),
n_slices = 9,
slices = NULL,
...
)
Arguments
x |
The result of |
stat |
|
plane , n_slices , slices |
Anatomical plane and which slice indices to show. Default: 9 axial slices. |
... |
Additional arguments |
Value
The plot
Plot engagements
Description
Plot engagements
Usage
## S3 method for class 'bMap_eng.cifti'
plot(x, stat = c("engaged", "pvals", "pvals_adj", "tstats", "se"), ...)
Arguments
x |
The engagements from |
stat |
|
... |
Additional arguments to |
Value
The engagements plot
Plot prior
Description
Plot prior
Usage
## S3 method for class 'prior.cifti'
plot(
x,
stat = c("mean", "sd", "var"),
maps = TRUE,
FC = c("emp", "IW", "Chol", "none"),
var_method = c("non-negative", "unbiased"),
...
)
Arguments
x |
The prior from |
stat |
Which prior statistic to plot: the |
maps |
Show the prior maps on the brain? Default: |
FC |
Empirical ( |
var_method |
|
... |
Additional arguments to |
Value
The plot
Plot prior
Description
Plot prior
Usage
## S3 method for class 'prior.gifti'
plot(
x,
stat = c("both", "mean", "sd", "var"),
var_method = c("non-negative", "unbiased"),
...
)
Arguments
x |
The prior from |
stat |
|
var_method |
|
... |
Additional arguments to |
Value
The plot
Plot prior
Description
Plot prior
Usage
## S3 method for class 'prior.matrix'
plot(x, ...)
Arguments
x |
The prior from |
... |
Additional arguments |
Value
The plot
Plot prior
Description
Based on oro.nifti::image
.
Usage
## S3 method for class 'prior.nifti'
plot(
x,
stat = c("mean", "sd", "var"),
plane = c("axial", "sagittal", "coronal"),
n_slices = 9,
slices = NULL,
var_method = c("non-negative", "unbiased"),
...
)
Arguments
x |
The prior from |
stat |
|
plane , n_slices , slices |
Anatomical plane and which slice indices to show. Default: 9 axial slices. |
var_method |
|
... |
Additional arguments to |
Details
Consider using struct_prior
to obtain the 3D volumes to plot with a different
viewer function (e.g. from oro.nifti
) if desired.
Value
The plot
Estimate residual autocorrelation for prewhitening
Description
Estimate residual autocorrelation for prewhitening
Usage
pw_estimate(A, ar_order, aic = FALSE)
Arguments
A |
Estimated A matrix (T x Q) |
ar_order , aic |
Order of the AR model used to prewhiten the data at each location.
If |
Value
Estimated AR coefficients and residual variance at every vertex
Remove brain structure from CIFTI prior
Description
Remove a brain structure from a CIFTI prior
Usage
removebs_prior(x, remove = NULL)
Arguments
x |
The |
remove |
|
Resample CIFTI prior
Description
Resample a CIFTI prior to a new spatial resolution.
Usage
resample_prior(x, resamp_res, verbose = FALSE)
Arguments
x |
The |
resamp_res |
The new resampling resolution. |
verbose |
Give occasional updates? Default: |
Value
The resampled "prior.cifti"
object.
Remove nuisance ICs from data
Description
Subtract estimated nuisance ICs from data matrix. If the number of nuisance ICs is not provided, will estimate using PESEL (the nuisance ICs are a rotation of the nuisance PCs).
Usage
rm_nuisIC(
BOLD,
DR = NULL,
prior_mean = NULL,
Q2 = NULL,
Q2_max = NULL,
checkRowCenter = TRUE,
verbose = FALSE,
return_Q2 = FALSE
)
Arguments
BOLD |
the row-centered |
DR , prior_mean |
We need an initial estimate of the brain networks, so
that we can avoid removing them during removal of the estimated noise ICs.
Provide either |
Q2 |
The number of nuisance ICs. If |
Q2_max |
If |
checkRowCenter |
Check row means, and raise an error if they are
nonzero? Default: |
verbose |
If |
return_Q2 |
Return (estimated) |
Value
The V
by T
data with the estimated nuisance ICs
subtracted from it. If return_Q2
, a list of length two: the second
entry will be Q2
.
scale
Description
scale
Arguments
scale |
|
Compute matrix square root of X'X
Description
Compute matrix square root of X'X
Usage
sqrt_XtX(X, inverse = FALSE)
Arguments
X |
A numerical matrix |
inverse |
if inverse=TRUE, compute inverse of square root |
Value
A matrix equalling the (inverse) matrix square root of X'X
Apply data structure to priors
Description
Apply data structure to priors
Usage
struct_prior(
prior,
FORMAT,
mask_input,
params,
dat_struct,
template_parc_table
)
Arguments
prior |
The prior |
FORMAT |
"CIFTI", "GIFTI", "NIFTI", or "DATA" |
mask_input |
The input mask |
params |
The params |
dat_struct |
The data structure |
Summarize a "bMap.cifti"
object
Description
Summary method for class "bMap.cifti"
Usage
## 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, ...)
Arguments
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The result of |
Value
A list summarizing of the results of the BrainMap analysis.
Nothing, invisibly.
Nothing, invisibly.
Summarize a "bMap.matrix"
object
Description
Summary method for class "bMap.matrix"
Usage
## 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, ...)
Arguments
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The prior from |
Value
A list summarizing of the results of the BrainMap analysis.
Nothing, invisibly.
Nothing, invisibly.
Summarize a "bMap.nifti"
object
Description
Summary method for class "bMap.nifti"
Usage
## 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, ...)
Arguments
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The prior from |
Value
A list summarizing of the results of the BrainMap analysis.
Nothing, invisibly.
Nothing, invisibly.
Summarize a "bMap_eng.cifti"
object
Description
Summary method for class "bMap_eng.cifti"
Usage
## 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, ...)
Arguments
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The engagements from |
Value
A list summarizing the data and results for the engagements analysis.
Nothing, invisibly.
Nothing, invisibly.
Summarize a "bMap_eng.matrix"
object
Description
Summary method for class "bMap_eng.matrix"
Usage
## 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, ...)
Arguments
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The engagements from |
Value
A list summarizing the data and results for the engagements analysis.
Nothing, invisibly.
Nothing, invisibly.
Summarize a "bMap_eng.nifti"
object
Description
Summary method for class "bMap_eng.nifti"
Usage
## 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, ...)
Arguments
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The engagements from |
Value
A list summarizing the data and results for the engagements analysis.
Nothing, invisibly.
Nothing, invisibly.
Summarize a "prior.cifti"
object
Description
Summary method for class "prior.cifti"
Usage
## 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, ...)
Arguments
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The prior from |
Value
A list summarizing the prior: data dimensions, options used for prior estimation, etc.
Nothing, invisibly.
Nothing, invisibly.
Summarize a "prior.gifti"
object
Description
Summary method for class "prior.gifti"
Usage
## 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, ...)
Arguments
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The prior from |
Value
A list summarizing the prior: data dimensions, options used for prior estimation, etc.
Nothing, invisibly.
Nothing, invisibly.
Summarize a "prior.matrix"
object
Description
Summary method for class "prior.matrix"
Usage
## 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, ...)
Arguments
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The prior from |
Value
A list summarizing the prior: data dimensions, options used for prior estimation, etc.
Nothing, invisibly.
Nothing, invisibly.
Summarize a "prior.nifti"
object
Description
Summary method for class "prior.nifti"
Usage
## 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, ...)
Arguments
object |
Object of class |
... |
further arguments passed to or from other methods. |
x |
The prior from |
Value
A list summarizing the prior: data dimensions, options used for prior estimation, etc.
Nothing, invisibly.
Nothing, invisibly.
Update A for VB FC Bayesian brain mapping using IW prior on FC
Description
Update A for VB FC Bayesian brain mapping using IW prior on FC
Usage
update_A(
mu_tau2,
mu_S,
E_SSt,
BOLD,
ntime,
nNets,
nvox,
u_samps,
prior_FC,
usePar = TRUE,
final = FALSE
)
Arguments
mu_tau2 , mu_S , E_SSt |
Most recent estimates of posterior moments for these variables. |
BOLD |
( |
ntime , nNets , nvox |
Number of timepoints, number of , number of locations |
u_samps |
Samples from Gamma for multivariate t prior on A |
prior_FC |
IW parameters for FC prior |
usePar |
Parallelize the computation? Default: |
final |
If TRUE, return cov_A. Default: |
Value
List of length two: mu_A
(TxQ) and E_AtA
(QxQ).
Update A for VB FC Bayesian brain mapping using Cholesky prior for FC
Description
Update A for VB FC Bayesian brain mapping using Cholesky prior for FC
Usage
update_A_Chol(
mu_tau2,
mu_S,
E_SSt,
BOLD,
ntime,
nNets,
nvox,
prior_FC,
final = FALSE,
exact = FALSE,
usePar = TRUE,
verbose = FALSE
)
Arguments
mu_tau2 , mu_S , E_SSt |
Most recent estimates of posterior moments for these variables. |
BOLD |
( |
ntime , nNets , nvox |
Number of timepoints, number of networks, number of locations |
prior_FC |
IW parameters for FC prior |
final |
If TRUE, return cov_A. Default: |
exact |
If FALSE, at intermediate steps (final = |
usePar |
Parallelize the computation? Default: |
verbose |
If |
Value
List of length two: mu_A
(TxQ) and E_AtA
(QxQ).
Update S for VB FC Bayesian brain mapping
Description
Update S for VB FC Bayesian brain mapping
Usage
update_S(
mu_tau2,
mu_A,
E_AtA,
D_inv,
D_inv_S,
BOLD,
nNets,
nvox,
ntime,
final = FALSE
)
Arguments
mu_tau2 , mu_A , E_AtA |
Most recent posterior estimates |
D_inv , D_inv_S |
Some pre-computed quantities. |
BOLD |
( |
nNets , nvox , ntime |
Number of networks, number of data locations, and time series length |
final |
If TRUE, return cov_S. Default: |
Value
List of length three: mu_S
(QxV), E_SSt
(QxQ), and cov_S
(QxQxV).
Update tau for VB FC Bayesian brain mapping
Description
Update tau for VB FC Bayesian brain mapping
Usage
update_tau2(BOLD, BOLD2, mu_A, E_AtA, mu_S, E_SSt, prior_params, ntime, nvox)
Arguments
BOLD |
( |
BOLD2 |
A precomputed quantity, |
mu_A , E_AtA , mu_S , E_SSt |
Current posterior estimates |
prior_params |
Alpha and beta parameters of IG prior on |
ntime , nvox |
Number of timepoints in data and the number of data locations. |
Value
List of length two: alpha1
and beta1
.
varTol
Description
varTol
Arguments
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: |
Compute the error between empirical and theoretical variance of covariance matrix elements
Description
Compute the error between empirical and theoretical variance of covariance matrix elements
Usage
var_sq_err(nu, p, var_ij, xbar_ij, xbar_ii, xbar_jj)
Arguments
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 |
Value
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
Description
Compute the overall error between empirical and theoretical variance of CORRELATION matrix elements
Usage
var_sq_err_constrained(nu, p, var, xbar, M = 10000)
Arguments
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 |
Value
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