# u4_cba_cor: Generalized Cluster-Based Analysis (CBA) Method In MixfMRI: Mixture fMRI Clustering Analysis

## Description

Find clusters in 2D or 3D based on a generalized CBA method. The CBA method is originally proposed by Heller, et.al. (2006) using the correlation of two time series as the similarity of two spatial locations.

## Usage

 ```1 2 3``` ``` cba.cor(da.ts, da.m = NULL, adj.dist = TRUE, fun.sim = stats::cor) cba.cor.2d(da.ts, da.m = NULL, adj.dist = TRUE, fun.sim = stats::cor) cba.cor.3d(da.ts, da.m = NULL, adj.dist = TRUE, fun.sim = stats::cor) ```

## Arguments

 `da.ts` a time series array of dimensions `x * y * z * t`. `da.m` a mask determining inside of brain or not. `adj.dist` if adjust correlations by distance. `fun.sim` a function computing simility of two locations.

## Details

These functions implement the 2D and 3D versions of CBA proposed by Heller, et.al. (2006).

`da.ts` should have dimensions `x * y * z * t` for 3D data and `x * y * time` for 2D data. Similarly, `da.m` would have `x * y * z` and `x * y` correspondingly.

`da.m` has values 0 or 1 indicating outside or inside a brain, respectively.

`fun.sim(a, B)` is a function return similarity between a location `a` and N neighboring locations `B` where `a` is of dimension `t * 1` and `B` is of dimensiont * N. Ideally, `fun.sim`() should return values of similarity which take values between 0 and 1 where 0 means totally different and 1 means completely identical of two spatial locations. By default, `stats::cor` is used. See the example section next for user defined functions for `fun.sim`().

## Value

Return the cluster ids for each voxel. NA for outside of brain if `da.m` is provided.

Wei-Chen Chen.

## References

Heller, et.al. (2006) “Cluster-based analysis of FMRI data”, NeuroImage, 33(2), 599-608.

`fdr.bh.p1()`, `fdr.bh.p2()`.
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38``` ```### Simulated data library(MixfMRI, quietly = TRUE) dim <- c(4, 5, 4, 10) set.seed(123) da.ts <- array(rnorm(prod(dim)), dim = dim) id.class <- suppressWarnings(cba.cor(da.ts)) table(id.class) fun.tanh <- function(a, B){ d <- 1 / apply(B, 2, function(b){ dist(rbind(as.vector(a), b)) }) tanh(d) } id.class.tanh <- suppressWarnings(cba.cor(da.ts, fun.sim = fun.tanh)) table(id.class.tanh) fun.logit <- function(a, B){ d <- dist(t(cbind(a, B)))[1:ncol(B)] (1 / (1 + exp(-d))) * 2 - 1 } id.class.logit <- suppressWarnings(cba.cor(da.ts, fun.sim = fun.logit)) table(id.class.logit) ### Real data library(AnalyzeFMRI, quietly = TRUE) library(oro.nifti, quietly = TRUE) fn <- "pb02_volreg_tlrc.nii" da <- readNIfTI(fn) da.ts <- da@.Data fn <- "mask_anat.nii" da <- readNIfTI(fn) da.m <- da@.Data id.class <- suppressWarnings(cba.cor(da.ts, da.m)) dim(id.class) <- dim(da.m) length(table(id.class)) ```