R/get.neighbor.R

get.neighbor <- function (connectivity=c(26L,18L,6L)) {
  out <- switch(as.character(connectivity),
                `6` = t(matrix(c(1,2,2,2,1,2,2,2,1,3,2,2,2,3,2,2,2,3), nrow=3)),
                `18` = t(matrix(
                  c(1,1,2,1,2,1,1,2,2,1,2,3,1,3,2,2,1,1,2,1,2,2,1,3,2,2,1,2,2,2,
                    2,2,3,2,3,1,2,3,2,2,3,3,3,1,2,3,2,1,3,2,2,3,2,3,3,3,2), nrow=3)),
                `26` = t(matrix(
                  c(1,1,1,1,1,2,1,1,3,1,2,1,1,2,2,1,2,3,1,3,1,1,3,2,1,3,3,2,1,1,
                    2,1,2,2,1,3,2,2,1,2,2,3,2,3,1,2,3,2,2,3,3,3,1,1,3,1,2,3,1,3,
                    3,2,1,3,2,2,3,2,3,3,3,1,3,3,2,3,3,3), nrow=3)),
                otherwise=stop("connectivity not recognized, use 26, 18, or 6"))
  out <- out - 2
  return(out)
}
TKoscik/cluster.nii documentation built on March 31, 2020, 2:28 p.m.