-
Notifications
You must be signed in to change notification settings - Fork 520
/
brains.py
1350 lines (1084 loc) · 45.8 KB
/
brains.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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
# -*- coding: utf8 -*-
"""Autogenerated file - DO NOT EDIT
If you spot a bug, please report it on the mailing list and/or change the generator."""
import os
from ...base import (
CommandLine,
CommandLineInputSpec,
SEMLikeCommandLine,
TraitedSpec,
File,
Directory,
traits,
isdefined,
InputMultiPath,
OutputMultiPath,
)
class BRAINSConstellationModelerInputSpec(CommandLineInputSpec):
verbose = traits.Bool(
desc=", Show more verbose output, ",
argstr="--verbose ",
)
inputTrainingList = File(
desc=", Setup file, giving all parameters for training up a template model for each landmark., ",
exists=True,
argstr="--inputTrainingList %s",
)
outputModel = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc=", The full filename of the output model file., ",
argstr="--outputModel %s",
)
saveOptimizedLandmarks = traits.Bool(
desc=", Flag to make a new subject-specific landmark definition file in the same format produced by Slicer3 with the optimized landmark (the detected RP, AC, and PC) in it. Useful to tighten the variances in the ConstellationModeler., ",
argstr="--saveOptimizedLandmarks ",
)
optimizedLandmarksFilenameExtender = traits.Str(
desc=", If the trainingList is (indexFullPathName) and contains landmark data filenames [path]/[filename].fcsv , make the optimized landmarks filenames out of [path]/[filename](thisExtender) and the optimized version of the input trainingList out of (indexFullPathName)(thisExtender) , when you rewrite all the landmarks according to the saveOptimizedLandmarks flag., ",
argstr="--optimizedLandmarksFilenameExtender %s",
)
resultsDir = traits.Either(
traits.Bool,
Directory(),
hash_files=False,
desc=", The directory for the results to be written., ",
argstr="--resultsDir %s",
)
mspQualityLevel = traits.Int(
desc=", Flag cotrols how agressive the MSP is estimated. 0=quick estimate (9 seconds), 1=normal estimate (11 seconds), 2=great estimate (22 seconds), 3=best estimate (58 seconds)., ",
argstr="--mspQualityLevel %d",
)
rescaleIntensities = traits.Bool(
desc=", Flag to turn on rescaling image intensities on input., ",
argstr="--rescaleIntensities ",
)
trimRescaledIntensities = traits.Float(
desc=", Turn on clipping the rescaled image one-tailed on input. Units of standard deviations above the mean. Very large values are very permissive. Non-positive value turns clipping off. Defaults to removing 0.00001 of a normal tail above the mean., ",
argstr="--trimRescaledIntensities %f",
)
rescaleIntensitiesOutputRange = InputMultiPath(
traits.Int,
desc=", This pair of integers gives the lower and upper bounds on the signal portion of the output image. Out-of-field voxels are taken from BackgroundFillValue., ",
sep=",",
argstr="--rescaleIntensitiesOutputRange %s",
)
BackgroundFillValue = traits.Str(
desc="Fill the background of image with specified short int value. Enter number or use BIGNEG for a large negative number.",
argstr="--BackgroundFillValue %s",
)
writedebuggingImagesLevel = traits.Int(
desc=", This flag controls if debugging images are produced. By default value of 0 is no images. Anything greater than zero will be increasing level of debugging images., ",
argstr="--writedebuggingImagesLevel %d",
)
numberOfThreads = traits.Int(
desc="Explicitly specify the maximum number of threads to use.",
argstr="--numberOfThreads %d",
)
class BRAINSConstellationModelerOutputSpec(TraitedSpec):
outputModel = File(
desc=", The full filename of the output model file., ",
exists=True,
)
resultsDir = Directory(
desc=", The directory for the results to be written., ",
exists=True,
)
class BRAINSConstellationModeler(SEMLikeCommandLine):
"""title: Generate Landmarks Model (BRAINS)
category: Utilities.BRAINS
description: Train up a model for BRAINSConstellationDetector
"""
input_spec = BRAINSConstellationModelerInputSpec
output_spec = BRAINSConstellationModelerOutputSpec
_cmd = " BRAINSConstellationModeler "
_outputs_filenames = {"outputModel": "outputModel.mdl", "resultsDir": "resultsDir"}
_redirect_x = False
class landmarksConstellationWeightsInputSpec(CommandLineInputSpec):
inputTrainingList = File(
desc=", Setup file, giving all parameters for training up a Weight list for landmark., ",
exists=True,
argstr="--inputTrainingList %s",
)
inputTemplateModel = File(
desc="User-specified template model., ",
exists=True,
argstr="--inputTemplateModel %s",
)
LLSModel = File(
desc="Linear least squares model filename in HD5 format",
exists=True,
argstr="--LLSModel %s",
)
outputWeightsList = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc=", The filename of a csv file which is a list of landmarks and their corresponding weights., ",
argstr="--outputWeightsList %s",
)
class landmarksConstellationWeightsOutputSpec(TraitedSpec):
outputWeightsList = File(
desc=", The filename of a csv file which is a list of landmarks and their corresponding weights., ",
exists=True,
)
class landmarksConstellationWeights(SEMLikeCommandLine):
"""title: Generate Landmarks Weights (BRAINS)
category: Utilities.BRAINS
description: Train up a list of Weights for the Landmarks in BRAINSConstellationDetector
"""
input_spec = landmarksConstellationWeightsInputSpec
output_spec = landmarksConstellationWeightsOutputSpec
_cmd = " landmarksConstellationWeights "
_outputs_filenames = {"outputWeightsList": "outputWeightsList.wts"}
_redirect_x = False
class BRAINSTrimForegroundInDirectionInputSpec(CommandLineInputSpec):
inputVolume = File(
desc="Input image to trim off the neck (and also air-filling noise.)",
exists=True,
argstr="--inputVolume %s",
)
outputVolume = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Output image with neck and air-filling noise trimmed isotropic image with AC at center of image.",
argstr="--outputVolume %s",
)
directionCode = traits.Int(
desc=", This flag chooses which dimension to compare. The sign lets you flip direction., ",
argstr="--directionCode %d",
)
otsuPercentileThreshold = traits.Float(
desc=", This is a parameter to FindLargestForegroundFilledMask, which is employed to trim off air-filling noise., ",
argstr="--otsuPercentileThreshold %f",
)
closingSize = traits.Int(
desc=", This is a parameter to FindLargestForegroundFilledMask, ",
argstr="--closingSize %d",
)
headSizeLimit = traits.Float(
desc=", Use this to vary from the command line our search for how much upper tissue is head for the center-of-mass calculation. Units are CCs, not cubic millimeters., ",
argstr="--headSizeLimit %f",
)
BackgroundFillValue = traits.Str(
desc="Fill the background of image with specified short int value. Enter number or use BIGNEG for a large negative number.",
argstr="--BackgroundFillValue %s",
)
numberOfThreads = traits.Int(
desc="Explicitly specify the maximum number of threads to use.",
argstr="--numberOfThreads %d",
)
class BRAINSTrimForegroundInDirectionOutputSpec(TraitedSpec):
outputVolume = File(
desc="Output image with neck and air-filling noise trimmed isotropic image with AC at center of image.",
exists=True,
)
class BRAINSTrimForegroundInDirection(SEMLikeCommandLine):
"""title: Trim Foreground In Direction (BRAINS)
category: Utilities.BRAINS
description: This program will trim off the neck and also air-filling noise from the inputImage.
version: 0.1
documentation-url: http://www.nitrc.org/projects/art/
"""
input_spec = BRAINSTrimForegroundInDirectionInputSpec
output_spec = BRAINSTrimForegroundInDirectionOutputSpec
_cmd = " BRAINSTrimForegroundInDirection "
_outputs_filenames = {"outputVolume": "outputVolume.nii"}
_redirect_x = False
class BRAINSLmkTransformInputSpec(CommandLineInputSpec):
inputMovingLandmarks = File(
desc="Input Moving Landmark list file in fcsv, ",
exists=True,
argstr="--inputMovingLandmarks %s",
)
inputFixedLandmarks = File(
desc="Input Fixed Landmark list file in fcsv, ",
exists=True,
argstr="--inputFixedLandmarks %s",
)
outputAffineTransform = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="The filename for the estimated affine transform, ",
argstr="--outputAffineTransform %s",
)
inputMovingVolume = File(
desc="The filename of input moving volume",
exists=True,
argstr="--inputMovingVolume %s",
)
inputReferenceVolume = File(
desc="The filename of the reference volume",
exists=True,
argstr="--inputReferenceVolume %s",
)
outputResampledVolume = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="The filename of the output resampled volume",
argstr="--outputResampledVolume %s",
)
numberOfThreads = traits.Int(
desc="Explicitly specify the maximum number of threads to use.",
argstr="--numberOfThreads %d",
)
class BRAINSLmkTransformOutputSpec(TraitedSpec):
outputAffineTransform = File(
desc="The filename for the estimated affine transform, ",
exists=True,
)
outputResampledVolume = File(
desc="The filename of the output resampled volume", exists=True
)
class BRAINSLmkTransform(SEMLikeCommandLine):
"""title: Landmark Transform (BRAINS)
category: Utilities.BRAINS
description: This utility program estimates the affine transform to align the fixed landmarks to the moving landmarks, and then generate the resampled moving image to the same physical space as that of the reference image.
version: 1.0
documentation-url: http://www.nitrc.org/projects/brainscdetector/
"""
input_spec = BRAINSLmkTransformInputSpec
output_spec = BRAINSLmkTransformOutputSpec
_cmd = " BRAINSLmkTransform "
_outputs_filenames = {
"outputResampledVolume": "outputResampledVolume.nii",
"outputAffineTransform": "outputAffineTransform.h5",
}
_redirect_x = False
class BRAINSMushInputSpec(CommandLineInputSpec):
inputFirstVolume = File(
desc="Input image (1) for mixture optimization",
exists=True,
argstr="--inputFirstVolume %s",
)
inputSecondVolume = File(
desc="Input image (2) for mixture optimization",
exists=True,
argstr="--inputSecondVolume %s",
)
inputMaskVolume = File(
desc="Input label image for mixture optimization",
exists=True,
argstr="--inputMaskVolume %s",
)
outputWeightsFile = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Output Weights File",
argstr="--outputWeightsFile %s",
)
outputVolume = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="The MUSH image produced from the T1 and T2 weighted images",
argstr="--outputVolume %s",
)
outputMask = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="The brain volume mask generated from the MUSH image",
argstr="--outputMask %s",
)
seed = InputMultiPath(
traits.Int,
desc="Seed Point for Brain Region Filling",
sep=",",
argstr="--seed %s",
)
desiredMean = traits.Float(
desc="Desired mean within the mask for weighted sum of both images.",
argstr="--desiredMean %f",
)
desiredVariance = traits.Float(
desc="Desired variance within the mask for weighted sum of both images.",
argstr="--desiredVariance %f",
)
lowerThresholdFactorPre = traits.Float(
desc="Lower threshold factor for finding an initial brain mask",
argstr="--lowerThresholdFactorPre %f",
)
upperThresholdFactorPre = traits.Float(
desc="Upper threshold factor for finding an initial brain mask",
argstr="--upperThresholdFactorPre %f",
)
lowerThresholdFactor = traits.Float(
desc="Lower threshold factor for defining the brain mask",
argstr="--lowerThresholdFactor %f",
)
upperThresholdFactor = traits.Float(
desc="Upper threshold factor for defining the brain mask",
argstr="--upperThresholdFactor %f",
)
boundingBoxSize = InputMultiPath(
traits.Int,
desc="Size of the cubic bounding box mask used when no brain mask is present",
sep=",",
argstr="--boundingBoxSize %s",
)
boundingBoxStart = InputMultiPath(
traits.Int,
desc="XYZ point-coordinate for the start of the cubic bounding box mask used when no brain mask is present",
sep=",",
argstr="--boundingBoxStart %s",
)
numberOfThreads = traits.Int(
desc="Explicitly specify the maximum number of threads to use.",
argstr="--numberOfThreads %d",
)
class BRAINSMushOutputSpec(TraitedSpec):
outputWeightsFile = File(desc="Output Weights File", exists=True)
outputVolume = File(
desc="The MUSH image produced from the T1 and T2 weighted images", exists=True
)
outputMask = File(
desc="The brain volume mask generated from the MUSH image", exists=True
)
class BRAINSMush(SEMLikeCommandLine):
"""title: Brain Extraction from T1/T2 image (BRAINS)
category: Utilities.BRAINS
description: This program: 1) generates a weighted mixture image optimizing the mean and variance and 2) produces a mask of the brain volume
version: 0.1.0.$Revision: 1.4 $(alpha)
documentation-url: http:://mri.radiology.uiowa.edu
license: https://www.nitrc.org/svn/brains/BuildScripts/trunk/License.txt
contributor: This tool is a modification by Steven Dunn of a program developed by Greg Harris and Ron Pierson.
acknowledgements: This work was developed by the University of Iowa Departments of Radiology and Psychiatry. This software was supported in part of NIH/NINDS award NS050568.
"""
input_spec = BRAINSMushInputSpec
output_spec = BRAINSMushOutputSpec
_cmd = " BRAINSMush "
_outputs_filenames = {
"outputMask": "outputMask.nii.gz",
"outputWeightsFile": "outputWeightsFile.txt",
"outputVolume": "outputVolume.nii.gz",
}
_redirect_x = False
class BRAINSTransformConvertInputSpec(CommandLineInputSpec):
inputTransform = File(exists=True, argstr="--inputTransform %s")
referenceVolume = File(exists=True, argstr="--referenceVolume %s")
outputTransformType = traits.Enum(
"Affine",
"VersorRigid",
"ScaleVersor",
"ScaleSkewVersor",
"DisplacementField",
"Same",
desc="The target transformation type. Must be conversion-compatible with the input transform type",
argstr="--outputTransformType %s",
)
outputPrecisionType = traits.Enum(
"double",
"float",
desc="Precision type of the output transform. It can be either single precision or double precision",
argstr="--outputPrecisionType %s",
)
displacementVolume = traits.Either(
traits.Bool, File(), hash_files=False, argstr="--displacementVolume %s"
)
outputTransform = traits.Either(
traits.Bool, File(), hash_files=False, argstr="--outputTransform %s"
)
class BRAINSTransformConvertOutputSpec(TraitedSpec):
displacementVolume = File(exists=True)
outputTransform = File(exists=True)
class BRAINSTransformConvert(SEMLikeCommandLine):
"""title: BRAINS Transform Convert
category: Utilities.BRAINS
description: Convert ITK transforms to higher order transforms
version: 1.0
documentation-url: A utility to convert between transform file formats.
license: https://www.nitrc.org/svn/brains/BuildScripts/trunk/License.txt
contributor: Hans J. Johnson,Kent Williams, Ali Ghayoor
"""
input_spec = BRAINSTransformConvertInputSpec
output_spec = BRAINSTransformConvertOutputSpec
_cmd = " BRAINSTransformConvert "
_outputs_filenames = {
"displacementVolume": "displacementVolume.nii",
"outputTransform": "outputTransform.mat",
}
_redirect_x = False
class landmarksConstellationAlignerInputSpec(CommandLineInputSpec):
inputLandmarksPaired = File(
desc="Input landmark file (.fcsv)",
exists=True,
argstr="--inputLandmarksPaired %s",
)
outputLandmarksPaired = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Output landmark file (.fcsv)",
argstr="--outputLandmarksPaired %s",
)
class landmarksConstellationAlignerOutputSpec(TraitedSpec):
outputLandmarksPaired = File(desc="Output landmark file (.fcsv)", exists=True)
class landmarksConstellationAligner(SEMLikeCommandLine):
"""title: MidACPC Landmark Insertion
category: Utilities.BRAINS
description: This program converts the original landmark files to the acpc-aligned landmark files
contributor: Ali Ghayoor
"""
input_spec = landmarksConstellationAlignerInputSpec
output_spec = landmarksConstellationAlignerOutputSpec
_cmd = " landmarksConstellationAligner "
_outputs_filenames = {"outputLandmarksPaired": "outputLandmarksPaired"}
_redirect_x = False
class BRAINSEyeDetectorInputSpec(CommandLineInputSpec):
numberOfThreads = traits.Int(
desc="Explicitly specify the maximum number of threads to use.",
argstr="--numberOfThreads %d",
)
inputVolume = File(desc="The input volume", exists=True, argstr="--inputVolume %s")
outputVolume = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="The output volume",
argstr="--outputVolume %s",
)
debugDir = traits.Str(desc="A place for debug information", argstr="--debugDir %s")
class BRAINSEyeDetectorOutputSpec(TraitedSpec):
outputVolume = File(desc="The output volume", exists=True)
class BRAINSEyeDetector(SEMLikeCommandLine):
"""title: Eye Detector (BRAINS)
category: Utilities.BRAINS
version: 1.0
documentation-url: http://www.nitrc.org/projects/brainscdetector/
"""
input_spec = BRAINSEyeDetectorInputSpec
output_spec = BRAINSEyeDetectorOutputSpec
_cmd = " BRAINSEyeDetector "
_outputs_filenames = {"outputVolume": "outputVolume.nii"}
_redirect_x = False
class BRAINSLinearModelerEPCAInputSpec(CommandLineInputSpec):
inputTrainingList = File(
desc="Input Training Landmark List Filename, ",
exists=True,
argstr="--inputTrainingList %s",
)
numberOfThreads = traits.Int(
desc="Explicitly specify the maximum number of threads to use.",
argstr="--numberOfThreads %d",
)
class BRAINSLinearModelerEPCAOutputSpec(TraitedSpec):
pass
class BRAINSLinearModelerEPCA(SEMLikeCommandLine):
"""title: Landmark Linear Modeler (BRAINS)
category: Utilities.BRAINS
description: Training linear model using EPCA. Implementation based on my MS thesis, "A METHOD FOR AUTOMATED LANDMARK CONSTELLATION DETECTION USING EVOLUTIONARY PRINCIPAL COMPONENTS AND STATISTICAL SHAPE MODELS"
version: 1.0
documentation-url: http://www.nitrc.org/projects/brainscdetector/
"""
input_spec = BRAINSLinearModelerEPCAInputSpec
output_spec = BRAINSLinearModelerEPCAOutputSpec
_cmd = " BRAINSLinearModelerEPCA "
_outputs_filenames = {}
_redirect_x = False
class BRAINSInitializedControlPointsInputSpec(CommandLineInputSpec):
inputVolume = File(desc="Input Volume", exists=True, argstr="--inputVolume %s")
outputVolume = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Output Volume",
argstr="--outputVolume %s",
)
splineGridSize = InputMultiPath(
traits.Int,
desc="The number of subdivisions of the BSpline Grid to be centered on the image space. Each dimension must have at least 3 subdivisions for the BSpline to be correctly computed. ",
sep=",",
argstr="--splineGridSize %s",
)
permuteOrder = InputMultiPath(
traits.Int,
desc="The permutation order for the images. The default is 0,1,2 (i.e. no permutation)",
sep=",",
argstr="--permuteOrder %s",
)
outputLandmarksFile = traits.Str(
desc="Output filename", argstr="--outputLandmarksFile %s"
)
numberOfThreads = traits.Int(
desc="Explicitly specify the maximum number of threads to use.",
argstr="--numberOfThreads %d",
)
class BRAINSInitializedControlPointsOutputSpec(TraitedSpec):
outputVolume = File(desc="Output Volume", exists=True)
class BRAINSInitializedControlPoints(SEMLikeCommandLine):
"""title: Initialized Control Points (BRAINS)
category: Utilities.BRAINS
description: Outputs bspline control points as landmarks
version: 0.1.0.$Revision: 916 $(alpha)
license: https://www.nitrc.org/svn/brains/BuildScripts/trunk/License.txt
contributor: Mark Scully
acknowledgements: This work is part of the National Alliance for Medical Image Computing (NAMIC), funded by the National Institutes of Health through the NIH Roadmap for Medical Research, Grant U54 EB005149. Additional support for Mark Scully and Hans Johnson at the University of Iowa.
"""
input_spec = BRAINSInitializedControlPointsInputSpec
output_spec = BRAINSInitializedControlPointsOutputSpec
_cmd = " BRAINSInitializedControlPoints "
_outputs_filenames = {"outputVolume": "outputVolume.nii"}
_redirect_x = False
class CleanUpOverlapLabelsInputSpec(CommandLineInputSpec):
inputBinaryVolumes = InputMultiPath(
File(exists=True),
desc="The list of binary images to be checked and cleaned up. Order is important. Binary volume given first always wins out. ",
argstr="--inputBinaryVolumes %s...",
)
outputBinaryVolumes = traits.Either(
traits.Bool,
InputMultiPath(File(),),
hash_files=False,
desc="The output label map images, with integer values in it. Each label value specified in the inputLabels is combined into this output label map volume",
argstr="--outputBinaryVolumes %s...",
)
class CleanUpOverlapLabelsOutputSpec(TraitedSpec):
outputBinaryVolumes = OutputMultiPath(
File(exists=True),
desc="The output label map images, with integer values in it. Each label value specified in the inputLabels is combined into this output label map volume",
)
class CleanUpOverlapLabels(SEMLikeCommandLine):
"""title: Clean Up Overla Labels
category: Utilities.BRAINS
description: Take a series of input binary images and clean up for those overlapped area. Binary volumes given first always wins out
version: 0.1.0
contributor: Eun Young Kim
"""
input_spec = CleanUpOverlapLabelsInputSpec
output_spec = CleanUpOverlapLabelsOutputSpec
_cmd = " CleanUpOverlapLabels "
_outputs_filenames = {"outputBinaryVolumes": "outputBinaryVolumes.nii"}
_redirect_x = False
class BRAINSClipInferiorInputSpec(CommandLineInputSpec):
inputVolume = File(
desc="Input image to make a clipped short int copy from.",
exists=True,
argstr="--inputVolume %s",
)
outputVolume = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Output image, a short int copy of the upper portion of the input image, filled with BackgroundFillValue.",
argstr="--outputVolume %s",
)
acLowerBound = traits.Float(
desc=", When the input image to the output image, replace the image with the BackgroundFillValue everywhere below the plane This Far in physical units (millimeters) below (inferior to) the AC point (assumed to be the voxel field middle.) The oversize default was chosen to have no effect. Based on visualizing a thousand masks in the IPIG study, we recommend a limit no smaller than 80.0 mm., ",
argstr="--acLowerBound %f",
)
BackgroundFillValue = traits.Str(
desc="Fill the background of image with specified short int value. Enter number or use BIGNEG for a large negative number.",
argstr="--BackgroundFillValue %s",
)
numberOfThreads = traits.Int(
desc="Explicitly specify the maximum number of threads to use.",
argstr="--numberOfThreads %d",
)
class BRAINSClipInferiorOutputSpec(TraitedSpec):
outputVolume = File(
desc="Output image, a short int copy of the upper portion of the input image, filled with BackgroundFillValue.",
exists=True,
)
class BRAINSClipInferior(SEMLikeCommandLine):
"""title: Clip Inferior of Center of Brain (BRAINS)
category: Utilities.BRAINS
description: This program will read the inputVolume as a short int image, write the BackgroundFillValue everywhere inferior to the lower bound, and write the resulting clipped short int image in the outputVolume.
version: 1.0
"""
input_spec = BRAINSClipInferiorInputSpec
output_spec = BRAINSClipInferiorOutputSpec
_cmd = " BRAINSClipInferior "
_outputs_filenames = {"outputVolume": "outputVolume.nii"}
_redirect_x = False
class GenerateLabelMapFromProbabilityMapInputSpec(CommandLineInputSpec):
inputVolumes = InputMultiPath(
File(exists=True),
desc="The Input probaiblity images to be computed for lable maps",
argstr="--inputVolumes %s...",
)
outputLabelVolume = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="The Input binary image for region of interest",
argstr="--outputLabelVolume %s",
)
numberOfThreads = traits.Int(
desc="Explicitly specify the maximum number of threads to use.",
argstr="--numberOfThreads %d",
)
class GenerateLabelMapFromProbabilityMapOutputSpec(TraitedSpec):
outputLabelVolume = File(
desc="The Input binary image for region of interest", exists=True
)
class GenerateLabelMapFromProbabilityMap(SEMLikeCommandLine):
"""title: Label Map from Probability Images
category: Utilities.BRAINS
description: Given a list of probability maps for labels, create a discrete label map where only the highest probability region is used for the labeling.
version: 0.1
contributor: University of Iowa Department of Psychiatry, http:://www.psychiatry.uiowa.edu
"""
input_spec = GenerateLabelMapFromProbabilityMapInputSpec
output_spec = GenerateLabelMapFromProbabilityMapOutputSpec
_cmd = " GenerateLabelMapFromProbabilityMap "
_outputs_filenames = {"outputLabelVolume": "outputLabelVolume.nii.gz"}
_redirect_x = False
class BRAINSAlignMSPInputSpec(CommandLineInputSpec):
inputVolume = File(
desc=", The Image to be resampled, ",
exists=True,
argstr="--inputVolume %s",
)
OutputresampleMSP = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc=", The image to be output., ",
argstr="--OutputresampleMSP %s",
)
verbose = traits.Bool(
desc=", Show more verbose output, ", argstr="--verbose "
)
resultsDir = traits.Either(
traits.Bool,
Directory(),
hash_files=False,
desc=", The directory for the results to be written., ",
argstr="--resultsDir %s",
)
writedebuggingImagesLevel = traits.Int(
desc=", This flag controls if debugging images are produced. By default value of 0 is no images. Anything greater than zero will be increasing level of debugging images., ",
argstr="--writedebuggingImagesLevel %d",
)
mspQualityLevel = traits.Int(
desc=", Flag cotrols how agressive the MSP is estimated. 0=quick estimate (9 seconds), 1=normal estimate (11 seconds), 2=great estimate (22 seconds), 3=best estimate (58 seconds)., ",
argstr="--mspQualityLevel %d",
)
rescaleIntensities = traits.Bool(
desc=", Flag to turn on rescaling image intensities on input., ",
argstr="--rescaleIntensities ",
)
trimRescaledIntensities = traits.Float(
desc=", Turn on clipping the rescaled image one-tailed on input. Units of standard deviations above the mean. Very large values are very permissive. Non-positive value turns clipping off. Defaults to removing 0.00001 of a normal tail above the mean., ",
argstr="--trimRescaledIntensities %f",
)
rescaleIntensitiesOutputRange = InputMultiPath(
traits.Int,
desc=", This pair of integers gives the lower and upper bounds on the signal portion of the output image. Out-of-field voxels are taken from BackgroundFillValue., ",
sep=",",
argstr="--rescaleIntensitiesOutputRange %s",
)
BackgroundFillValue = traits.Str(
desc="Fill the background of image with specified short int value. Enter number or use BIGNEG for a large negative number.",
argstr="--BackgroundFillValue %s",
)
interpolationMode = traits.Enum(
"NearestNeighbor",
"Linear",
"ResampleInPlace",
"BSpline",
"WindowedSinc",
"Hamming",
"Cosine",
"Welch",
"Lanczos",
"Blackman",
desc="Type of interpolation to be used when applying transform to moving volume. Options are Linear, ResampleInPlace, NearestNeighbor, BSpline, or WindowedSinc",
argstr="--interpolationMode %s",
)
numberOfThreads = traits.Int(
desc="Explicitly specify the maximum number of threads to use.",
argstr="--numberOfThreads %d",
)
class BRAINSAlignMSPOutputSpec(TraitedSpec):
OutputresampleMSP = File(
desc=", The image to be output., ", exists=True
)
resultsDir = Directory(
desc=", The directory for the results to be written., ",
exists=True,
)
class BRAINSAlignMSP(SEMLikeCommandLine):
"""title: Align Mid Saggital Brain (BRAINS)
category: Utilities.BRAINS
description: Resample an image into ACPC alignement ACPCDetect
"""
input_spec = BRAINSAlignMSPInputSpec
output_spec = BRAINSAlignMSPOutputSpec
_cmd = " BRAINSAlignMSP "
_outputs_filenames = {
"OutputresampleMSP": "OutputresampleMSP.nii",
"resultsDir": "resultsDir",
}
_redirect_x = False
class BRAINSLandmarkInitializerInputSpec(CommandLineInputSpec):
inputFixedLandmarkFilename = File(
desc="input fixed landmark. *.fcsv",
exists=True,
argstr="--inputFixedLandmarkFilename %s",
)
inputMovingLandmarkFilename = File(
desc="input moving landmark. *.fcsv",
exists=True,
argstr="--inputMovingLandmarkFilename %s",
)
inputWeightFilename = File(
desc="Input weight file name for landmarks. Higher weighted landmark will be considered more heavily. Weights are propotional, that is the magnitude of weights will be normalized by its minimum and maximum value. ",
exists=True,
argstr="--inputWeightFilename %s",
)
outputTransformFilename = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="output transform file name (ex: ./outputTransform.mat) ",
argstr="--outputTransformFilename %s",
)
class BRAINSLandmarkInitializerOutputSpec(TraitedSpec):
outputTransformFilename = File(
desc="output transform file name (ex: ./outputTransform.mat) ", exists=True
)
class BRAINSLandmarkInitializer(SEMLikeCommandLine):
"""title: BRAINSLandmarkInitializer
category: Utilities.BRAINS
description: Create transformation file (*mat) from a pair of landmarks (*fcsv) files.
version: 1.0
license: https://www.nitrc.org/svn/brains/BuildScripts/trunk/License.txt
contributor: Eunyoung Regina Kim
"""
input_spec = BRAINSLandmarkInitializerInputSpec
output_spec = BRAINSLandmarkInitializerOutputSpec
_cmd = " BRAINSLandmarkInitializer "
_outputs_filenames = {"outputTransformFilename": "outputTransformFilename"}
_redirect_x = False
class insertMidACPCpointInputSpec(CommandLineInputSpec):
inputLandmarkFile = File(
desc="Input landmark file (.fcsv)", exists=True, argstr="--inputLandmarkFile %s"
)
outputLandmarkFile = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Output landmark file (.fcsv)",
argstr="--outputLandmarkFile %s",
)
class insertMidACPCpointOutputSpec(TraitedSpec):
outputLandmarkFile = File(desc="Output landmark file (.fcsv)", exists=True)
class insertMidACPCpoint(SEMLikeCommandLine):
"""title: MidACPC Landmark Insertion
category: Utilities.BRAINS
description: This program gets a landmark fcsv file and adds a new landmark as the midpoint between AC and PC points to the output landmark fcsv file
contributor: Ali Ghayoor
"""
input_spec = insertMidACPCpointInputSpec
output_spec = insertMidACPCpointOutputSpec
_cmd = " insertMidACPCpoint "
_outputs_filenames = {"outputLandmarkFile": "outputLandmarkFile"}
_redirect_x = False
class BRAINSSnapShotWriterInputSpec(CommandLineInputSpec):
inputVolumes = InputMultiPath(
File(exists=True),
desc="Input image volume list to be extracted as 2D image. Multiple input is possible. At least one input is required.",
argstr="--inputVolumes %s...",
)
inputBinaryVolumes = InputMultiPath(
File(exists=True),
desc="Input mask (binary) volume list to be extracted as 2D image. Multiple input is possible.",
argstr="--inputBinaryVolumes %s...",
)
inputSliceToExtractInPhysicalPoint = InputMultiPath(
traits.Float,
desc="2D slice number of input images. For autoWorkUp output, which AC-PC aligned, 0,0,0 will be the center.",
sep=",",
argstr="--inputSliceToExtractInPhysicalPoint %s",
)
inputSliceToExtractInIndex = InputMultiPath(
traits.Int,
desc="2D slice number of input images. For size of 256*256*256 image, 128 is usually used.",
sep=",",
argstr="--inputSliceToExtractInIndex %s",