forked from BRAINSia/BRAINSStandAlone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorkupT1T2BRAINSCut.py
426 lines (377 loc) · 23.2 KB
/
WorkupT1T2BRAINSCut.py
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
#!/usr/bin/env python
from nipype.interfaces.base import CommandLine, CommandLineInputSpec, TraitedSpec, File, Directory
from nipype.interfaces.base import traits, isdefined, BaseInterface
from nipype.interfaces.utility import Merge, Split, Function, Rename, IdentityInterface
import nipype.interfaces.io as nio # Data i/o
import nipype.pipeline.engine as pe # pypeline engine
from SEMTools import *
from RF12BRAINSCutWrapper import RF12BRAINSCutWrapper
from PipeLineFunctionHelpers import getListIndex
def GenerateWFName(projectid, subjectid, sessionid, WFName):
return WFName + '_' + str(subjectid) + "_" + str(sessionid) + "_" + str(projectid)
def CreateLabelMap(listOfImages, LabelImageName, CSVFileName, posteriorDictionary, projectid, subjectid, sessionid):
"""
A function to create a consolidated label map and a
csv file of volume measurements.
"""
import SimpleITK as sitk
import os
import csv
def CleanUpSegmentationsWithExclusionProbabilityMaps( initial_seg, probMapOfExclusion, percentageThreshold = 0.85 ):
"""This function is used to clean up grey matter sub-cortical segmentations
by removing tissue that is more than 85% chance of being either WM or CSF
The inputs are the initial segmentation, the WM Probability, and the CSF Probability
"""
seg = sitk.Cast( initial_seg, sitk.sitkUInt8 )
print "AA", initial_seg
print "BB", dict(sitk.Statistics(seg))
exclude_Mask = sitk.Cast( sitk.BinaryThreshold( probMapOfExclusion, percentageThreshold, 1.0, 0, 1), sitk.sitkUInt8 )
print "CC", dict(sitk.Statistics(exclude_Mask))
cleanedUpSeg = seg * exclude_Mask
print "DD", dict(sitk.Statistics(cleanedUpSeg))
return cleanedUpSeg
def CleanUpGMSegmentationWithWMCSF( initial_seg_fn, posteriorDictionary, WMThreshold, CSFThreshold ):
initial_seg = sitk.Cast(sitk.ReadImage(initial_seg_fn), sitk.sitkUInt8 )
WM_FN=posteriorDictionary['WM']
WM_PROB=sitk.ReadImage(WM_FN)
WM_removed = CleanUpSegmentationsWithExclusionProbabilityMaps( initial_seg, WM_PROB, WMThreshold )
CSF_FN=posteriorDictionary['CSF']
CSF_PROB=sitk.ReadImage(CSF_FN)
CSF_removed = CleanUpSegmentationsWithExclusionProbabilityMaps( initial_seg, CSF_PROB, CSFThreshold )
return CSF_removed
orderOfPriority = [
"l_caudate",
"r_caudate",
"l_putamen",
"r_putamen",
"l_hippocampus",
"r_hippocampus",
"l_thalamus",
"r_thalamus",
"l_accumben",
"r_accumben",
"l_globus",
"r_globus"
]
valueDict = {
"l_caudate": 1,
"r_caudate": 2,
"l_putamen": 3,
"r_putamen": 4,
"l_hippocampus": 5,
"r_hippocampus": 6,
"l_thalamus": 7,
"r_thalamus": 8,
"l_accumben": 9,
"r_accumben": 10,
"l_globus": 11,
"r_globus": 12
}
cleaned_labels_map = dict()
labelImage = None
print "ZZZ"
x=0
for segFN in listOfImages:
x=x+1
print x, segFN
## Clean up the segmentations
curr_segROI = CleanUpGMSegmentationWithWMCSF(segFN, posteriorDictionary, 0.85, 0.85 )
print "Y"
curr_segROI.GetSize()
remove_pre_postfix = segFN.replace(".nii.gz", "")
remove_pre_postfix = os.path.basename(remove_pre_postfix.replace("subjectANNLabel_", "").replace("_seg", ""))
remove_pre_postfix = os.path.basename(remove_pre_postfix.replace("ANNContinuousPrediction", "").replace("subject", ""))
structName = remove_pre_postfix.lower()
cleaned_fileName = os.path.join(os.path.dirname(segFN),"cleaned_"+structName+"_seg.nii.gz")
print "="*20,structName," ",cleaned_fileName
cleaned_labels_map[structName]=cleaned_fileName
sitk.WriteImage(curr_segROI, cleaned_fileName)
if labelImage is None:
labelImage = curr_segROI * valueDict[structName]
else:
not_mask = sitk.Not(curr_segROI)
## Clear out an empty space for the next mask to be inserted
labelImage *= not_mask
## Add in the mask image with it's proper label
labelImage = labelImage + curr_segROI * valueDict[structName]
sitk.WriteImage(labelImage, LabelImageName)
ls = sitk.LabelStatisticsImageFilter()
ls.Execute(labelImage, labelImage)
ImageSpacing = labelImage.GetSpacing()
csvFile = open(CSVFileName, 'w')
dWriter = csv.DictWriter(csvFile, ['projectid', 'subjectid', 'sessionid', 'Structure', 'LabelCode', 'Volume_mm3'], restval='', extrasaction='raise', dialect='excel')
dWriter.writeheader()
writeDictionary = dict()
for name in orderOfPriority:
value = valueDict[name]
if ls.HasLabel(value):
# print "Displaying: ", name, value
myMeasurementMap = ls.GetMeasurementMap(value)
dictKeys = myMeasurementMap.GetVectorOfMeasurementNames()
dictValues = myMeasurementMap.GetVectorOfMeasurementValues()
measurementDict = dict(zip(dictKeys, dictValues))
structVolume = ImageSpacing[0] * ImageSpacing[1] * ImageSpacing[2] * measurementDict['Count']
writeDictionary['Volume_mm3'] = structVolume
writeDictionary['Structure'] = name
writeDictionary['LabelCode'] = value
# writeDictionary['FileName']=os.path.abspath(LabelImageName)
writeDictionary['projectid'] = projectid
writeDictionary['subjectid'] = subjectid
writeDictionary['sessionid'] = sessionid
dWriter.writerow(writeDictionary)
CleanedLeftCaudate = cleaned_labels_map['l_caudate']
CleanedRightCaudate = cleaned_labels_map['r_caudate']
CleanedLeftHippocampus = cleaned_labels_map['l_hippocampus']
CleanedRightHippocampus = cleaned_labels_map['r_hippocampus']
CleanedLeftPutamen = cleaned_labels_map['l_putamen']
CleanedRightPutamen = cleaned_labels_map['r_putamen']
CleanedLeftThalamus = cleaned_labels_map['l_thalamus']
CleanedRightThalamus = cleaned_labels_map['r_thalamus']
CleanedLeftAccumben = cleaned_labels_map['l_accumben']
CleanedRightAccumben = cleaned_labels_map['r_accumben']
CleanedLeftGlobus = cleaned_labels_map['l_globus']
CleanedRightGlobus = cleaned_labels_map['r_globus']
return os.path.abspath(LabelImageName), os.path.abspath(CSVFileName), CleanedLeftCaudate, CleanedRightCaudate, CleanedLeftHippocampus, CleanedRightHippocampus, CleanedLeftPutamen, CleanedRightPutamen, CleanedLeftThalamus, CleanedRightThalamus, CleanedLeftAccumben, CleanedRightAccumben, CleanedLeftGlobus, CleanedRightGlobus
#==============================================
#==============================================
#==============================================
#==============================================
#==============================================
#==============================================
"""
from WorkupT1T2BRAINSCutSegmentation import CreateBRAINSCutSegmentationWorkflow
myLocalcutWF= CreateBRAINSCutSegmentationWorkflow("999999_PersistanceCheckingWorkflow")
cutWF.connect(SplitAvgBABC,'avgBABCT1',myLocalcutWF,'fixedVolume')
cutWF.connect(BABC,'outputLabels',myLocalcutWF,'fixedBinaryVolume')
cutWF.connect(BAtlas,'template_t1',myLocalcutWF,'movingVolume')
cutWF.connect(BAtlas,'template_brain',myLocalcutWF,'movingBinaryVolume')
cutWF.connect(BLI,'outputTransformFilename',myLocalcutWF,'initialTransform')
"""
def CreateBRAINSCutWorkflow(projectid,
subjectid,
sessionid,
WFName,
CLUSTER_QUEUE,
CLUSTER_QUEUE_LONG,
atlasObject,
t1Only=False):
cutWF = pe.Workflow(name=GenerateWFName(projectid, subjectid, sessionid, WFName))
inputsSpec = pe.Node(interface=IdentityInterface(fields=['T1Volume', 'T2Volume',
'posteriorDictionary', 'RegistrationROI',
'atlasToSubjectTransform']), name='inputspec')
"""
Denoised T1 input for BRAINSCut
"""
denosingTimeStep=0.0625
denosingConductance=0.4
denosingIteration=5
DenoisedT1 = pe.Node(interface=GradientAnisotropicDiffusionImageFilter(), name="DenoisedT1")
DenoisedT1.inputs.timeStep = denosingTimeStep
DenoisedT1.inputs.conductance = denosingConductance
DenoisedT1.inputs.numberOfIterations = denosingIteration
DenoisedT1.inputs.outputVolume = "DenoisedT1.nii.gz"
cutWF.connect(inputsSpec, 'T1Volume', DenoisedT1, 'inputVolume')
"""
Gradient Anistropic Diffusion T1 images for BRAINSCut
"""
GADT1 = pe.Node(interface=GradientAnisotropicDiffusionImageFilter(), name="GADT1")
GADT1.inputs.timeStep = 0.025
GADT1.inputs.conductance = 1
GADT1.inputs.numberOfIterations = 5
GADT1.inputs.outputVolume = "GADT1.nii.gz"
cutWF.connect(inputsSpec, 'T1Volume', GADT1, 'inputVolume')
if not t1Only:
"""
Denoised T1 input for BRAINSCut
"""
DenoisedT2 = pe.Node(interface=GradientAnisotropicDiffusionImageFilter(), name="DenoisedT2")
DenoisedT2.inputs.timeStep = denosingTimeStep
DenoisedT2.inputs.conductance = denosingConductance
DenoisedT2.inputs.numberOfIterations = denosingIteration
DenoisedT2.inputs.outputVolume = "DenoisedT2.nii.gz"
cutWF.connect(inputsSpec, 'T2Volume', DenoisedT2, 'inputVolume')
"""
Gradient Anistropic Diffusion T1 images for BRAINSCut
"""
GADT2 = pe.Node(interface=GradientAnisotropicDiffusionImageFilter(), name="GADT2")
GADT2.inputs.timeStep = 0.025
GADT2.inputs.conductance = 1
GADT2.inputs.numberOfIterations = 5
GADT2.inputs.outputVolume = "GADT2.nii.gz"
cutWF.connect(inputsSpec, 'T2Volume', GADT2, 'inputVolume')
"""
Sum the gradient images for BRAINSCut
"""
SGI = pe.Node(interface=GenerateSummedGradientImage(), name="SGI")
SGI.inputs.outputFileName = "SummedGradImage.nii.gz"
cutWF.connect(GADT1, 'outputVolume', SGI, 'inputVolume1')
cutWF.connect(GADT2, 'outputVolume', SGI, 'inputVolume2')
"""
BRAINSCut
"""
RF12BC = pe.Node(interface=RF12BRAINSCutWrapper(), name="IQR_NORM_SEP_RF12_BRAINSCut")
many_cpu_RF12BC_options_dictionary = {'qsub_args': '-S /bin/bash -pe smp1 2-2 -l h_vmem=8G,mem_free=4G -o /dev/null -e /dev/null ' + CLUSTER_QUEUE, 'overwrite': True}
# many_cpu_RF12BC_options_dictionary={'qsub_args': '-S /bin/bash -pe smp1 2-8 -l big_mem=true,h_vmem=60G,mem_free=30G -o /dev/null -e /dev/null '+CLUSTER_QUEUE, 'overwrite': True}
# many_cpu_RF12BC_options_dictionary={'qsub_args': '-S /bin/bash -pe smp1 4-6 -l big_mem=true,h_vmem=22G,mem_free=22G -o /dev/null -e /dev/null '+CLUSTER_QUEUE, 'overwrite': True}
RF12BC.plugin_args = many_cpu_RF12BC_options_dictionary
RF12BC.inputs.trainingVectorFilename = "trainingVectorFilename.txt"
RF12BC.inputs.xmlFilename = "BRAINSCutSegmentationDefinition.xml"
RF12BC.inputs.vectorNormalization = "IQR"
""" HACK These should be l_caudate_seg.nii.gz
subjectANNLabel_l_caudate.nii.gz
subjectANNLabel_l_hippocampus.nii.gz
subjectANNLabel_l_putamen.nii.gz
subjectANNLabel_l_thalamus.nii.gz
subjectANNLabel_r_caudate.nii.gz
subjectANNLabel_r_hippocampus.nii.gz
subjectANNLabel_r_putamen.nii.gz
subjectANNLabel_r_thalamus.nii.gz
"""
RF12BC.inputs.outputBinaryLeftCaudate = 'subjectANNLabel_l_caudate.nii.gz'
RF12BC.inputs.outputBinaryRightCaudate = 'subjectANNLabel_r_caudate.nii.gz'
RF12BC.inputs.outputBinaryLeftHippocampus = 'subjectANNLabel_l_hippocampus.nii.gz'
RF12BC.inputs.outputBinaryRightHippocampus = 'subjectANNLabel_r_hippocampus.nii.gz'
RF12BC.inputs.outputBinaryLeftPutamen = 'subjectANNLabel_l_putamen.nii.gz'
RF12BC.inputs.outputBinaryRightPutamen = 'subjectANNLabel_r_putamen.nii.gz'
RF12BC.inputs.outputBinaryLeftThalamus = 'subjectANNLabel_l_thalamus.nii.gz'
RF12BC.inputs.outputBinaryRightThalamus = 'subjectANNLabel_r_thalamus.nii.gz'
RF12BC.inputs.outputBinaryLeftAccumben = 'subjectANNLabel_l_accumben.nii.gz'
RF12BC.inputs.outputBinaryRightAccumben = 'subjectANNLabel_r_accumben.nii.gz'
RF12BC.inputs.outputBinaryLeftGlobus = 'subjectANNLabel_l_globus.nii.gz'
RF12BC.inputs.outputBinaryRightGlobus = 'subjectANNLabel_r_globus.nii.gz'
"""
"ANNContinuousPredictionl_accumbensubject.nii.gz"
RF12BC.inputs.outputBinaryLeftCaudate = 'ANNContinuousPredictionl_caudatesubject.nii.gz'
RF12BC.inputs.outputBinaryRightCaudate = 'ANNContinuousPredictionr_caudatesubject.nii.gz'
RF12BC.inputs.outputBinaryLeftHippocampus = 'ANNContinuousPredictionl_hippocampussubject.nii.gz'
RF12BC.inputs.outputBinaryRightHippocampus = 'ANNContinuousPredictionr_hippocampussubject.nii.gz'
RF12BC.inputs.outputBinaryLeftPutamen = 'ANNContinuousPredictionl_putamensubject.nii.gz'
RF12BC.inputs.outputBinaryRightPutamen = 'ANNContinuousPredictionr_putamensubject.nii.gz'
RF12BC.inputs.outputBinaryLeftThalamus = 'ANNContinuousPredictionl_thalamussubject.nii.gz'
RF12BC.inputs.outputBinaryRightThalamus = 'ANNContinuousPredictionr_thalamussubject.nii.gz'
RF12BC.inputs.outputBinaryLeftAccumben = 'ANNContinuousPredictionl_accumbensubject.nii.gz'
RF12BC.inputs.outputBinaryRightAccumben = 'ANNContinuousPredictionr_accumbensubject.nii.gz'
RF12BC.inputs.outputBinaryLeftGlobus = 'ANNContinuousPredictionl_globussubject.nii.gz'
RF12BC.inputs.outputBinaryRightGlobus = 'ANNContinuousPredictionr_globussubject.nii.gz'
"""
cutWF.connect( DenoisedT1, 'outputVolume', RF12BC, 'inputSubjectT1Filename')
from PipeLineFunctionHelpers import MakeInclusionMaskForGMStructures;
makeCandidateRegionNode = pe.Node(interface=Function(['posteriorDictionary','candidateRegionFileName'],
['outputCandidateRegionFileName'],
function=MakeInclusionMaskForGMStructures), name="MakeCandidateRegion")
makeCandidateRegionNode.inputs.candidateRegionFileName = "RF12_CandidateRegionMask.nii.gz"
cutWF.connect(inputsSpec,'posteriorDictionary',makeCandidateRegionNode,'posteriorDictionary')
cutWF.connect(makeCandidateRegionNode,'outputCandidateRegionFileName', RF12BC,'candidateRegion')
if not t1Only:
cutWF.connect( DenoisedT2, 'outputVolume', RF12BC, 'inputSubjectT2Filename')
# cutWF.connect(inputsSpec,'TotalGM',RF12BC,'inputSubjectTotalGMFilename')
# cutWF.connect(inputsSpec,'RegistrationROI',RF12BC,'inputSubjectRegistrationROIFilename')
# Error cutWF.connect(SGI,'outputVolume',RF12BC,'inputSubjectGadSGFilename')
cutWF.connect(SGI, 'outputFileName', RF12BC, 'inputSubjectGadSGFilename')
cutWF.connect(atlasObject, 'template_t1', RF12BC, 'inputTemplateT1')
# cutWF.connect(atlasObject,'template_brain',RF12BC,'inputTemplateRegistrationROIFilename')
cutWF.connect(atlasObject, 'rho', RF12BC, 'inputTemplateRhoFilename')
cutWF.connect(atlasObject, 'phi', RF12BC, 'inputTemplatePhiFilename')
cutWF.connect(atlasObject, 'theta', RF12BC, 'inputTemplateThetaFilename')
cutWF.connect(atlasObject, 'l_caudate_ProbabilityMap', RF12BC, 'probabilityMapsLeftCaudate')
cutWF.connect(atlasObject, 'r_caudate_ProbabilityMap', RF12BC, 'probabilityMapsRightCaudate')
cutWF.connect(atlasObject, 'l_hippocampus_ProbabilityMap', RF12BC, 'probabilityMapsLeftHippocampus')
cutWF.connect(atlasObject, 'r_hippocampus_ProbabilityMap', RF12BC, 'probabilityMapsRightHippocampus')
cutWF.connect(atlasObject, 'l_putamen_ProbabilityMap', RF12BC, 'probabilityMapsLeftPutamen')
cutWF.connect(atlasObject, 'r_putamen_ProbabilityMap', RF12BC, 'probabilityMapsRightPutamen')
cutWF.connect(atlasObject, 'l_thalamus_ProbabilityMap', RF12BC, 'probabilityMapsLeftThalamus')
cutWF.connect(atlasObject, 'r_thalamus_ProbabilityMap', RF12BC, 'probabilityMapsRightThalamus')
cutWF.connect(atlasObject, 'l_accumben_ProbabilityMap', RF12BC, 'probabilityMapsLeftAccumben')
cutWF.connect(atlasObject, 'r_accumben_ProbabilityMap', RF12BC, 'probabilityMapsRightAccumben')
cutWF.connect(atlasObject, 'l_globus_ProbabilityMap', RF12BC, 'probabilityMapsLeftGlobus')
cutWF.connect(atlasObject, 'r_globus_ProbabilityMap', RF12BC, 'probabilityMapsRightGlobus')
# TODO:
if not t1Only:
cutWF.connect(atlasObject, 'trainModelFile_txtD0060NT0060_gz', RF12BC, 'modelFilename')
else:
### TODO: Replace with proper atlasObject name in the future!!! This is a HACK
### to avoid changing the hash keys of the input files from the atlas.
def ChangeModelPathDirectory(multiModalFileName):
return multiModalFileName.replace('modelFiles', 'T1OnlyModels')
cutWF.connect([(atlasObject, RF12BC,
[(('trainModelFile_txtD0060NT0060_gz', ChangeModelPathDirectory), 'modelFilename')])])
## Need to index from next line cutWF.connect(inputsSpec,'atlasToSubjectTransform',RF12BC,'deformationFromTemplateToSubject')
cutWF.connect([(inputsSpec, RF12BC, [(('atlasToSubjectTransform', getListIndex, 0), 'deformationFromTemplateToSubject')]), ])
mergeAllLabels = pe.Node(interface=Merge(12), name="labelMergeNode")
# NOTE: Ordering is important
cutWF.connect(RF12BC, 'outputBinaryLeftCaudate', mergeAllLabels, 'in1')
cutWF.connect(RF12BC, 'outputBinaryRightCaudate', mergeAllLabels, 'in2')
cutWF.connect(RF12BC, 'outputBinaryLeftPutamen', mergeAllLabels, 'in3')
cutWF.connect(RF12BC, 'outputBinaryRightPutamen', mergeAllLabels, 'in4')
cutWF.connect(RF12BC, 'outputBinaryLeftHippocampus', mergeAllLabels, 'in5')
cutWF.connect(RF12BC, 'outputBinaryRightHippocampus', mergeAllLabels, 'in6')
cutWF.connect(RF12BC, 'outputBinaryLeftThalamus', mergeAllLabels, 'in7')
cutWF.connect(RF12BC, 'outputBinaryRightThalamus', mergeAllLabels, 'in8') # HACK: CHECK ORDERING
cutWF.connect(RF12BC, 'outputBinaryLeftAccumben', mergeAllLabels, 'in9')
cutWF.connect(RF12BC, 'outputBinaryRightAccumben', mergeAllLabels, 'in10')
cutWF.connect(RF12BC, 'outputBinaryLeftGlobus', mergeAllLabels, 'in11')
cutWF.connect(RF12BC, 'outputBinaryRightGlobus', mergeAllLabels, 'in12')
computeOneLabelMap = pe.Node(interface=Function(['listOfImages', 'LabelImageName', 'CSVFileName',
'posteriorDictionary',
'projectid', 'subjectid', 'sessionid'],
['outputLabelImageName', 'outputCSVFileName',
'CleanedLeftCaudate',
'CleanedRightCaudate',
'CleanedLeftHippocampus',
'CleanedRightHippocampus',
'CleanedLeftPutamen',
'CleanedRightPutamen',
'CleanedLeftThalamus',
'CleanedRightThalamus',
'CleanedLeftAccumben',
'CleanedRightAccumben',
'CleanedLeftGlobus',
'CleanedRightGlobus'
],
function=CreateLabelMap), name="ComputeOneLabelMap")
computeOneLabelMap.inputs.projectid = projectid
computeOneLabelMap.inputs.subjectid = subjectid
computeOneLabelMap.inputs.sessionid = sessionid
computeOneLabelMap.inputs.LabelImageName = "allLabels.nii.gz"
computeOneLabelMap.inputs.CSVFileName = "allLabels_seg.csv"
cutWF.connect(inputsSpec, 'posteriorDictionary', computeOneLabelMap, 'posteriorDictionary')
cutWF.connect(mergeAllLabels, 'out', computeOneLabelMap, 'listOfImages')
outputsSpec = pe.Node(interface=IdentityInterface(fields=[
'outputBinaryLeftCaudate', 'outputBinaryRightCaudate',
'outputBinaryLeftHippocampus', 'outputBinaryRightHippocampus',
'outputBinaryLeftPutamen', 'outputBinaryRightPutamen',
'outputBinaryLeftThalamus', 'outputBinaryRightThalamus',
'outputBinaryLeftAccumben', 'outputBinaryRightAccumben',
'outputBinaryLeftGlobus', 'outputBinaryRightGlobus',
'outputLabelImageName', 'outputCSVFileName',
'xmlFilename']), name='outputspec')
cutWF.connect(computeOneLabelMap, 'outputLabelImageName', outputsSpec, 'outputLabelImageName')
cutWF.connect(computeOneLabelMap, 'outputCSVFileName', outputsSpec, 'outputCSVFileName')
cutWF.connect(computeOneLabelMap, 'CleanedLeftCaudate', outputsSpec, 'outputBinaryLeftCaudate')
cutWF.connect(computeOneLabelMap, 'CleanedRightCaudate', outputsSpec, 'outputBinaryRightCaudate')
cutWF.connect(computeOneLabelMap, 'CleanedLeftHippocampus', outputsSpec, 'outputBinaryLeftHippocampus')
cutWF.connect(computeOneLabelMap, 'CleanedRightHippocampus', outputsSpec, 'outputBinaryRightHippocampus')
cutWF.connect(computeOneLabelMap, 'CleanedLeftPutamen', outputsSpec, 'outputBinaryLeftPutamen')
cutWF.connect(computeOneLabelMap, 'CleanedRightPutamen', outputsSpec, 'outputBinaryRightPutamen')
cutWF.connect(computeOneLabelMap, 'CleanedLeftThalamus', outputsSpec, 'outputBinaryLeftThalamus')
cutWF.connect(computeOneLabelMap, 'CleanedRightThalamus', outputsSpec, 'outputBinaryRightThalamus')
cutWF.connect(computeOneLabelMap, 'CleanedLeftAccumben', outputsSpec, 'outputBinaryLeftAccumben')
cutWF.connect(computeOneLabelMap, 'CleanedRightAccumben', outputsSpec, 'outputBinaryRightAccumben')
cutWF.connect(computeOneLabelMap, 'CleanedLeftGlobus', outputsSpec, 'outputBinaryLeftGlobus')
cutWF.connect(computeOneLabelMap, 'CleanedRightGlobus', outputsSpec, 'outputBinaryRightGlobus')
"""
cutWF.connect(RF12BC, 'outputBinaryLeftCaudate', outputsSpec, 'outputBinaryLeftCaudate')
cutWF.connect(RF12BC, 'outputBinaryRightCaudate', outputsSpec, 'outputBinaryRightCaudate')
cutWF.connect(RF12BC, 'outputBinaryLeftHippocampus', outputsSpec, 'outputBinaryLeftHippocampus')
cutWF.connect(RF12BC, 'outputBinaryRightHippocampus', outputsSpec, 'outputBinaryRightHippocampus')
cutWF.connect(RF12BC, 'outputBinaryLeftPutamen', outputsSpec, 'outputBinaryLeftPutamen')
cutWF.connect(RF12BC, 'outputBinaryRightPutamen', outputsSpec, 'outputBinaryRightPutamen')
cutWF.connect(RF12BC, 'outputBinaryLeftThalamus', outputsSpec, 'outputBinaryLeftThalamus')
cutWF.connect(RF12BC, 'outputBinaryRightThalamus', outputsSpec, 'outputBinaryRightThalamus')
cutWF.connect(RF12BC, 'outputBinaryLeftAccumben', outputsSpec, 'outputBinaryLeftAccumben')
cutWF.connect(RF12BC, 'outputBinaryRightAccumben', outputsSpec, 'outputBinaryRightAccumben')
cutWF.connect(RF12BC, 'outputBinaryLeftGlobus', outputsSpec, 'outputBinaryLeftGlobus')
cutWF.connect(RF12BC, 'outputBinaryRightGlobus', outputsSpec, 'outputBinaryRightGlobus')
"""
cutWF.connect(RF12BC, 'xmlFilename', outputsSpec, 'xmlFilename')
return cutWF