-
Notifications
You must be signed in to change notification settings - Fork 0
/
idinteraction.nw
142 lines (110 loc) · 3.33 KB
/
idinteraction.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env nextflow
/*
vim: syntax=groovy
-*- mode: groovy;-*-
*/
// Experimental processing pipeline for idinteraction using nextflow
params.indir = "./participants/*"
params.eventfile = "./particiants/transitionannotations.csv"
participant_dir = Channel.fromPath(params.indir, type: 'dir').map {
path -> tuple(path.baseName,
path.toRealPath(),
path)
}
keyframefile = Channel.fromPath(params.eventfile)
eventnames = Channel.from ("start1",
"end1",
"start2",
"end2")
process enter_participant {
// Separate each participant's data into its constituent
// streams
input:
set participantcode, fullpath, path from participant_dir
output:
set participantcode, 'attention.txt' into attention_for_groundtruth, attention_for_events
set participantcode, 'frontkinect.mp4', val("kinect"),
val("front") into frontkinectfile
set participantcode, 'webcam.mp4', val("webcam"), val("front") into webcamfile
set participantcode, 'depthdata.tar' into depthfile
"""
# TODO - check each only matches a single file
cat ${fullpath}/*_attention.txt > attention.txt
cat ${fullpath}/*_kinect.mp4 > frontkinect.mp4
cat ${fullpath}/*_webcam.mp4 > webcam.mp4
tar czf depthdata.tar ${fullpath}/P??depth/*
"""
}
process attention_to_groundtruth {
// Convert an attention file to a groundtruth file
input:
set val(participantcode), file(attentionfile) from attention_for_groundtruth
output:
set file('groundtruth.csv'), val(participantcode) into csvfile
"""
echo "groundtruth" > groundtruth.csv
cat ${attentionfile} >> groundtruth.csv
"""
}
process extract_eventframe {
input:
file attentionfile from attention_for_events
file keyframefile from keyframefile
val event from eventnames
output:
set val(event), val(eventframe) into eventframe
exec:
eventframe = "123"
}
// Split channel so we can use it in following two filters
eventframe.into {eventframe1; eventframe2}
startevents = eventframe1.filter {it[0] =~/^start./}
endevents = eventframe2.filter{it[0] =~/^end./}
/*
process map_frame_to_kinect {
// Transform a frame from Webcam to Kinect time
input:
set val(webcamframe), val(event), val(participantcode) from xxx
val map from mappingfile // Not sure how we'll implement this
output:
val webcamframe from eventframe
exec:
// Stuff to do the mapping
}
*/
// Combine both video sources
videofiles = frontkinectfile.mix(webcamfile)
// Combine all combinations of startevents and video sources
cppmt_runs = videofiles.combine(startevents)
// Run them
process run_cppmt {
echo true
input:
set val(event), val(eventframe) ,
val(participantcode), file(videofile), val(timebase),
val(source) from cppmt_runs
output:
set participantcode, "cppmt_tracking.csv", timebase, source into cppmttrackingfile
"""
echo "Running cppmt tracking"
echo "${videofile} ${event} ${eventframe}"
echo "${participantcode}, ${timebase}"
echo "${event}, ${eventframe}"
echo "Cppmt tracking" > cppmt_tracking.csv
echo ${participantcode} >> cppmt_tracking
cat ${videofile} >> cppmt_tracking
echo ${event} >> cppmt_tracking
echo ${eventframe} >> cppmt_tracking
"""
}
process report_cppmt {
input:
set val(participantcode), file("cppmttrack.csv"),
val(timebase), val(source) from cppmttrackingfile
exec:
println "in report_cppmt"
println "pcode:" + participantcode
println timebase
println source
println "end report_cppmt"
}