-
Notifications
You must be signed in to change notification settings - Fork 11
/
fslr_Generic_fslstats_Maker.R
64 lines (48 loc) · 1.73 KB
/
fslr_Generic_fslstats_Maker.R
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
proper = function(x){
paste0(toupper(substr(x, 1,1)), substr(x, 2, nchar(x)))
}
#############################################
# Function maker that involves 1 file
#############################################
makefunc = function(opt, FUNC, func,
remove = TRUE){
x = readLines('fslr_Generic_fslstats.R')
x = gsub("%opt%", opt, x)
x = gsub("%FUNC%", FUNC, x)
x = gsub("%func%", func, x)
funcname = paste0("fsl", opt)
writeLines(text = x, con = paste0("R/", funcname, ".R"))
if (remove) file.remove(paste0("R/", funcname, ".R"))
return(TRUE)
}
#############################################
# Function maker that involves non-zero entries
#############################################
makefunc = function(opt,
FUNC,
func,
remove = TRUE){
x = readLines('fslr_Generic_fslstats_nonzero.R')
x = gsub("%opt%", opt, x)
x = gsub("%OPT%", toupper(opt), x)
x = gsub("%FUNC%", FUNC, x)
x = gsub("%func%", func, x)
funcname = paste0("fsl", func)
writeLines(text = x, con = paste0("R/", funcname, ".R"))
if (remove) file.remove(paste0("R/", funcname, ".R"))
return(TRUE)
}
remove = FALSE
################################################################
# Make Functions that take in 1 file
################################################################
# makefunc("r", FUNC = "Robust Range", func = "rrange",
# remove = TRUE)
makefunc("m", FUNC = "Mean", func = "mean",
remove = remove)
makefunc("s", FUNC = "Standard Deviation", func = "sd",
remove = remove)
makefunc("e", FUNC = "Mean Entropy", func = "entropy",
remove = remove)
makefunc("v", FUNC = "Volume", func = "volume",
remove = remove)