-
Notifications
You must be signed in to change notification settings - Fork 0
/
jobrunner.nw
103 lines (84 loc) · 3.34 KB
/
jobrunner.nw
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env nextflow
/* Run IDInteraction analysis jobs (i.e. classifying from ground truth
and arbitrary sources of tracking data) using Nextflow */
/* August 2017 */
/*
vim: syntax=groovy
-*- mode: groovy;-*-
*/
params.outfile="outfile.csv"
params.sources="openface,cppmt"
params.includeframefortracking=false
params.targetted=false
experimentparts=[1,2]
shuffleoptions = ["","no"]
trainingframes=[30,60,120,240,450,900,1800]
participantrange = 1..20 // Want to detect automatically (pass as environment var?)
participantcode = participantrange.collect{"P" + String.valueOf(it).padLeft(2,'0')}
participants=Channel.from(participantcode)
process runClassifier {
// Run the classifier for a participant/experimentpart combination
input:
val participant from participants
each experimentpart from experimentparts
each trainingframe from trainingframes
each shuffle from shuffleoptions
output:
// We need each output filename to be unique.
// We do this by getting the directory name we run in in the
// shell script
file "result*.csv" into classres
exec:
sources = ["cppmt":"/idinteraction/results/cppMT/part${experimentpart}/${participant}_front.csv",
"pca":"/idinteraction/results/depth/${participant}.pca${experimentpart}",
"mixture":"/idinteraction/results/depth/${participant}.mixture${experimentpart}",
"openface":"/idinteraction/results/OpenFace/${participant}_front.openface",
"mixtureside":"/idinteraction/results/depth_side/${participant}.mixture${experimentpart}",
"pcaside": "/idinteraction/results/depth_side/${participant}.pca${experimentpart}"]
// Derive the string we need to pass as --tracker parameters
sourcelist = params.sources.tokenize(",")
String sourcestring = ""
for (String s : sourcelist){
thissource = sources[s]
if (!thissource){
throw new IOException("No frame source " + thissource)
}
sourcestring += ("--tracker " + thissource + " ")
}
includeframefortracking = " "
if (params.includeframefortracking){
includeframefortracking = "--includeframefortracking"
}
targetted = " "
shufflecode = shuffle
if(params.targetted){
targetted = "--targetted --windowsize 1000 --advancesize 500 --batchsize 50"
shufflecode="targetted"
}
groundtruth = "/idinteraction/results/Groundtruth/${participant}_attention.csv"
startstring = "start" + "$experimentpart"
endstring = "end" + "$experimentpart"
// Only run for shuffled when doing targetted training
when:
!params.targetted || (params.targetted && shuffle=="")
shell:
// ${PWD##*/} gets the last part of the current directory
"""
abc-classify.py --${shuffle}shuffle --externaltrainingframes ${trainingframe} ${sourcestring} --summaryfile result\${PWD##*/}.csv --startframe \$(cat /idinteraction/results/EventFrames/${participant}_attention.${startstring}) --endframe \$(cat /idinteraction/results/EventFrames/${participant}_attention.${endstring}) --extgt /idinteraction/results/Groundtruth/${participant}_attention.csv --useexternalgt --maxmissing 600 --participantcode a:${experimentpart}::f:${trainingframe}::p:${participant}::s:${shufflecode}
"""
}
process produceOutput {
// Combine the results of each individual run
publishDir "data/runresults", mode:"copy" , overwrite:"false"
input:
file classreslist from classres.collect()
output:
file '*.csv'
script:
"""
for resfile in ${classreslist}
do
cat \$resfile >> ${params.outfile}
done
"""
}