tfceParams: Setting the parameters for TFCE correction

Description Usage Arguments Details Note Examples

View source: R/param_setters.R

Description

tfceParams sets the parameters for TFCE correction

Usage

1
tfceParams(ChN = NULL, EH = NULL, auto = TRUE, steps = 50L)

Arguments

ChN

channel neighbourhood matrix

EH

numeric vector giving the E and H parameters

auto

logical; if set to TRUE (default), ChN and EH are set automagically. See Details.

steps

integer value indicating the number of thresholding steps (default: 50L)

Details

The TFCE correction has three parameters: the channel neighbourhood matrix, and the E and H parameters. The channel neighb. matrix is usually generated by chanNb. The E and H parameters should be fixed at c(0.66, 2) for t-tests and c(0.66, 1) for F-tests, unless you have very good reasons to change these defaults. If 'auto' is TRUE and 'ChN' is NULL, tfceParams looks for an object named '.arraydat' and tries to extract its 'ChN' attribute. This usually works because in the functions which perform TFCE correction (arrayAnova and arrayTtest), the data argument is named as .arraydat. If this automatic lookup fails, tfceParams fails with an informative error message. If 'auto' is TRUE and 'EH' is NULL, tfceParams investigates if it was called from a function which has "anova" in its name (upper- or lower-case does not matter) or not. In the former case EH is set to c(0.66, 1), otherwise c(0.66, 2).

Note

IMPORTANT! Be extremely careful with the 'auto' parameter.

Examples

 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
# use example dataset
data(erps)

# create channel neighb. matrix
chan_pos <- attr(erps, "chan")
chn <- chanNb(chan_pos, alpha = 0.7) # see ?chanNb how to find alpha
attr(erps, "ChN") <- chn

# create a dummy function
myAnova <- function(.arraydat) {
    tfce <- tfceParams()
    tfce
}

# check what it returns
res <- myAnova(erps)
str(res)
stopifnot(identical(res, 
                    structure(list(ChN = chn, EH = c(0.66, 1), steps = 50L), 
                              class = "tfceParams")
                   ))

# if called from the global environment, provide ChN and EH
myAnova2 <- function(.arraydat, tfce = NULL) tfce

# this fails
res <- try(myAnova2(erps, tfce = tfceParams()), silent = TRUE)
stopifnot(inherits(res, "try-error"))
res[1]

# this works
res <- myAnova2(erps, tfce = tfceParams(ChN = chn, EH = c(0.66, 1)))
str(res)

tdeenes/eegR documentation built on April 19, 2021, 4:17 p.m.