# Group_analysis

    library(BayesDLMfMRI)
    library(oro.nifti)
    #> oro.nifti 0.11.4
    library(neurobase)

Now we illustrate how to run an fMRI group analysis as described in Cardona-Jiménez and Pereira [2021]. In this first version of the BayesDLMfMRI package, we implement functions to detect brain activation for single groups. The comparison analysis between groups is under development and will be offered in future versions of the package. First, we read the fMRI images of 2 subjects taken from the “voice-localizer” example:

    DataGroups <- get_example_fMRI_data_group()

The complete dateset(21 subjets) and results are avalible in Cardona-Jiménez and Pereira [2021].

    # load example covaraites and mask
    data("covariates", package="BayesDLMfMRI")
    data("mask", package="BayesDLMfMRI")

In order to run any of the functions available in this package to perform fMRI group analysis, the data sets or sets of images from each subject must be stored on a list object as it is shown above. To deal with this massive amount of information, the user must have a big RAM capacity available on the machine where this process will be run. It is also recommended to have a multi-core processor available in order to speed up computation time. The arguments or input parameters for any functions offered in this package to run group analysis are almost identical to those required for individual analysis. There is only an additional argument needed (mask), which adds a 3D array that works as a brain of reference (MNI atlas) for the group analysis.

    res <- ffdGroupEvidenceFFBS(ffdGroup = DataGroups, covariates = Covariates,
                                m0=0, Cova=100, delta = 0.95, S0 = 1, n0 = 1, N1 = FALSE, Nsimu1 = 100,
                                Cutpos = 30, r1 = 1, mask = mask, Ncores = 15)

    str(res)
    #> List of 3
    #>  $ : num [1:2, 1:91, 1:109, 1:91] 0 0 0 0 0 0 0 0 0 0 ...
    #>  $ : num [1:2, 1:91, 1:109, 1:91] 0 0 0 0 0 0 0 0 0 0 ...
    #>  $ : num [1:2, 1:91, 1:109, 1:91] 0 0 0 0 0 0 0 0 0 0 ...
    #>  - attr(*, "class")= chr "fMRI_group_evidence"