Package: BHMSMAfMRI 2.2

Nilotpal Sanyal

BHMSMAfMRI: Bayesian Hierarchical Multi-Subject Multiscale Analysis of Functional MRI (fMRI) Data

Package BHMSMAfMRI performs Bayesian hierarchical multi-subject multiscale analysis of fMRI data as described in Sanyal & Ferreira (2012) <doi:10.1016/j.neuroimage.2012.08.041>, or other multiscale data, using wavelet-based prior that borrows strength across subjects and provides posterior smoothed images of the effect sizes and samples from the posterior distribution.

Authors:Nilotpal Sanyal [aut, cre], Marco A.R. Ferreira [aut]

BHMSMAfMRI_2.2.tar.gz
BHMSMAfMRI_2.2.tar.gz(r-4.5-noble)BHMSMAfMRI_2.2.tar.gz(r-4.4-noble)
BHMSMAfMRI_2.2.tgz(r-4.4-emscripten)BHMSMAfMRI_2.2.tgz(r-4.3-emscripten)
BHMSMAfMRI.pdf |BHMSMAfMRI.html
BHMSMAfMRI/json (API)
NEWS

# Install 'BHMSMAfMRI' in R:
install.packages('BHMSMAfMRI', repos = 'https://cloud.r-project.org')

Bug tracker:https://github.com/nilotpalsanyal/bhmsmafmri/issues

Pkgdown site:https://nilotpalsanyal.github.io

Uses libs:
  • openblas– Optimized BLAS
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library
Datasets:
  • fmridata - A simulated fMRI data for 3 subjects

On CRAN:

Conda-Forge:

openblascppopenmp

2.70 score 1 stars 621 downloads 11 exports 8 dependencies

Last updated 9 months agofrom:4f006c3abe. Checks:1 OK, 1 WARNING. Indexed: no.

TargetResultLatest binary
Doc / VignettesOKFeb 08 2025
R-4.5-linux-x86_64WARNINGFeb 08 2025

Exports:BHMSMAglmcoefhyperparamestpostglmcoefpostgroupglmcoefpostmixprobpostsamplespostwaveletcoefreadfmridatasubstituteWaveletCoefwaveletcoef

Dependencies:abindbitopsMASSoro.niftiRcppRcppArmadilloRNiftiwavethresh

BHMSMAfMRI User Guide

Rendered fromBHMSMAfMRIvignette.Rmdusingknitr::rmarkdownon Feb 08 2025.

Last update: 2022-10-02
Started: 2022-09-08

Citation

To cite package ‘BHMSMAfMRI’ in publications use:

Sanyal N, Ferreira M (2024). BHMSMAfMRI: Bayesian Hierarchical Multi-Subject Multiscale Analysis of Functional MRI (fMRI) Data. R package version 2.2, https://CRAN.R-project.org/package=BHMSMAfMRI.

Corresponding BibTeX entry:

  @Manual{,
    title = {BHMSMAfMRI: Bayesian Hierarchical Multi-Subject Multiscale
      Analysis of Functional MRI (fMRI) Data},
    author = {Nilotpal Sanyal and Marco A.R. Ferreira},
    year = {2024},
    note = {R package version 2.2},
    url = {https://CRAN.R-project.org/package=BHMSMAfMRI},
  }

Readme and manuals

BHMSMAfMRI: Bayesian Hierarchical Multi-Subject Multiscale Analysis of fMRI Data

BHMSMAfMRI performs Bayesian hierarchical multi-subject multiscale analysis of function MRI (fMRI) data as described in Sanyal & Ferreira (2012), or other multiscale data, using wavelet based prior that borrows strength across subjects and provides posterior smooth estimates of the effect sizes and samples from their posterior distribution.

Installation

Install from CRAN
install.packages("BHMSMAfMRI")
Install from GitHub
# install.packages("devtools")
devtools::install_github("nilotpalsanyal/BHMSMAfMRI")

The main function:

BHMSMA is the main function which accepts fMRI data as a 4D array (see code below) and a design matrix. For the time-series of all voxels, a general linear model (GLM) is fit with all the regressors in the design matrix. After that, the standardized regression coefficient map of a regressor of interest is subjected to further analysis. The function BHMSMA returns the posterior smoothed map of the regression coefficients. Below is a basic illustration of its use. For a detailed manual, see the package vignette.

library(BHMSMAfMRI)
#> 
#>  Welcome! Thanks for trying BHMSMAfMRI.
#>  
#>  Website: https://nilotpalsanyal.github.io/BHMSMAfMRI/
#>  Bug report: https://github.com/nilotpalsanyal/BHMSMAfMRI/issues

# Read data from image files
fpath <- system.file("extdata", package="BHMSMAfMRI")
untar(paste0(fpath,"/fmridata.tar"), exdir=tempdir())
n <- 3
grid <- 32
ntime <- 9
data <- array(dim=c(n,grid,grid,ntime))
for(subject in 1:n)
{
  directory <- paste0(tempdir(),"/fmridata","/s0",subject,"/")
  a <- readfmridata(directory, format="Analyze", prefix=paste0("s0",subject,"_t"),
                    nimages=9, dim.image=c(grid,grid,1))
  data[subject,,,] <- a[,,1,]
}
data(fmridata)
names(fmridata)
#> [1] "grid"         "nsubject"     "TrueCoeff"    "DesignMatrix"
truecoef <- fmridata$TrueCoeff
designmat <- fmridata$DesignMatrix

# Perform analyses
k <- 2  #consider the second regressor
analysis <- "multi"     #perform multi-subject analysis (MSA)
BHMSMAmulti <- BHMSMA(n, grid, data, designmat, k, analysis, truecoef)
analysis <- "single"     #perform single subject analysis (SSA)
BHMSMAsingle <- BHMSMA(n, grid, data, designmat, k, analysis, truecoef)

# Compare results for the first subject
zlim = c(0,max(abs(BHMSMAmulti$GLMCoefStandardized[1,,,k])))
par(mfrow=c(2,2))
image( truecoef[1,,],col=heat.colors(12),main="true map")
image( abs(BHMSMAsingle$GLMCoefStandardized[1,,,k]),
       col=heat.colors(8),zlim=zlim,main="GLM coef map")
image( abs(BHMSMAsingle$GLMcoefposterior[1,,]),
       col=heat.colors(8),zlim=zlim,main="posterior map SSA")
image( abs(BHMSMAmulti$GLMcoefposterior[1,,]),
       col=heat.colors(8),zlim=zlim,main="posterior map MSA")

References:

Sanyal, Nilotpal, and Ferreira, Marco A.R. (2012). Bayesian hierarchical multi-subject multiscale analysis of functional MRI data. Neuroimage, 63, 3, 1519-1531. https://doi.org/10.1016/j.neuroimage.2012.08.041

Help Manual

Help pageTopics
Bayesian Hierarchical Multi-Subject Multiscale Analysis (BHMSMA) of Functional MRI DataBHMSMAfMRI
Bayesian hierarchical multi-subject multiscale analysis (BHMSMA) of functional MRI data or other multiscale dataBHMSMA
A simulated fMRI data for 3 subjectsfmridata
Fit GLM (general linear model) to the fMRI time-series of all voxels within a single 2D brain sliceglmcoef
Obtain estimates of the hyperparameters of the BHMSMA modelhyperparamest
Obtain posterior estimate of a 2D GLM coefficients map of a regressorpostglmcoef
Obtain posterior group estimate of a 2D GLM coefficients map of a regressorpostgroupglmcoef
Obtain estimates of the mixture probabilities defining the BHMSMA posterior wavelet coefficients distributionspostmixprob
Obtain samples from the posterior distribution of a 2D GLM coefficient map.postsamples
Obtain posterior estimates of the BHMSMA wavelet coefficientspostwaveletcoef
Import fMRI data from various fMRI image filesreadfmridata
Substitute 2D wavelet transform coefficients with user-given valuessubstituteWaveletCoef
Apply discrete wavelet transform (DWT) to a 2D GLM coefficient map of a regressorwaveletcoef