-
Notifications
You must be signed in to change notification settings - Fork 0
/
eyeQC.R
executable file
·85 lines (71 loc) · 2.09 KB
/
eyeQC.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env Rscript
# 20200323WF - init
# developed for AntiPet eyetracking quality checking
setwd("/Volumes/Hera/Projects/autoeyescore/")
o <- docopt::docopt(
"eye quality check
Usage:
eyeQC.R tasks
eyeQC.R <task> --pdf ( redo | todo | done | <dotnotation> )
eyeQC.R <task> <intials> ( todo | done | reverse | random | <dotnotation> ) [ --droponly ]
eyeQC.R (-h | --help)
Options:
-h --help Show this screen.
-d luna.date.trial dot notation.
")
# just list avaiable tasks
if (o$tasks) {
cat(paste(collapse="\n", sapply(Sys.glob("*/*.settings.R"), dirname)), "\n")
quit()
}
src <- sprintf("%s/%s.settings.R", o$task, o$task)
if (!file.exists(src))
stop("no settings file for task ", o$task, " like '", src, "'. see eyeQC.R tasks")
source(src)
source("ScoreRun.R")
source("getSacsDot.R")
outdir <- file.path('audit', o$task)
# all files
if(!is.null(o$dotnotation)) {
di <- dot2runinfo(o$dotnotation)
allinfo <- getFiles(di$eyetrack)
} else {
cat("# generating list of all raw eye files\n")
allinfo <- getFiles()
}
# pull out parts we care about
allfiles <- allinfo$file
dots <- allinfo$id
cat("# generating list of all completed files\n")
if(o$pdf) {
have <- lapply(Sys.glob(paste0(outdir,"/pdf/*/")), basename)
} else if(is.null(o$dotnotation)) {
have <- lapply(Sys.glob(paste0(outdir,"/*_", o$intials, ".txt")),
function(f) gsub("_*", "", basename(f)))
} else {
have <- list()
}
need <- setdiff(dots, have)
# just show what we have todo and quit
if (o$todo) {
cat(paste(collapse="\n", need), "\n")
quit()
}
if (o$done) {
cat(paste(collapse="\n", have), "\n")
quit()
}
# how to organize
if (o$reverse) need <- rev(need)
if (o$random) need <- need[sample(1:length(need))]
for (dot in need) {
if(o$pdf) {
pdfdir <- file.path(outdir,'pdf', dot)
print(sprintf('pdfrun(%s,%s)', dot,pdfdir))
pdfrun(dot, pdfdir)
next
}
getRunDot(dot, showplot=T, auditor=o$intials, pdfdir=pdfdir)
cat("====== finished ", dot, "\n\n\n")
readline("Want to stop? Push Ctrl-C.\nEnter to continue\n")
}