Learn R Programming

templateICAr

This package contains functions implementing the template ICA model proposed in Mejia et al. (2019) and the spatial template ICA model proposed in proposed in Mejia et al. (2020+). For both models, subject-level brain networks are estimated as deviations from known population-level networks, which can be estimated using standard ICA algorithms. Both models employ an expectation-maximization algorithm for estimation of the latent brain networks and unknown model parameters.

Template ICA consists of three steps. The main functions associated with each step are listed below.

  1. Template estimation: estimate_template. Can export the results with export_template.
  2. Template ICA model estimation (single-subject): templateICA.
  3. Identification of areas of engagement in each IC (or deviation from the template mean): activations.

Citation

If you use templateICAr please cite the following papers:

NameAPA Citation
Template ICAMejia, A. F., Nebel, M. B., Wang, Y., Caffo, B. S., & Guo, Y. (2020). Template Independent Component Analysis: targeted and reliable estimation of subject-level brain networks using big data population priors. Journal of the American Statistical Association, 115(531), 1151-1177.
Spatial Template ICAMejia, A. F., Bolin, D., Yue, Y. R., Wang, J., Caffo, B. S., & Nebel, M. B. (2022). Template Independent Component Analysis with spatial priors for accurate subject-level brain network estimation and inference. Journal of Computational and Graphical Statistics, (just-accepted), 1-35.

You can also obtain citation information from within R like so:

citation("templateICAr")

Installation

You can install the development version of templateICAr from Github with:

# install.packages("devtools")
devtools::install_github("mandymejia/templateICAr")

Important Notes on Dependencies:

To analyze or visualize CIFTI-format data, templateICAr depends on the ciftiTools package, which requires an installation of Connectome Workbench. It can be installed from the HCP website.

For fitting the template ICA model with surface-based priors (spatial_model=TRUE in templateICA()), INLA is required. Due to a CRAN policy, INLA cannot be installed automatically. You can obtain it by running install.packages("INLA", repos=c(getOption("repos"), INLA="https://inla.r-inla-download.org/R/stable"), dep=TRUE). Alternatively, dep=FALSE can be used along with manual installation of dependencies as necessary to avoid installing all of the many INLA dependencies, most of which are not actually required. Binaries for alternative Linux builds can be added with the command inla.binary.install(). Note that INLA is not required for standard template ICA.

Depending on the analysis, PARDISO may reduce computation time. To obtain a free academic license forINLA-PARDISO, run inla.pardiso() in R after running library(INLA). Provide an academic email address. Once you obtain a license, point to it using INLA::inla.setOption(pardiso.license = "pardiso.lic") followed by INLA::inla.pardiso.check() to ensure that PARDISO is successfully installed and running.

Copy Link

Version

Install

install.packages('templateICAr')

Monthly Downloads

12,307

Version

0.9.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Amanda Mejia

Last Published

November 21st, 2024

Functions in templateICAr (0.9.1)

bdiag_m

Block diagonal matrix
estimate_nu

Universally estimate IW dof parameter nu based on method of moments, so that no empirical variance is under-estimated
bdiag_m2

Bdiag m2
dual_reg2

Dual Regression wrapper
activations

Activations of (spatial) template ICA
estimate_nu_matrix

Estimate IW dof parameter nu based on method of moments
compute_mu_s

Compute posterior mean and precision of s
export_template

Export template
dim_reduce

PCA-based Dimension Reduction and Prewhitening
groupICA.cifti

Perform group ICA based on CIFTI data
format_activation_name

Format activation name
halflogdetX

Half log determinant
orthonorm

Orthonormalizes a square, invertible matrix
getInvCovAR

Compute inverse covariance matrix for AR process (up to a constant scaling factor)
compute_LL_std

Compute LL for EM Template ICA
compute_R_inv

Compute SPDE and prior precision matrices for S
get_FORMAT

Get FORMAT from format
estimate_template_from_DR

Estimate template from DR
make_mesh_2D

Make 2D INLA mesh
norm_BOLD

Normalize BOLD data
estimate.ESS

Estimation of effective sample size
plot.tICA.nifti

Plot template
plot.tICA.matrix

Plot template
plot.tICA.cifti

Plot template
estimate_template_from_DR_two

Estimate template from DR estimates (when there are two measurements)
make_mask

Create a mask based on vertices that are invalid
rm_nuisIC

Remove nuisance ICs from data
make_mesh

Make INLA mesh from "surf" object
plot.template.gifti

Plot template
make_Pmat

Make permutation matrix
loglik_kappa_est

Kappa log-likelihood
summary.tICA_act.matrix

Summarize a "tICA_act.matrix" object
scale_Param

scale
summary.template.cifti

Summarize a "template.cifti" object
plot.template.matrix

Plot template
removebs_template

Remove brain structure from CIFTI template
summary.tICA_act.nifti

Summarize a "tICA_act.nifti" object
plot.template.cifti

Plot template
var_sq_err

Compute the error between empirical and theoretical variance of covariance matrix elements
plot.tICA_act.cifti

Plot activations
struct_template

Apply data structure to templates
sqrt_XtX

Compute matrix square root of X'X
estimate_template_FC

Estimate FC template
estimate_template

Estimate template
plot.template.nifti

Plot template
summary.tICA.cifti

Summarize a "tICA.cifti" object
add_str

Combine additive terms in string
summary.tICA.matrix

Summarize a "tICA.matrix" object
pw_estimate

Estimate residual autocorrelation for prewhitening
lik

Compute likelihood in SPDE model for ESS estimation
hpf_param

hpf
resample_template

Resample CIFTI template
summary.template.matrix

Summarize a "template.matrix" object
var_sq_err_constrained

Compute the overall error between empirical and theoretical variance of CORRELATION matrix elements
update_tau2

Update tau for VB FC Template ICA
summary.template.gifti

Summarize a "template.gifti" object
varTol_Param

varTol
templateICA

Template ICA
update_A_Chol

Update A for VB FC Template ICA using Cholesky prior for FC
summary.template.nifti

Summarize a "template.nifti" object
update_S

Update S for VB FC Template ICA
summary.tICA_act.cifti

Summarize a "tICA_act.cifti" object
update_A

Update A for VB FC Template ICA using IW prior on FC
summary.tICA.nifti

Summarize a "tICA.nifti" object
Chol_samp_fun

Cholesky-based FC sampling
LL2_kappa

Compute part of kappa log-likelihood
IW_var

Compute theoretical Inverse-Wishart variance of covariance matrix elements
IW_var_cor

Compute theoretical Inverse-Wishart variance of correlation matrix elements
EM_templateICA

EM Algorithms for Template ICA Models
UT2mat

Transform upper-triangular elements to matrix form
check_req_ifti_pkg

Check required packages for the data format
INLA_check

Check for INLA
LL_SQUAREM

Log-likelihood SQUAREM
GSR_Param

GSR
Q2_max_check

Check Q2_max
check_parallel_packages

Check for required parallel packages
UpdateThetaSQUAREM_templateICA

Update theta SQUAREM
TR_param

TR
UpdateTheta_templateICA

Parameter Estimates in EM Algorithm for Template ICA Model
VB_FCtemplateICA

VB_FCtemplateICA