-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
152 lines (111 loc) · 5.07 KB
/
build.gradle
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
141
142
143
144
145
146
147
148
149
150
151
152
buildDir.mkdirs()
ext {
defaultSettings = file("$rootDir/resources/settings/default.groovy")
evaluationResourceDir = file("$rootDir/resources/evaluation")
tongueTemplateName = "tongue_template"
palateTemplateName = "palate_template"
mriDir = file("$rootDir/resources/mri")
templateDir = file("$rootDir/resources/template")
landmarksTongueDir = file("$rootDir/resources/landmarksTongue")
landmarksPalateDir = file("$rootDir/resources/landmarksPalate")
landmarksAlignmentDir = file("$rootDir/resources/landmarksAlignment")
Rscripts = file("$rootDir/resources/Rscripts")
// gather configuration
configMap = [:]
def slurper = new ConfigSlurper()
// outer loop -> datasets
fileTree("$rootDir/configuration").include("*/dataset.groovy").each{ datasetFile ->
def dataset = new ConfigSlurper().parse(datasetFile.text)
// store dataset information
configMap["$dataset.dataset.name"] = dataset
// generate bootstrap configuration
(1..dataset.bootstrapTongue.iterations).each{ counter ->
def iterationSettings = slurper.parse(dataset.prettyPrint())
iterationSettings.bootstrapTongue.counter = counter
iterationSettings.bootstrapPalate.counter = counter
configMap["$counter-$dataset.dataset.name"] = iterationSettings
}
// inner loop -> speakers of the dataset
dataset.dataset.speakers.each{ speaker ->
// parse speaker file
def speakerFile = file("${datasetFile.parentFile}/${speaker}/speaker.groovy")
def config = new ConfigSlurper().parse(speakerFile.text)
// apply default settings
def baseSettings = slurper.parse(defaultSettings.text)
// merge speaker specific settings
def settingsFile = file("$datasetFile.parentFile/$speaker/settings.groovy")
baseSettings.merge(slurper.parse(settingsFile.text))
// get base settings
baseSettings.speaker.name = config.speaker.name
baseSettings.speaker.palateScan = config.speaker.palateScan
baseSettings.speaker.basePath = "$dataset.dataset.name/$config.speaker.name"
baseSettings.speaker.dataset = dataset.dataset
baseSettings.speaker.session = config.speaker.session
configMap["$dataset.dataset.name-$config.speaker.name"] = baseSettings
// add palate scan to scans
def scans = config.speaker.scans.clone()
scans.add(config.speaker.palateScan)
// create settings for each scan
scans.each{ scan ->
def scanSettings = slurper.parse(baseSettings.toProperties())
def scanFolder = file("$speakerFile.parentFile/$scan")
// merge scan specific settings if present
fileTree(scanFolder){
include "*.groovy"
}.each {
scanSettings.merge(slurper.parse(it.text))
}
// set scan number, name of speaker, and type of scan
scanSettings.speaker.scan = scan
scanSettings.speaker.name = config.speaker.name
scanSettings.speaker.type = dataset.dataset.type
// build path
scanSettings.speaker.scanPath = "$dataset.dataset.name/$config.speaker.name/$scan"
configMap["$dataset.dataset.name-$config.speaker.name-$scan"] = scanSettings
// generate bootstrap configuration
(1..dataset.bootstrapTongue.iterations).each{ counter ->
def iterationSettings = slurper.parse(scanSettings.toProperties())
iterationSettings.bootstrapTongue.counter = counter
iterationSettings.bootstrapTongue.iterations = dataset.bootstrapTongue.iterations
iterationSettings.bootstrapPalate.counter = counter
iterationSettings.bootstrapPalate.iterations = dataset.bootstrapPalate.iterations
configMap["$counter-$dataset.dataset.name-$config.speaker.name-$scan"] = iterationSettings
}
} // end scans
} // end speakers
} // end datasets
} // end ext
task createTongueTemplateLandmarks {
description = "Extracts landmarks from the tongue template blend file."
def inputFile = file("$templateDir/${tongueTemplateName}.blend")
def outputFile = file("$buildDir/landmarksTongue.json")
inputs.file inputFile
outputs.file outputFile
doLast{
outputFile.parentFile.mkdirs()
exec{
commandLine "./extract_landmarks.py --input $inputFile --output $outputFile".tokenize()
workingDir "$templateDir"
// blender may not free all memory blocks and report an error
ignoreExitValue = true
}
}
}
task createPalateTemplateLandmarks {
description = "Extracts landmarks from the palate template blend file."
def inputFile = file("$templateDir/${palateTemplateName}.blend")
def outputFile = file("$buildDir/landmarksPalate.json")
inputs.file inputFile
outputs.file outputFile
doLast{
exec{
commandLine "./extract_landmarks.py --input $inputFile --output $outputFile".tokenize()
workingDir "$templateDir"
// blender may not free all memory blocks and report an error
ignoreExitValue = true
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.7'
}