Package 'BayesDLMfMRI'

Title: Statistical Analysis for Task-Based Fmri Data
Description: The 'BayesDLMfMRI' package performs statistical analysis for task-based functional magnetic resonance imaging (fMRI) data at both individual and group levels. The analysis to detect brain activation at the individual level is based on modeling the fMRI signal using Matrix-Variate Dynamic Linear Models (MDLM). The analysis for the group stage is based on posterior distributions of the state parameter obtained from the modeling at the individual level. In this way, this package offers several R functions with different algorithms to perform inference on the state parameter to assess brain activation for both individual and group stages. Those functions allow for parallel computation when the analysis is performed for the entire brain as well as analysis at specific voxels when it is required. References: Cardona-Jiménez (2021) <doi:10.1016/j.csda.2021.107297>; Cardona-Jiménez (2021) <arXiv:2111.01318>.
Authors: Johnatan Cardona-Jiménez [aut], Carlos Pérez [cre, aut], Isabel Ramírez [aut]
Maintainer: Carlos Pérez <[email protected]>
License: GPL-2
Version: 0.0.3
Built: 2024-07-24 19:59:23 UTC
Source: CRAN

Help Index


Bayesian Matrix-Variate Dynamic Linear Models for Task-based fMRI Modeling in R

Description

The 'BayesDLMfMRI' package performs statistical analysis for task-based functional magnetic resonance imaging (fMRI) data at both individual and group levels. The analysis to detect brain activation at the individual level is based on modeling the fMRI signal using Matrix-Variate Dynamic Linear Models (MDLM). The analysis for the group stage is based on posterior distributions of the state parameter obtained from the modeling at the individual level. In this way, this package offers several R functions with different algorithms to perform inference on the state parameter to assess brain activation for both individual and group stages. Those functions allow for parallel computation when the analysis is performed for the entire brain as well as analysis at specific voxels when it is required.

Authors

Maintainer: Carlos Peréz [email protected]
Creator: Johnatan Cardona-Jiménez [email protected]
Contributor: Isabel Ramírez [email protected]


Covariates related to the observed BOLD response

Description

Covariates related to the observed BOLD response and its derivative used in the examples presented in the vignettes.

Usage

Covariates

Format

An object of class data.frame with 310 rows and 2 columns.

Examples

data("covariates", package="BayesDLMfMRI")

MNI image used to plot posterior probability maps in the vignette examples.

Description

MNI image used to plot posterior probability maps in the examples presented in the vignettes.

Usage

ffd

Format

An object of class nifti of dimension 91 x 109 x 91.

Examples

data("ffd", package="BayesDLMfMRI")

ffdEvidenceFETS

Description

This function can be used to build activation maps for task-based fMRI data.

Usage

ffdEvidenceFETS(
  ffdc,
  covariates,
  m0 = 0,
  Cova = 100,
  delta = 0.95,
  S0 = 1,
  n0 = 1,
  N1 = FALSE,
  Nsimu1 = 100,
  Cutpos1 = 30,
  r1 = 1,
  perVol = 0.1,
  Test = "LTT",
  Ncores = NULL,
  seed = NULL
)

Arguments

ffdc

a 4D array (ffdc[i,j,k,t]) that contains the sequence of MRI images that are meant to be analyzed. (i,j,k) define the position of the observed voxel at time t.

covariates

a data frame or matrix whose columns contain the covariates related to the expected BOLD response obtained from the experimental setup.

m0

the constant prior mean value for the covariates parameters and common to all voxels within every neighborhood at t=0 (m=0 is the default value when no prior information is available). For the case of available prior information, m0 can be defined as a \(p\times q\) matrix, where \(p\) is the number of columns in the covariates object and \(q\) is the cluster size.

Cova

a positive constant that defines the prior variances for the covariates parameters at t=0 (Cova=100 is the default value when no prior information is available). For the case of available prior information, Cova can be defined as a \(p\times p\) matrix, where \(p\) is the number of columns in the covariates object.

delta

a discount factor related to the evolution variances. Recommended values between 0.85<delta<1. delta=1 will yield results similar to the classical general linear model.

S0

prior covariance structure among voxels within every cluster at t=0. S0=1 is the default value when no prior information is available and defines an \(q\times q\) identity matrix. For the case of available prior information, S0 can be defined as an \(q\times q\) matrix, where \(q\) is the common number of voxels in every cluster.

n0

a positive hyperparameter of the prior distribution for the covariance matrix S0 at t=0 (n0=1 is the default value when no prior information is available). For the case of available prior information, n0 can be set as n0=np, where np is the number of MRI images in the pilot sample.

N1

is the number of images (2<N1<T) from the ffdc array employed in the model fitting. N1=NULL (or equivalently N1=T) is its default value, taking all the images in the ffdc array for the fitting process.

Nsimu1

is the number of simulated on-line trajectories related to the state parameters. These simulated curves are later employed to compute the posterior probability of voxel activation.

Cutpos1

a cutpoint time from where the on-line trajectories begin. This parameter value is related to an approximation from a t-student distribution to a normal distribution. Values equal to or greater than 30 are recommended (30<Cutpos1<T).

r1

a positive integer number that defines the distance from every voxel with its most distant neighbor. This value determines the size of the cluster. The users can set a range of different r1 values: \(r1 = 0, 1, 2, 3, 4\), which leads to \(q = 1, 7, 19, 27, 33\), where \(q\) is the size of the cluster.

perVol

helps to define a threshold for the voxels considered in the analysis. For example, Min.vol = 0.10 means that all the voxels with values below to max(ffdc)*perVol can be considered irrelevant and discarded from the analysis.

Test

test type either "LTT" (Average cluster effect) or "JointTest" (Joint effect).

Ncores

a positive integer indicating the number of threads or cores to be used in the computation of the activation maps.

seed

random seed.

Details

Every voxel from the 4D array image is clustered with its nearest neighbors. There are as many clusters as voxels in the image. Then, activation maps are obtained by fitting a multivariate dynamic linear model on every cluster of voxels. The resulting activation evidence measure for every voxel is obtained using the Forward Estimated Trajectories Sampler (FETS) algorithm. To deeply understand the method implemented in this package, a reading of (Cardona-Jiménez and de B. Pereira 2021) and (Cardona-Jiménez 2021) is mandatory.

Value

It returns a list of the type res[[p]][x,y,z], where p represents the column position in the covariates matrix and [x,y,z] represent the voxel position in the brain image.

References

Cardona-Jiménez J, de B. Pereira CA (2021). “Assessing dynamic effects on a Bayesian matrix-variate dynamic linear model: An application to task-based fMRI data analysis.” Computational Statistics & Data Analysis, 163, 107297. ISSN 0167-9473, doi:10.1016/j.csda.2021.107297, https://www.sciencedirect.com/science/article/pii/S0167947321001316.

Cardona-Jiménez J (2021). “BayesDLMfMRI: Bayesian Matrix-Variate Dynamic Linear Models for Task-based fMRI Modeling in R.” arXiv e-prints, arXiv–2111.

Examples

## Not run: 
fMRI.data  <- get_example_fMRI_data()
data("covariates", package="BayesDLMfMRI")
res <- ffdEvidenceFETS(ffdc = fMRI.data, covariates = Covariates,
                       m0 = 0, Cova = 100, delta = 0.95, S0 = 1, 
                       n0 = 1, Nsimu1 = 100, Cutpos1 = 30, 
                       r1 = 2, Test = "JointTest",  Ncores = 1)
str(res)

## End(Not run)

ffdEvidenceFFBS

Description

This function can be used to build activation maps for task-based fMRI data.

Usage

ffdEvidenceFFBS(
  ffdc,
  covariates,
  m0 = 0,
  Cova = 100,
  delta = 0.95,
  S0 = 1,
  n0 = 1,
  N1 = FALSE,
  Nsimu1 = 100,
  Cutpos1 = 30,
  r1 = 1,
  perVol = 0.1,
  Ncores = NULL,
  seed = NULL
)

Arguments

ffdc

a 4D array (ffdc[i,j,k,t]) that contains the sequence of MRI images that are meant to be analyzed. (i,j,k) define the position of the voxel observed at time t.

covariates

a data frame or matrix whose columns contain the covariates related to the expected BOLD response obtained from the experimental setup.

m0

the constant prior mean value for the covariates parameters and common to all voxels within every neighborhood at t=0 (m=0 is the default value when no prior information is available). For the case of available prior information, m0 can be defined as a \(p\times q\) matrix, where \(p\) is the number of columns in the covariates object and \(q\) is the cluster size.

Cova

a positive constant that defines the prior variances for the covariates parameters at t=0 (Cova=100 is the default value when no prior information is available). For the case of available prior information, Cova can be defined as a \(p\times p\) matrix, where \(p\) is the number of columns in the covariates object.

delta

a discount factor related to the evolution variances. Recommended values between 0.85<delta<1. delta=1 will yield results similar to the classical general linear model.

S0

prior covariance structure among voxels within every cluster at t=0. S0=1 is the default value when no prior information is available and defines an \(q\times q\) identity matrix. For the case of available prior information, S0 can be defined as an \(q\times q\) matrix, where \(q\) is the common number of voxels in every cluster.

n0

a positive hyperparameter of the prior distribution for the covariance matrix S0 at t=0 (n0=1 is the default value when no prior information is available). For the case of available prior information, n0 can be set as n0=np, where np is the number of MRI images in the pilot sample.

N1

is the number of images (2<N1<T) from the ffdc array employed in the model fitting. N1=NULL (or equivalently N1=T) is its default value, taking all the images in the ffdc array for the fitting process.

Nsimu1

is the number of simulated on-line trajectories related to the state parameters. These simulated curves are later employed to compute the posterior probability of voxel activation.

Cutpos1

a cutpoint time from where the on-line trajectories begin. This parameter value is related to an approximation from a t-student distribution to a normal distribution. Values equal to or greater than 30 are recommended (30<Cutpos1<T).

r1

a positive integer number that defines the distance from every voxel with its most distant neighbor. This value determines the size of the cluster. The users can set a range of different r1 values: \(r1 = 0, 1, 2, 3, 4\), which leads to \(q = 1, 7, 19, 27, 33\), where \(q\) is the size of the cluster.

perVol

helps to define a threshold for the voxels considered in the analysis. For example, Min.vol = 0.10 means that all the voxels with values below to max(ffdc)*perVol can be considered irrelevant and discarded from the analysis.

Ncores

a postive integer indicating the number of threads or cores to be used in the computation of the activation maps.

seed

random seed.

Details

Every voxel from the 4D array image is clustered with its nearest neighbors. There are as many clusters as voxels in the image. Then, activation maps are obtained by fitting a multivariate dynamic linear model on every cluster of voxels. The resulting activation evidence measure for every voxel is obtained by using the Forward filtering backward sampling (FFBS) algorithm. To deeply understand the method implemented in this package, a reading of (Cardona-Jiménez and de B. Pereira 2021) and (Cardona-Jiménez 2021) is mandatory.

Value

It returns a list of the form res[[k]][p,x,y,z], where k defines the type of test (k = 1 for "Marginal", k = 2 for "JointTest", and k = 3 for "LTT"), p represents the column position in the covariates matrix and x,y,z represent the voxel position in the brain image.

References

Cardona-Jiménez J, de B. Pereira CA (2021). “Assessing dynamic effects on a Bayesian matrix-variate dynamic linear model: An application to task-based fMRI data analysis.” Computational Statistics & Data Analysis, 163, 107297. ISSN 0167-9473, doi:10.1016/j.csda.2021.107297, https://www.sciencedirect.com/science/article/pii/S0167947321001316.

Cardona-Jiménez J (2021). “BayesDLMfMRI: Bayesian Matrix-Variate Dynamic Linear Models for Task-based fMRI Modeling in R.” arXiv e-prints, arXiv–2111.

Examples

## Not run: 
fMRI.data  <- get_example_fMRI_data()
data("covariates", package="BayesDLMfMRI")
res <- ffdEvidenceFFBS(ffdc = fMRI.data, covariates = Covariates, m0=0, Cova=100,
                       delta=0.95, S0=1, n0=1, N1=FALSE, 
                       Nsimu1 = 100, Cutpos1=30, r1 = 1,
                       perVol = 0.10, Ncores=3)
str(res)

## End(Not run)

ffdEvidenceFSTS

Description

This function can be used to build activation maps for task-based fMRI data.

Usage

ffdEvidenceFSTS(
  ffdc,
  covariates,
  m0 = 0,
  Cova = 100,
  delta = 0.95,
  S0 = 1,
  n0 = 1,
  N1 = FALSE,
  Nsimu1 = 100,
  Cutpos1 = 30,
  r1 = 1,
  perVol = 0.1,
  Ncores = NULL,
  seed = NULL
)

Arguments

ffdc

a 4D array (ffdc[i,j,k,t]) that contains the sequence of MRI images that are meant to be analyzed. (i,j,k) define the position of the voxel observed at time t.

covariates

a data frame or matrix whose columns contain the covariates related to the expected BOLD response obtained from the experimental setup.

m0

the constant prior mean value for the covariates parameters and common to all voxels within every neighborhood at t=0 (m=0 is the default value when no prior information is available). For the case of available prior information, m0 can be defined as a \(p\times q\) matrix, where \(p\) is the number of columns in the covariates object and \(q\) is the cluster size.

Cova

a positive constant that defines the prior variances for the covariates parameters at t=0 (Cova=100 is the default value when no prior information is available). For the case of available prior information, Cova can be defined as a \(p\times p\) matrix, where p is the number of columns in the covariates object.

delta

a discount factor related to the evolution variances. Recommended values between 0.85<delta<1. delta=1 will yield results similar to the classical general linear model.

S0

prior covariance structure among voxels within every cluster at t=0. S0=1 is the default value when no prior information is available and defines an \(q\times q\) identity matrix. For the case of available prior information, S0 can be defined as an \(q\times q\) matrix, where \(q\) is the common number of voxels in every cluster.

n0

a positive hyperparameter of the prior distribution for the covariance matrix S0 at t=0 (n0=1 is the default value when no prior information is available). For the case of available prior information, n0 can be set as n0=np, where np is the number of MRI images in the pilot sample.

N1

is the number of images (2<N1<T) from the ffdc array employed in the model fitting. N1=NULL (or equivalently N1=T) is its default value, taking all the images in the ffdc array for the fitting process.

Nsimu1

is the number of simulated on-line trajectories related to the state parameters. These simulated curves are later employed to compute the posterior probability of voxel activation.

Cutpos1

a cutpoint time from where the on-line trajectories begin. This parameter value is related to an approximation from a t-student distribution to a normal distribution. Values equal to or greater than 30 are recommended (30<Cutpos1<T).

r1

a positive integer number that defines the distance from every voxel with its most distant neighbor. This value determines the size of the cluster. The users can set a range of different r1 values: \(r1 = 0, 1, 2, 3, 4\), which leads to \(q = 1, 7, 19, 27, 33\), where \(q\) is the size of the cluster.

perVol

helps to define a threshold for the voxels considered in the analysis. For example, Min.vol = 0.10 means that all the voxels with values below to max(ffdc)*perVol can be considered irrelevant and discarded from the analysis.

Ncores

a positive integer indicating the number of threads or cores to be used in the computation of the activation maps.

seed

random seed.

Details

Every voxel from the 4D array image is clustered with its nearest neighbors. There are as many clusters as voxels in the image. Then, activation maps are obtained by fitting a multivariate dynamic linear model on every cluster of voxels. The resulting activation evidence measure for every voxel is obtained by using the Forward State Trajectories Sampler (FSTS) algorithm. To deeply understand the method implemented in this package, a reading of (Cardona-Jiménez and de B. Pereira 2021) and (Cardona-Jiménez 2021) is mandatory.

Value

It returns a list of the form [[k]][p,x,y,z], where k defines the type of test (k = 1 for "Marginal", k = 2 for "JointTest", and k = 3 for "LTT"), p represents the column position in the covariates matrix and x,y,z represent the voxel position in the brain image.

References

Cardona-Jiménez J, de B. Pereira CA (2021). “Assessing dynamic effects on a Bayesian matrix-variate dynamic linear model: An application to task-based fMRI data analysis.” Computational Statistics & Data Analysis, 163, 107297. ISSN 0167-9473, doi:10.1016/j.csda.2021.107297, https://www.sciencedirect.com/science/article/pii/S0167947321001316.

Cardona-Jiménez J (2021). “BayesDLMfMRI: Bayesian Matrix-Variate Dynamic Linear Models for Task-based fMRI Modeling in R.” arXiv e-prints, arXiv–2111.

Examples

## Not run: 
fMRI.data  <- get_example_fMRI_data()
data("covariates", package="BayesDLMfMRI")
res <- ffdEvidenceFSTS(ffdc = fMRI.data, covariates = Covariates, m0=0, Cova=100,
                       delta=0.95, S0=1, n0=1, N1=FALSE, 
                       Nsimu1 = 100, Cutpos1=30, r1 = 1,
                       perVol = 0.10, Ncores=3)
str(res)

## End(Not run)

ffdGroupEvidenceFETS

Description

This function can be used to build activation maps for group task-based fMRI data.

Usage

ffdGroupEvidenceFETS(
  ffdGroup,
  covariates,
  m0 = 0,
  Cova = 100,
  delta = 0.95,
  S0 = 1,
  n0 = 1,
  N1 = FALSE,
  Nsimu1 = 100,
  Cutpos = 30,
  r1,
  Test,
  mask,
  Ncores = NULL
)

Arguments

ffdGroup

list of N elements, each being a 4D array (ffdc[i,j,k,t]) that contains the sequence of MRI images related to each of the N subjects in the sample.

covariates

a data frame or matrix whose columns contain the covariates related to the expected BOLD response obtained from the experimental setup.

m0

the constant prior mean value for the covariates parameters and common to all voxels within every neighborhood at t=0 (m=0 is the default value when no prior information is available). For the case of available prior information, m0 can be defined as a \(p\times q\) matrix, where \(p\) is the number of columns in the covariates object and \(q\) is the cluster size.

Cova

a positive constant that defines the prior variances for the covariates parameters at t=0 (Cova=100 is the default value when no prior information is available). For the case of available prior information, Cova can be defined as a pXp matrix, where p is the number of columns in the covariates object.

delta

a discount factor related to the evolution variances. Recommended values between 0.85<delta<1. delta=1 will yield results similar to the classical general linear model.

S0

prior covariance structure between pair of voxels within every cluster at t=0. S0=1 is the default value when no prior information is available and defines an \(q\times q\) identity matrix. For the case of available prior information, S0 can be defined as an \(q \times q\) matrix, where \(q\) is the common number of voxels in every cluster.

n0

a positive hyperparameter of the prior distribution for the covariance matrix S0 at \(t=0\) (n1=1 is the default value when no prior information is available). For the case of available prior information, n0 can be set as n0=np, where np is the number of MRI images in the pilot sample.

N1

is the number of images (2<N1<T) from the ffdc array employed in the model fitting. N1=NULL (or equivalently N1=T) is its default value, taking all the images in the ffdc array for the fitting process.

Nsimu1

is the number of simulated on-line trajectories related to the state parameters. These simulated curves are later employed to compute the posterior probability of voxel activation.

Cutpos

a cutpoint time from where the on-line trajectories begin. This parameter value is related to an approximation from a t-student distribution to a normal distribution. Values equal to or greater than 30 are recommended (30<Cutpos1<T).

r1

positive integer number that defines the distance from every voxel with its most distant neighbor. This value determines the size of the cluster. The users can set a range of different r1 values: \(r1 = 0, 1, 2, 3, 4\), which leads to \(q = 1, 7, 19, 27, 33\), where \(q\) is the size of the cluster.

Test

test type either "LTT" (Average cluster effect) or "JointTest" (Joint effect).

mask

a 3D array that works as a brain of reference (MNI atlas) for the group analysis.

Ncores

a positive integer indicating the number of threads or cores to be used in the computation of the activation maps.

Details

A multivariate dynamic linear model is fitted in the same fashion as at the individual level for every subject in the sample. However, at this stage, the posterior distributions from all the subjects are combined to build a single one, which is then employed to compute the activation evidence maps for the group using Forward estimated trajectories sampler (FETS) algorithm. To deeply understand the method implemented in this package, a reading of (Cardona-Jiménez and de B. Pereira 2021) and (Cardona-Jiménez 2021) is mandatory.

Value

It returns a list of \(2 \times p\) elements, where \(p\) is the number of covariates, and 2 is the number of options evaluated as sampler distributions: Average cluster effect and Marginal effect (when Test=="LTT") or Joint effect and Marginal effect (when Test=="JointTest"). The first p elements from the list are the activation maps related to each column of the covariates matrix respectively when computing the activation evidence using either Test=="LTT" or Test=="JointTest". The remaining activation maps are those associated with the marginal distribution.

References

Cardona-Jiménez J, de B. Pereira CA (2021). “Assessing dynamic effects on a Bayesian matrix-variate dynamic linear model: An application to task-based fMRI data analysis.” Computational Statistics & Data Analysis, 163, 107297. ISSN 0167-9473, doi:10.1016/j.csda.2021.107297, https://www.sciencedirect.com/science/article/pii/S0167947321001316.

Cardona-Jiménez J (2021). “BayesDLMfMRI: Bayesian Matrix-Variate Dynamic Linear Models for Task-based fMRI Modeling in R.” arXiv e-prints, arXiv–2111.

Examples

## Not run: 
DatabaseGroup <- get_example_fMRI_data_group()
data("covariates", package="BayesDLMfMRI")
data("mask", package="BayesDLMfMRI")
res <- ffdGroupEvidenceFETS(ffdGroup = DatabaseGroup, covariates = Covariates, 
                            m0 = 0, Cova = 100, delta = 0.95, S0 = 1, 
                            n0 = 1, N1 = FALSE, Nsimu1 = 100, Cutpos=30, 
                            r1 = 1, Test = "JointTest", mask = mask, Ncores = 7)
str(res)

## End(Not run)

ffdGroupEvidenceFFBS

Description

This function can be used to build activation maps for group task-based fMRI data.

Usage

ffdGroupEvidenceFFBS(
  ffdGroup,
  covariates,
  m0 = 0,
  Cova = 100,
  delta = 0.95,
  S0 = 1,
  n0 = 1,
  N1 = FALSE,
  Nsimu1 = 100,
  Cutpos = 30,
  r1,
  mask,
  Ncores = NULL
)

Arguments

ffdGroup

list of N elements, each being a 4D array (ffdc[i,j,k,t]) that contains the sequence of MRI images related to each of the N subjects in the sample.

covariates

a data frame or matrix whose columns contain the covariates related to the expected BOLD response obtained from the experimental setup

m0

the constant prior mean value for the covariates parameters and common to all voxels within every neighborhood at t=0 (m=0 is the default value when no prior information is available). For the case of available prior information, m0 can be defined as a \(p\times q\) matrix, where \(p\) is the number of columns in the covariates object and \(q\) is the cluster size.

Cova

a positive constant that defines the prior variances for the covariates parameters at t=0 (Cova=100 is the default value when no prior information is available). For the case of available prior information, Cova can be defined as a \(p\times p\) matrix, where \(p\) is the number of columns in the covariates object.

delta

a discount factor related to the evolution variances. Recommended values between 0.85<delta<1. delta=1 will yield results similar to the classical general linear model.

S0

prior covariance structure between pair of voxels within every cluster at t=0. S0=1 is the default value when no prior information is available and defines an \(q\times q\) identity matrix. For the case of available prior information, S0 can be defined as an \(q\times q\) matrix, where \(q\) is the common number of voxels in every cluster.

n0

a positive hyperparameter of the prior distribution for the covariance matrix S0 at \(t=0\) (n1=1 is the default value when no prior information is available). For the case of available prior information, n0 can be set as n0=np, where np is the number of MRI images in the pilot sample.

N1

is the number of images (2<N1<T) from the ffdc array employed in the model fitting. N1=NULL (or equivalently N1=T) is its default value, taking all the images in the ffdc array for the fitting process.

Nsimu1

is the number of simulated on-line trajectories related to the state parameters. These simulated curves are later employed to compute the posterior probability of voxel activation.

Cutpos

a cutpoint time from where the on-line trajectories begin. This parameter value is related to an approximation from a t-student distribution to a normal distribution. Values equal to or greater than 30 are recommended (30<Cutpos1<T).

r1

positive integer number that defines the distance from every voxel with its most distant neighbor. This value determines the size of the cluster. The users can set a range of different r1 values: \(r1 = 0, 1, 2, 3, 4\), which leads to \(q = 1, 7, 19, 27, 33\), where \(q\) is the size of the cluster.

mask

a 3D array that works as a brain of reference (MNI atlas) for the group analysis.

Ncores

a postive integer indicating the number of threads or cores to be used in the computation of the activation maps.

Details

A multivariate dynamic linear model is fitted in the same fashion as at the individual level for every subject in the sample. However, at this stage, the posterior distributions from all the subjects are combined to build a single one, which is then employed to compute the activation evidence maps for the group using the Forward Filtering Backward Sampling (FFBS) algorithm. To deeply understand the method implemented in this package, a reading of (Cardona-Jiménez and de B. Pereira 2021) and (Cardona-Jiménez 2021) is mandatory.

Value

It returns a list of the form [[k]][p,x,y,z], where k defines the type of test (k = 1 for Marginal effect, k = 2 for Joint effect, and k = 3 for Average cluster effect), p represents the column position in the covariates matrix and x,y,z represent the voxel position in the brain image.

References

Cardona-Jiménez J, de B. Pereira CA (2021). “Assessing dynamic effects on a Bayesian matrix-variate dynamic linear model: An application to task-based fMRI data analysis.” Computational Statistics & Data Analysis, 163, 107297. ISSN 0167-9473, doi:10.1016/j.csda.2021.107297, https://www.sciencedirect.com/science/article/pii/S0167947321001316.

Cardona-Jiménez J (2021). “BayesDLMfMRI: Bayesian Matrix-Variate Dynamic Linear Models for Task-based fMRI Modeling in R.” arXiv e-prints, arXiv–2111.

Examples

## Not run: 
# This example can take a long time to run.
DatabaseGroup <- get_example_fMRI_data_group()
data("covariates", package="BayesDLMfMRI")
res <- ffdGroupEvidenceFFBS(ffdGroup = DatabaseGroup, covariates = Covariates, 
                            m0=0, Cova=100, delta = 0.95, 
                            S0 = 1, n0 = 1, N1 = FALSE, Nsimu1 = 100,
                            Cutpos = 30, r1 = 1, mask = MASK, Ncores = 7)
str(res)

## End(Not run)

ffdGroupEvidenceFSTS

Description

This function can be used to build activation maps for group task-based fMRI data.

Usage

ffdGroupEvidenceFSTS(
  ffdGroup,
  covariates,
  m0 = 0,
  Cova = 100,
  delta = 0.95,
  S0 = 1,
  n0 = 1,
  N1 = FALSE,
  Nsimu1 = 100,
  Cutpos = 30,
  r1,
  mask,
  Ncores = NULL
)

Arguments

ffdGroup

list of N elements, each being a 4D array (ffdc[i,j,k,t]) that contains the sequence of MRI images related to each of the N subjects in the sample.

covariates

a data frame or matrix whose columns contain the covariates related to the expected BOLD response obtained from the experimental setup

m0

the constant prior mean value for the covariates parameters and common to all voxels within every neighborhood at t=0 (m=0 is the default value when no prior information is available). For the case of available prior information, m0 can be defined as a \(p\times q\) matrix, where \(p\) is the number of columns in the covariates object and \(q\) is the cluster size.

Cova

a positive constant that defines the prior variances for the covariates parameters at t=0 (Cova=100 is the default value when no prior information is available). For the case of available prior information, Cova can be defined as a \(p\times p\) matrix, where \(p\) is the number of columns in the covariates object.

delta

a discount factor related to the evolution variances. Recommended values between 0.85<delta<1. delta=1 will yield results similar to the classical general linear model.

S0

prior covariance structure between pair of voxels within every cluster at t=0. S0=1 is the default value when no prior information is available and defines an \(q\times q\) identity matrix. For the case of available prior information, S0 can be defined as an \(q \times q\) matrix, where \(q\) is the common number of voxels in every cluster.

n0

a positive hyperparameter of the prior distribution for the covariance matrix S0 at t=0 (n1=1 is the default value when no prior information is available). For the case of available prior information, n0 can be set as n0=np, where np is the number of MRI images in the pilot sample.

N1

is the number of images (2<N1<T) from the ffdc array employed in the model fitting. N1=NULL (or equivalently N1=T) is its default value, taking all the images in the ffdc array for the fitting process.

Nsimu1

is the number of simulated on-line trajectories related to the state parameters. These simulated curves are later employed to compute the posterior probability of voxel activation.

Cutpos

a cutpoint time from where the on-line trajectories begin. This parameter value is related to an approximation from a t-student distribution to a normal distribution. Values equal to or greater than 30 are recommended (30<Cutpos1<T).

r1

a positive integer number that defines the distance from every voxel with its most distant neighbor. This value determines the size of the cluster. The users can set a range of different r1 values: \(r1 = 0, 1, 2, 3, 4\), which leads to \(q = 1, 7, 19, 27, 33\), where \(q\) is the size of the cluster.

mask

3D array that works as a brain of reference (MNI atlas) for the group analysis.

Ncores

a postive integer indicating the number of threads or cores to be used in the computation of the activation maps.

Details

A multivariate dynamic linear model is fitted in the same fashion as at the individual level for every subject in the sample. However, at this stage, the posterior distributions from all the subjects are combined to build a single one, which is then employed to compute the activation evidence maps for the group using the Forward State Trajectories Sampler (FSTS) algorithm To deeply understand the method implemented in this package, a reading of (Cardona-Jiménez and de B. Pereira 2021) and (Cardona-Jiménez 2021) is mandatory.

Value

It returns a list of the form [[k]][p,x,y,z], where k defines the type of test (k = 1 for Marginal effect, k = 2 for Joint effect, and k = 3 for Average cluster effect), p represents the column position in the covariates matrix and x,y,z represent the voxel position in the brain image.

Examples

## Not run: 
# This example can take a long time to run.
DatabaseGroup <- get_example_fMRI_data_group()
data("covariates", package="BayesDLMfMRI")
res <- ffdGroupEvidenceFSTS(ffdGroup = DatabaseGroup, covariates = Covariates, 
                            m0 = 0, Cova = 100, delta = 0.95, S0 = 1, 
                            n0 = 1, N1 = FALSE, Nsimu1 = 100, Cutpos=30, 
                            r1 = 1, mask = MASK, Ncores = 7)
str(res)

## End(Not run)

get_example_fMRI_data

Description

This function is used to download the example data used in the Vignettes.

Usage

get_example_fMRI_data(save_path = NULL, force = FALSE, subject = 1)

Arguments

save_path

location where the data the example data is stored.

force

force the download, even if the data already exists.

subject

The example subject, must be 1 or 2.

Details

The data for this example is related to an fMRI experiment where a sound stimulus is presented. That experiment is intended to offer a "voice localizer" scan, which allows rapid and reliable localization of the voice-sensitive "temporal voice areas" (TVA) of the human auditory cortex (Pernet et al. 2015). The data of this "voice localizer" scan is freely available on the online platform OpenNEURO (Gorgolewski et al. 2017).

Value

It returns an array of dimensions [91, 109, 91, 310].

References

Pernet CR, McAleer P, Latinus M, Gorgolewski KJ, Charest I, Bestelmeyer PE, Watson RH, Fleming D, Crabbe F, Valdes-Sosa M, others (2015). “The human voice areas: Spatial organization and inter-individual variability in temporal and extra-temporal cortices.” Neuroimage, 119, 164–174.

Gorgolewski K, Esteban O, Schaefer G, Wandell B, Poldrack R (2017). “OpenNeuro - a free online platform for sharing and analysis of neuroimaging data.” Organization for Human Brain Mapping. Vancouver, Canada, 1677.

Examples

## Not run: 
# This example can take a long time to run.
fMRI.data  <- get_example_fMRI_data()

## End(Not run)

get_example_fMRI_data_group

Description

This function is used to download the example data used in the Vignettes.

Usage

get_example_fMRI_data_group(save_path = NULL, force = FALSE)

Arguments

save_path

location where the data the example data is stored.

force

force the download, even if the data already exists.

Details

The data for this example is related to an fMRI experiment where a sound stimulus is presented. That experiment is intended to offer a "voice localizer" scan, which allows rapid and reliable localization of the voice-sensitive "temporal voice areas" (TVA) of the human auditory cortex (Pernet et al. 2015). The data of this "voice localizer" scan is freely available on the online platform OpenNEURO (Gorgolewski et al. 2017).

Value

It returns a list in which each element is an array of dimensions [91, 109, 91, 310].

References

Pernet CR, McAleer P, Latinus M, Gorgolewski KJ, Charest I, Bestelmeyer PE, Watson RH, Fleming D, Crabbe F, Valdes-Sosa M, others (2015). “The human voice areas: Spatial organization and inter-individual variability in temporal and extra-temporal cortices.” Neuroimage, 119, 164–174.

Gorgolewski K, Esteban O, Schaefer G, Wandell B, Poldrack R (2017). “OpenNeuro - a free online platform for sharing and analysis of neuroimaging data.” Organization for Human Brain Mapping. Vancouver, Canada, 1677.

Examples

## Not run: 
# This example can take a long time to run.
DatabaseGroup <- get_example_fMRI_data_group()

## End(Not run)

GroupSingleVoxelFETS

Description

This function is used to perform a group activation analysis for single voxels based on the FETS algorithm.

Usage

GroupSingleVoxelFETS(
  posi.ffd,
  DatabaseGroup,
  covariates,
  m0,
  Cova,
  delta,
  S0,
  n0,
  N1,
  Nsimu1,
  r1,
  Test,
  Cutpos
)

Arguments

posi.ffd

the position of the voxel in the brain image.

DatabaseGroup

list of N elements, each being a 4D array (ffdc[i,j,k,t]) that contains the sequence of MRI images related to each of the N subjects in the sample.

covariates

a data frame or matrix whose columns contain the covariates related to the expected BOLD response obtained from the experimental setup.

m0

the constant prior mean value for the covariates parameters and common to all voxels within every neighborhood at t=0 (m=0 is the default value when no prior information is available). For the case of available prior information, m0 can be defined as a \(p\times q\) matrix, where \(p\) is the number of columns in the covariates object and \(q\) is the cluster size.

Cova

a positive constant that defines the prior variances for the covariates parameters at t=0 (Cova=100 is the default value when no prior information is available). For the case of available prior information, Cova can be defined as a \(p \times p\) matrix, where \(p\) is the number of columns in the covariates object.

delta

a discount factor related to the evolution variances. Recommended values between 0.85<delta<1. delta=1 will yield results similar to the classical general linear model.

S0

prior covariance structure between pair of voxels within every cluster at t=0. S0=1 is the default value when no prior information is available and defines an \(q \times q\) identity matrix. For the case of available prior information, S0 can be defined as an \(q \times q\) matrix, where \(q\) is the common number of voxels in every cluster.

n0

a positive hyperparameter of the prior distribution for the covariance matrix S0 at t=0 (n1=1 is the default value when no prior information is available). For the case of available prior information, n0 can be set as n0=np, where np is the number of MRI images in the pilot sample.

N1

is the number of images (2<N1<T) from the ffdc array employed in the model fitting. N1=NULL (or equivalently N1=T) is its default value, taking all the images in the ffdc array for the fitting process.

Nsimu1

is the number of simulated on-line trajectories related to the state parameters. These simulated curves are later employed to compute the posterior probability of voxel activation.

r1

a positive integer number that defines the distance from every voxel with its most distant neighbor. This value determines the size of the cluster. The users can set a range of different r1 values: \(r1 = 0, 1, 2, 3, 4\), which leads to \(q = 1, 7, 19, 27, 33\), where \(q\) is the size of the cluster.

Test

test type either "LTT" (Average cluster effect) or "JointTest" (Joint effect).

Cutpos

a cutpoint time from where the on-line trajectories begin. This parameter value is related to an approximation from a t-student distribution to a normal distribution. Values equal to or greater than 30 are recommended (30<Cutpos1<T).

Details

This function allows the performance of a group activation analysis for single voxels. A multivariate dynamic linear model is fitted to a cluster of voxels, with its center at location (i,j,k), in the way it is presented in (Cardona-Jiménez and de B. Pereira 2021).

Value

a list containing a vector (Evidence) with the evidence measure of activation for each of the p covariates considered in the model, the simulated online trajectories related to the state parameter, the simulated BOLD responses, \(\hat{Y}\)ascii. and a measure to examine the goodness of fit of the model \((100 \ast |Y[i,j,k]_t - \hat{Y}[i,j,k]_t | \hat{Y}[i,j,k]_t )\) for that particular voxel (FitnessV).

References

Cardona-Jiménez J, de B. Pereira CA (2021). “Assessing dynamic effects on a Bayesian matrix-variate dynamic linear model: An application to task-based fMRI data analysis.” Computational Statistics & Data Analysis, 163, 107297. ISSN 0167-9473, doi:10.1016/j.csda.2021.107297, https://www.sciencedirect.com/science/article/pii/S0167947321001316.

Cardona-Jiménez J (2021). “BayesDLMfMRI: Bayesian Matrix-Variate Dynamic Linear Models for Task-based fMRI Modeling in R.” arXiv e-prints, arXiv–2111.

Examples

## Not run: 
# This example can take a long time to run.
DatabaseGroup <- get_example_fMRI_data_group()
data("covariates", package="BayesDLMfMRI")
resSingle <- GroupSingleVoxelFETS(posi.ffd = c(14, 56, 40), DatabaseGroup,
                                  covariates = Covariates, m0 = 0, Cova = 100, 
                                  delta = 0.95, S0 = 1, n0 = 1, N1 = FALSE, 
                                  Nsimu1 = 100, r1 = 1, Test = "JointTest", Cutpos = 30)

## End(Not run)

GroupSingleVoxelFFBS

Description

This function is used to perform a group activation analysis for single voxels based on the FFBS algorithm.

Usage

GroupSingleVoxelFFBS(
  posi.ffd,
  DatabaseGroup,
  covariates,
  m0,
  Cova,
  delta,
  S0,
  n0,
  N1,
  Nsimu1,
  r1,
  Cutpos
)

Arguments

posi.ffd

the position of the voxel in the brain image.

DatabaseGroup

list of N elements, each being a 4D array (ffdc[i,j,k,t]) that contains the sequence of MRI images related to each of the N subjects in the sample.

covariates

a data frame or matrix whose columns contain the covariates related to the expected BOLD response obtained from the experimental setup.

m0

the constant prior mean value for the covariates parameters and common to all voxels within every neighborhood at t=0 (m0=0 is the default value when no prior information is available). For the case of available prior information, m0 can be defined as a \(p\times q\) matrix, where \(p\) is the number of columns in the covariates object and \(q\) is the cluster size.

Cova

a positive constant that defines the prior variances for the covariates parameters at t=0 (Cova=100 is the default value when no prior information is available). For the case of available prior information, Cova can be defined as a \(p \times p\) matrix, where p is the number of columns in the covariates object.

delta

a discount factor related to the evolution variances. Recommended values between 0.85<delta<1. delta=1 will yield results similar to the classical general linear model.

S0

prior covariance structure between pair of voxels within every cluster at t=0, S0=1 is the default value when no prior information is available and defines an \(q\times q\) identity matrix. For the case of available prior information, S0 can be defined as an \(q \times q\) matrix, where \(q\) is the common number of voxels in every cluster.

n0

a positive hyperparameter of the prior distribution for the covariance matrix S0 at t=0 (n1=1 is the default value when no prior information is available). For the case of available prior information, n0 can be set as n0=np, where np is the number of MRI images in the pilot sample.

N1

is the number of images (2<N1<T) from the ffdc array employed in the model fitting. N1=NULL (or equivalently N1=T) is its default value, taking all the images in the ffdc array for the fitting process.

Nsimu1

is the number of simulated on-line trajectories related to the state parameters. These simulated curves are later employed to compute the posterior probability of voxel activation.

r1

a positive integer number that defines the distance from every voxel with its most distant neighbor. This value determines the size of the cluster. The users can set a range of different r1 values: \(r1 = 0, 1, 2, 3, 4\), which leads to \(q = 1, 7, 19, 27, 33\), where \(q\) is the size of the cluster.

Cutpos

a cutpoint time from where the on-line trajectories begin. This parameter value is related to an approximation from a t-student distribution to a normal distribution. Values equal to or greater than 30 are recommended (30<Cutpos1<T).

Details

This function allows the performance of a group activation analysis for single voxels. A multivariate dynamic linear model is fitted to a cluster of voxels, with its center at location (i,j,k), in the way it is presented in (Cardona-Jiménez and de B. Pereira 2021).

Value

a list containing a vector (Evidence) with the evidence measure of activation for each of the p covariates considered in the model, the simulated online trajectories related to the state parameter, the simulated BOLD responses, and a measure to examine the goodness of fit of the model \((100 \ast |Y[i,j,k]_t - \hat{Y}[i,j,k]_t |/ \hat{Y}[i,j,k]_t )\) for that particular voxel (FitnessV).

References

Cardona-Jiménez J, de B. Pereira CA (2021). “Assessing dynamic effects on a Bayesian matrix-variate dynamic linear model: An application to task-based fMRI data analysis.” Computational Statistics & Data Analysis, 163, 107297. ISSN 0167-9473, doi:10.1016/j.csda.2021.107297, https://www.sciencedirect.com/science/article/pii/S0167947321001316.

Cardona-Jiménez J (2021). “BayesDLMfMRI: Bayesian Matrix-Variate Dynamic Linear Models for Task-based fMRI Modeling in R.” arXiv e-prints, arXiv–2111.

Examples

## Not run: 
# This example can take a long time to run.
DatabaseGroup <- get_example_fMRI_data_group()
data("covariates", package="BayesDLMfMRI")
resSingle <- GroupSingleVoxelFFBS(posi.ffd = c(14, 56, 40), DatabaseGroup,
                                  covariates = Covariates, m0 = 0, Cova = 100, 
                                  delta = 0.95, S0 = 1, n0 = 1, N1 = FALSE, 
                                  Nsimu1 = 100, r1 = 1, Cutpos = 30)

## End(Not run)

GroupSingleVoxelFSTS

Description

This function is used to perform a group activation analysis for single voxels based on the FSTS algorithm.

Usage

GroupSingleVoxelFSTS(
  posi.ffd,
  DatabaseGroup,
  covariates,
  m0,
  Cova,
  delta,
  S0,
  n0,
  N1,
  Nsimu1,
  r1,
  Cutpos
)

Arguments

posi.ffd

the position of the voxel in the brain image.

DatabaseGroup

list of N elements, each being a 4D array (ffdc[i,j,k,t]) that contains the sequence of MRI images related to each of the N subjects in the sample.

covariates

a data frame or matrix whose columns contain the covariates related to the expected BOLD response obtained from the experimental setup.

m0

the constant prior mean value for the covariates parameters and common to all voxels within every neighborhood at t=0 (m0=0 is the default value when no prior information is available). For the case of available prior information, m0 can be defined as a \(p\times q\) matrix, where \(p\) is the number of columns in the covariates object and \(q\) is the cluster size.

Cova

a positive constant that defines the prior variances for the covariates parameters at t=0 (Cova=100 is the default value when no prior information is available). For the case of available prior information, Cova can be defined as a \(p\times p\) matrix, where p is the number of columns in the covariates object.

delta

a discount factor related to the evolution variances. Recommended values between 0.85<delta<1. delta=1 will yield results similar to the classical general linear model.

S0

prior covariance structure between pair of voxels within every cluster at t=0, S0=1 is the default value when no prior information is available and defines an \(q\times q\) identity matrix. For the case of available prior information, S0 can be defined as an \(q \times q\) matrix, where \(q\) is the common number of voxels in every cluster.

n0

a positive hyperparameter of the prior distribution for the covariance matrix S0 at t=0 (n1=1 is the default value when no prior information is available). For the case of available prior information, n0 can be set as n0=np, where np is the number of MRI images in the pilot sample.

N1

is the number of images (2<N1<T) from the ffdc array employed in the model fitting. N1=NULL (or equivalently N1=T) is its default value, taking all the images in the ffdc array for the fitting process.

Nsimu1

is the number of simulated on-line trajectories related to the state parameters. These simulated curves are later employed to compute the posterior probability of voxel activation.

r1

a positive integer number that defines the distance from every voxel with its most distant neighbor. This value determines the size of the cluster. The users can set a range of different r1 values: \(r1 = 0, 1, 2, 3, 4\), which leads to \(q = 1, 7, 19, 27, 33\), where \(q\) is the size of the cluster.

Cutpos

a cutpoint time from where the on-line trajectories begin. This parameter value is related to an approximation from a t-student distribution to a normal distribution. Values equal to or greater than 30 are recommended (30<Cutpos1<T).

Details

This function allows the performance of a group activation analysis for single voxels. A multivariate dynamic linear model is fitted to a cluster of voxels, with its center at location (i,j,k), in the way it is presented in (Cardona-Jiménez and de B. Pereira 2021).

Value

a list containing a vector (Evidence) with the evidence measure of activation for each of the p covariates considered in the model, the simulated online trajectories related to the state parameter, the simulated BOLD responses, and a measure to examine the goodness of fit of the model \((100 \ast |Y[i,j,k]_t - \hat{Y}[i,j,k]_t |/ \hat{Y}[i,j,k]_t )\) for that particular voxel (FitnessV).

References

Cardona-Jiménez J, de B. Pereira CA (2021). “Assessing dynamic effects on a Bayesian matrix-variate dynamic linear model: An application to task-based fMRI data analysis.” Computational Statistics & Data Analysis, 163, 107297. ISSN 0167-9473, doi:10.1016/j.csda.2021.107297, https://www.sciencedirect.com/science/article/pii/S0167947321001316.

Cardona-Jiménez J (2021). “BayesDLMfMRI: Bayesian Matrix-Variate Dynamic Linear Models for Task-based fMRI Modeling in R.” arXiv e-prints, arXiv–2111.

Examples

## Not run: 
# This example can take a long time to run.
DatabaseGroup <- get_example_fMRI_data_group()
data("covariates", package="BayesDLMfMRI")
resSingle <- GroupSingleVoxelFSTS(posi.ffd = c(14, 56, 40), DatabaseGroup,
                                  covariates = Covariates, m0 = 0, Cova = 100, 
                                  delta = 0.95, S0 = 1, n0 = 1, N1 = FALSE, 
                                  Nsimu1 = 100, r1 = 1, Cutpos = 30)

## End(Not run)

A 3D array that works as a brain of reference (MNI atlas).

Description

A 3D array that works as a brain of reference (MNI atlas) for the group analysis.

Usage

mask

Format

An object of class nifti of dimension 91 x 109 x 91.

Examples

data("mask", package="BayesDLMfMRI")

plot.fMRI_single_evidence

Description

Plot function

Usage

## S3 method for class 'fMRI_single_evidence'
plot(x, overlay, index, index2 = NULL, ...)

Arguments

x

is the returned value of any of the ffdEvidence* functions.

overlay

MNI image used to plot posterior probability maps.

index

the element of res to be plotted.

index2

the element of res to be plotted, only used if needed.

...

additional parameters passed to the ortho2 function.

Details

Plot function

Examples

## Not run: 
fMRI.data  <- get_example_fMRI_data()
data("covariates", package="BayesDLMfMRI")
data("ffd", package="BayesDLMfMRI") # used for overlay.
res <- ffdEvidenceFETS(ffdc = fMRI.data,
                   covariates = Covariates,
                   m0 = 0, Cova = 100, delta = 0.95,
                   S0 = 1, n0 = 1, Nsimu1 = 100, Cutpos1 = 30,
                   r1 = 1, Test = "LTT", Ncores = 15)
plot(res, overlay=ffd, index=1, col.y = heat.colors(50), 
     ycolorbar = TRUE, ybreaks = seq(0.95, 1, by = 0.001))

## End(Not run)

print.fMRI_group_evidence

Description

Print the structure of the object related to the ffdGroupEvidence* functions.

Usage

## S3 method for class 'fMRI_group_evidence'
print(x, ...)

Arguments

x

is the returned value of any of the ffdGroupEvidence* functions

...

Other potential arguments

Details

Print the structure of the object related to the ffdGroupEvidence* functions.

Examples

## Not run: 
DatabaseGroup <- get_example_fMRI_data_group()
data("covariates", package="BayesDLMfMRI")
data("mask", package="BayesDLMfMRI")
res <- ffdGroupEvidenceFETS(ffdGroup = DatabaseGroup, covariates = Covariates, 
                            m0 = 0, Cova = 100, delta = 0.95, S0 = 1, 
                            n0 = 1, N1 = FALSE, Nsimu1 = 100, Cutpos=30, 
                            r1 = 1, Test = "JointTest", mask = mask, Ncores = 7)
print(res)

## End(Not run)

print.fMRI_group_single_voxel

Description

Print the structure of the object related to the SingleVoxel* functions.

Usage

## S3 method for class 'fMRI_group_single_voxel'
print(x, ...)

Arguments

x

is the returned value of any of the GroupSingleVoxel* functions

...

Other potential arguments

Details

Print the structure of the object related to the GroupSingleVoxel* functions.

Examples

## Not run: 
DatabaseGroup <- get_example_fMRI_data_group()
data("covariates", package="BayesDLMfMRI")
res <- GroupSingleVoxelFFBS(posi.ffd = c(14, 56, 40), DatabaseGroup,
                            covariates = Covariates, m0 = 0, Cova = 100, 
                            delta = 0.95, S0 = 1, n0 = 1, N1 = FALSE, 
                            Nsimu1 = 100, r1 = 1, Cutpos = 30)
print(res)

## End(Not run)

print.fMRI_single_evidence

Description

Print the structure of the object related to the ffdEvidence* functions.

Usage

## S3 method for class 'fMRI_single_evidence'
print(x, ...)

Arguments

x

is the returned value of any of the ffdEvidence* functions

...

Other potential arguments

Details

Print the structure of the object related to the ffdEvidence* functions.

Examples

## Not run: 
fMRI.data  <- get_example_fMRI_data()
data("covariates", package="BayesDLMfMRI")
res <- ffdEvidenceFFBS(ffdc = fMRI.data, covariates = Covariates, m0=0, Cova=100,
                       delta=0.95, S0=1, n0=1, N1=FALSE, 
                       Nsimu1 = 100, Cutpos1=30, r1 = 1,
                       perVol = 0.10, Ncores=3)
print(res)

## End(Not run)

print.fMRI_single_voxel

Description

Print the structure of the object related to the SingleVoxel* functions.

Usage

## S3 method for class 'fMRI_single_voxel'
print(x, ...)

Arguments

x

is the returned value of any of the SingleVoxel* functions,

...

Other potential arguments

Details

Print the structure of the object related to the SingleVoxel* functions.

Examples

## Not run: 
fMRI.data  <- get_example_fMRI_data()
data("covariates", package="BayesDLMfMRI")
res.indi <- SingleVoxelFSTS(posi.ffd = c(14, 56, 40), 
                            covariates = Covariates,
                            ffdc =  fMRI.data, 
                            m0 = 0, Cova = 100, delta = 0.95, S0 = 1, 
                            n0 = 1, Nsimu1 = 100, N1 = N1, Cutpos1 = 30, 
                            Min.vol = 0.10, r1 = 1)
print(res.indi)

## End(Not run)

SingleVoxelFETS

Description

This function is used to perform an activation analysis for single voxels based on the FETS algorithm.

Usage

SingleVoxelFETS(
  posi.ffd,
  covariates,
  ffdc,
  m0,
  Cova,
  delta,
  S0,
  n0,
  N1,
  Nsimu1,
  Cutpos1,
  Min.vol,
  r1,
  Test
)

Arguments

posi.ffd

the position of the voxel in the brain image.

covariates

a data frame or matrix whose columns contain the covariates related to the expected BOLD response obtained from the experimental setup.

ffdc

a 4D array (ffdc[i,j,k,t]) that contains the sequence of MRI images that are meant to be analyzed. (i,j,k) define the position of the observed voxel at time t.

m0

the constant prior mean value for the covariates parameters and common to all voxels within every neighborhood at t=0 (m=0 is the default value when no prior information is available). For the case of available prior information, m0 can be defined as a \(p\times q\) matrix, where \(p\) is the number of columns in the covariates object and \(q\) is the cluster size.

Cova

a positive constant that defines the prior variances for the covariates parameters at t=0 (Cova=100 is the default value when no prior information is available). For the case of available prior information, Cova can be defined as a \(p \times p\) matrix, where \(p\) is the number of columns in the covariates object.

delta

a discount factor related to the evolution variances. Recommended values between 0.85<delta<1. delta=1 will yield results similar to the classical general linear model.

S0

prior covariance structure among voxels within every cluster at t=0. S0=1 is the default value when no prior information is available and defines an \(q\times q\) identity matrix. For the case of available prior information, S0 can be defined as an \(q\times q\) matrix, where \(q\) is the common number of voxels in every cluster.

n0

a positive hyperparameter of the prior distribution for the covariance matrix S0 at t=0 (n1=1 is the default value when no prior information is available). For the case of available prior information, n0 can be set as n0=np, where np is the number of MRI images in the pilot sample.

N1

is the number of images (2<N1<T) from the ffdc array employed in the model fitting. N1=NULL (or equivalently N1=T) is its default value, taking all the images in the ffdc array for the fitting process.

Nsimu1

is the number of simulated on-line trajectories related to the state parameters. These simulated curves are later employed to compute the posterior probability of voxel activation.

Cutpos1

a cutpoint time from where the on-line trajectories begin. This parameter value is related to an approximation from a t-student distribution to a normal distribution. Values equal to or greater than 30 are recommended (30<Cutpos1<T).

Min.vol

helps to define a threshold for the voxels considered in the analysis. For example, Min.vol = 0.10 means that all the voxels with values below to max(ffdc)*Min.vol can be considered irrelevant and discarded from the analysis.

r1

a positive integer number that defines the distance from every voxel with its most distant neighbor. This value determines the size of the cluster. The users can set a range of different r1 values: \(r1 = 0, 1, 2, 3, 4\), which leads to \(q = 1, 7, 19, 27, 33\), where \(q\) is the size of the cluster.

Test

test type either "LTT" (Average cluster effect) or "JointTest" (Joint effect).

Details

This function allows the development of an activation analysis for single voxels. A multivariate dynamic linear model is fitted to a cluster of voxels, with its center at location (i,j,k), in the way it is presented in (Cardona-Jiménez and de B. Pereira 2021).

Value

a list containing a vector (Evidence) with the evidence measure of activation for each of the p covariates considered in the model, the simulated online trajectories related to the state parameter, the simulated BOLD responses, and a measure to examine the goodness of fit of the model \((100 \ast |Y[i,j,k]_t - \hat{Y}[i,j,k]_t |/ \hat{Y}[i,j,k]_t )\) for that particular voxel (FitnessV).

References

Cardona-Jiménez J, de B. Pereira CA (2021). “Assessing dynamic effects on a Bayesian matrix-variate dynamic linear model: An application to task-based fMRI data analysis.” Computational Statistics & Data Analysis, 163, 107297. ISSN 0167-9473, doi:10.1016/j.csda.2021.107297, https://www.sciencedirect.com/science/article/pii/S0167947321001316.

Cardona-Jiménez J (2021). “BayesDLMfMRI: Bayesian Matrix-Variate Dynamic Linear Models for Task-based fMRI Modeling in R.” arXiv e-prints, arXiv–2111.

Examples

## Not run: 
# This example can take a long time to run.
fMRI.data  <- get_example_fMRI_data()
data("covariates", package="BayesDLMfMRI")
res.indi <- SingleVoxelFETS(posi.ffd = c(14, 56, 40), 
                            covariates = Covariates,
                            ffdc =  fMRI.data, 
                            m0 = 0, Cova = 100, delta = 0.95, S0 = 1, 
                            n0 = 1, Nsimu1 = 100, N1 = FALSE, Cutpos1 = 30, 
                            Min.vol = 0.10, r1 = 1, Test = "LTT")


## End(Not run)

SingleVoxelFFBS

Description

This function is used to perform an activation analysis for single voxels based on the FFBS algorithm.

Usage

SingleVoxelFFBS(
  posi.ffd,
  covariates,
  ffdc,
  m0,
  Cova,
  delta,
  S0,
  n0,
  N1,
  Nsimu1,
  Cutpos1,
  Min.vol,
  r1
)

Arguments

posi.ffd

the position of the voxel in the brain image.

covariates

a data frame or matrix whose columns contain the covariates related to the expected BOLD response obtained from the experimental setup.

ffdc

a 4D array (ffdc[i,j,k,t]) that contains the sequence of MRI images that are meant to be analyzed. (i,j,k) define the position of the observed voxel at time t.

m0

the constant prior mean value for the covariates parameters and common to all voxels within every neighborhood at t=0 (m=0 is the default value when no prior information is available). For the case of available prior information, m0 can be defined as a \(p\times q\) matrix, where \(p\) is the number of columns in the covariates object and \(q\) is the cluster size.

Cova

a positive constant that defines the prior variances for the covariates parameters at t=0 (Cova=100 is the default value when no prior information is available). For the case of available prior information, Cova can be defined as a \(p\times p\) matrix, where \(p\) is the number of columns in the covariates object.

delta

a discount factor related to the evolution variances. Recommended values between 0.85<delta<1. delta=1 will yield results similar to the classical general linear model.

S0

prior covariance structure among voxels within every cluster at t=0. S0=1 is the default value when no prior information is available and defines an \(q\times q\) identity matrix. For the case of available prior information, S0 can be defined as an \(q\times q\) matrix, where \(q\) is the common number of voxels in every cluster.

n0

a positive hyperparameter of the prior distribution for the covariance matrix S0 at t=0 (n1=1 is the default value when no prior information is available). For the case of available prior information, n0 can be set as n0=np, where np is the number of MRI images in the pilot sample.

N1

is the number of images (2<N1<T) from the ffdc array employed in the model fitting. N1=NULL (or equivalently N1=T) is its default value, taking all the images in the ffdc array for the fitting process.

Nsimu1

is the number of simulated on-line trajectories related to the state parameters. These simulated curves are later employed to compute the posterior probability of voxel activation.

Cutpos1

a cutpoint time from where the on-line trajectories begin. This parameter value is related to an approximation from a t-student distribution to a normal distribution. Values equal to or greater than 30 are recommended (30<Cutpos1<T).

Min.vol

helps to define a threshold for the voxels considered in the analysis. For example, Min.vol = 0.10 means that all the voxels with values below to max(ffdc)*Min.vol can be considered irrelevant and discarded from the analysis.

r1

a positive integer number that defines the distance from every voxel with its most distant neighbor. This value determines the size of the cluster. The users can set a range of different r1 values: \(r1 = 0, 1, 2, 3, 4\), which leads to \(q = 1, 7, 19, 27, 33\), where \(q\) is the size of the cluster.

Details

This function allows the development of an activation analysis for single voxels. A multivariate dynamic linear model is fitted to a cluster of voxels, with its center at location (i,j,k), in the way it is presented in (Cardona-Jiménez and de B. Pereira 2021).

Value

a list containing a vector (Evidence) with the evidence measure of activation for each of the p covariates considered in the model, the simulated online trajectories related to the state parameter, the simulated BOLD responses, and a measure to examine the goodness of fit of the model \((100 \ast |Y[i,j,k]_t - \hat{Y}[i,j,k]_t |/ \hat{Y}[i,j,k]_t )\) for that particular voxel (FitnessV).

References

Cardona-Jiménez J, de B. Pereira CA (2021). “Assessing dynamic effects on a Bayesian matrix-variate dynamic linear model: An application to task-based fMRI data analysis.” Computational Statistics & Data Analysis, 163, 107297. ISSN 0167-9473, doi:10.1016/j.csda.2021.107297, https://www.sciencedirect.com/science/article/pii/S0167947321001316.

Cardona-Jiménez J (2021). “BayesDLMfMRI: Bayesian Matrix-Variate Dynamic Linear Models for Task-based fMRI Modeling in R.” arXiv e-prints, arXiv–2111.

Examples

## Not run: 
# This example can take a long time to run.
fMRI.data  <- get_example_fMRI_data()
data("covariates", package="BayesDLMfMRI")
res.indi <- SingleVoxelFFBS(posi.ffd = c(14, 56, 40), 
                            covariates = Covariates,
                            ffdc =  fMRI.data, 
                            m0 = 0, Cova = 100, delta = 0.95, S0 = 1, 
                            n0 = 1, Nsimu1 = 100, N1 = FALSE, Cutpos1 = 30, 
                            Min.vol = 0.10, r1 = 1)


## End(Not run)

SingleVoxelFSTS

Description

This function is used to perform an activation analysis for single voxels based on the FSTS algorithm.

Usage

SingleVoxelFSTS(
  posi.ffd,
  covariates,
  ffdc,
  m0,
  Cova,
  delta,
  S0,
  n0,
  N1,
  Nsimu1,
  Cutpos1,
  Min.vol,
  r1
)

Arguments

posi.ffd

the position of the voxel in the brain image.

covariates

a data frame or matrix whose columns contain the covariates related to the expected BOLD response obtained from the experimental setup.

ffdc

a 4D array (ffdc[i,j,k,t]) that contains the sequence of MRI images that are meant to be analyzed. (i,j,k) define the position of the voxel observed at time t.

m0

the constant prior mean value for the covariates parameters and common to all voxels within every neighborhood at t=0 (m0=0 is the default value when no prior information is available). For the case of available prior information, m0 can be defined as a \(p\times q\) matrix, where \(p\) is the number of columns in the covariates object and \(q\) is the cluster size.

Cova

a positive constant that defines the prior variances for the covariates parameters at t=0 (Cova=100 is the default value when no prior information is available). For the case of available prior information, Cova can be defined as a \(p \times p\) matrix, where \(p\) is the number of columns in the covariates object.

delta

a discount factor related to the evolution variances. Recommended values between 0.85<delta<1. delta=1 will yield results similar to the classical general linear model.

S0

prior covariance structure among voxels within every cluster at t=0. S0=1 is the default value when no prior information is available and defines an \(q \times q\) identity matrix. For the case of available prior information, S0 can be defined as an \(q \times q\) matrix, where \(q\) is the common number of voxels in every cluster.

n0

a positive hyperparameter of the prior distribution for the covariance matrix S0 at t=0 (n=1 is the default value when no prior information is available). For the case of available prior information, n0 can be set as n0=np, where np is the number of MRI images in the pilot sample.

N1

is the number of images (2<N1<T) from the ffdc array employed in the model fitting. N1=NULL (or equivalently N1=T) is its default value, taking all the images in the ffdc array for the fitting process.

Nsimu1

is the number of simulated on-line trajectories related to the state parameters. These simulated curves are later employed to compute the posterior probability of voxel activation.

Cutpos1

a cutpoint time from where the on-line trajectories begin. This parameter value is related to an approximation from a t-student distribution to a normal distribution. Values equal to or greater than 30 are recommended (30<Cutpos1<T).

Min.vol

helps to define a threshold for the voxels considered in the analysis. For example, Min.vol = 0.10 means that all the voxels with values below to max(ffdc)*Min.vol can be considered irrelevant and discarded from the analysis.

r1

a positive integer number that defines the distance from every voxel with its most distant neighbor. This value determines the size of the cluster. The users can set a range of different r1 values: \(r1 = 0, 1, 2, 3, 4\), which leads to \(q = 1, 7, 19, 27, 33\), where \(q\) is the size of the cluster.

Details

This function allows the development of an activation analysis for single voxels. A multivariate dynamic linear model is fitted to a cluster of voxels, with its center at location (i,j,k), in the way it is presented in (Cardona-Jiménez and de B. Pereira 2021).

Value

a list containing a vector (Evidence) with the evidence measure of activation for each of the p covariates considered in the model, the simulated online trajectories related to the state parameter, the simulated BOLD responses, and a measure to examine the goodness of fit of the model \((100 \ast |Y[i,j,k]_t - \hat{Y}[i,j,k]_t |/ \hat{Y}[i,j,k]_t )\) for that particular voxel (FitnessV).

References

Cardona-Jiménez J, de B. Pereira CA (2021). “Assessing dynamic effects on a Bayesian matrix-variate dynamic linear model: An application to task-based fMRI data analysis.” Computational Statistics & Data Analysis, 163, 107297. ISSN 0167-9473, doi:10.1016/j.csda.2021.107297, https://www.sciencedirect.com/science/article/pii/S0167947321001316.

Cardona-Jiménez J (2021). “BayesDLMfMRI: Bayesian Matrix-Variate Dynamic Linear Models for Task-based fMRI Modeling in R.” arXiv e-prints, arXiv–2111.

Examples

## Not run: 
# This example can take a long time to run.
fMRI.data  <- get_example_fMRI_data()
data("covariates", package="BayesDLMfMRI")
res.indi <- SingleVoxelFSTS(posi.ffd = c(14, 56, 40), 
                            covariates = Covariates,
                            ffdc =  fMRI.data, 
                            m0 = 0, Cova = 100, delta = 0.95, S0 = 1, 
                            n0 = 1, Nsimu1 = 100, N1 = FALSE, Cutpos1 = 30, 
                            Min.vol = 0.10, r1 = 1)


## End(Not run)

summary.fMRI_group_evidence

Description

Summary function

Usage

## S3 method for class 'fMRI_group_evidence'
summary(object, ...)

Arguments

object

is the returned value of any of the fdGroupEvidence* functions

...

Other potential arguments

Details

Summary function

Examples

## Not run: 
DatabaseGroup <- get_example_fMRI_data_group()
data("covariates", package="BayesDLMfMRI")
data("mask", package="BayesDLMfMRI")
res <- ffdGroupEvidenceFETS(ffdGroup = DatabaseGroup, covariates = Covariates, 
                            m0 = 0, Cova = 100, delta = 0.95, S0 = 1, 
                            n0 = 1, N1 = FALSE, Nsimu1 = 100, Cutpos=30, 
                            r1 = 1, Test = "JointTest", mask = mask, Ncores = 7)
summary(res)

## End(Not run)

summary.fMRI_single_evidence

Description

Summary function

Usage

## S3 method for class 'fMRI_single_evidence'
summary(object, ...)

Arguments

object

is the returned value of any of the ffdEvidence* functions

...

Other potential arguments

Details

Summary function

Examples

## Not run: 
fMRI.data  <- get_example_fMRI_data()
data("covariates", package="BayesDLMfMRI")
res <- ffdEvidenceFFBS(ffdc = fMRI.data, covariates = Covariates, m0=0, Cova=100,
                       delta=0.95, S0=1, n0=1, N1=FALSE, 
                       Nsimu1 = 100, Cutpos1=30, r1 = 1,
                       perVol = 0.10, Ncores=3)
summary(res)

## End(Not run)