18
18
)
19
19
from nipype .utils .filemanip import split_filename , fname_presuffix
20
20
21
+ from src .interfaces .cat12 .surface import Cell
22
+
21
23
22
24
class CAT12SegmentInputSpec (SPMCommandInputSpec ):
23
25
in_files = InputMultiPath (
@@ -41,6 +43,27 @@ class CAT12SegmentInputSpec(SPMCommandInputSpec):
41
43
copyfile = False ,
42
44
)
43
45
46
+ _help_shoots_tpm = (
47
+ 'Shooting Template %d. The Shooting template must be in multi-volume nifti format and should contain GM,'
48
+ ' WM, and background segmentations and have to be saved with at least 16 bit. '
49
+ )
50
+
51
+ shooting_tpm = ImageFileSPM (exists = True , field = "extopts.registration.shooting.shootingtpm" ,
52
+ desc = _help_shoots_tpm % 0 , mandatory = False , copyfile = False )
53
+
54
+ shooting_tpm_template_1 = ImageFileSPM (
55
+ exists = True , desc = _help_shoots_tpm % 1 , mandatory = False , copyfile = False
56
+ )
57
+ shooting_tpm_template_2 = ImageFileSPM (
58
+ exists = True , desc = _help_shoots_tpm % 2 , mandatory = False , copyfile = False
59
+ )
60
+ shooting_tpm_template_3 = ImageFileSPM (
61
+ exists = True , desc = _help_shoots_tpm % 3 , mandatory = False , copyfile = False
62
+ )
63
+ shooting_tpm_template_4 = ImageFileSPM (
64
+ exists = True , desc = _help_shoots_tpm % 4 , mandatory = False , copyfile = False
65
+ )
66
+
44
67
n_jobs = traits .Int (
45
68
1 , usedefault = True , mandatory = True , field = "nproc" , desc = "Number of threads"
46
69
)
@@ -239,13 +262,6 @@ class CAT12SegmentInputSpec(SPMCommandInputSpec):
239
262
copyfile = False ,
240
263
)
241
264
242
- _dartel_help = (
243
- "This option is to export data into a form that can be used with DARTEL. The SPM default is to "
244
- "only apply rigid body transformation. However, a more appropriate option is to apply affine "
245
- "transformation, because the additional scaling of the images requires less deformations to "
246
- "non-linearly register brains to the template."
247
- )
248
-
249
265
# Grey matter
250
266
gm_output_native = traits .Bool (
251
267
False ,
@@ -495,11 +511,14 @@ def __init__(self, **inputs):
495
511
496
512
def _format_arg (self , opt , spec , val ):
497
513
"""Convert input to appropriate format for spm"""
498
- if opt in [ "in_files" ] :
514
+ if opt == "in_files" :
499
515
if isinstance (val , list ):
500
516
return scans_for_fnames (val )
501
517
else :
502
518
return scans_for_fname (val )
519
+ elif opt in ["tpm" , "shooting_tpm" ]:
520
+ return Cell2Str (val )
521
+
503
522
return super (CAT12Segment , self )._format_arg (opt , spec , val )
504
523
505
524
def _list_outputs (self ):
@@ -513,9 +532,7 @@ def _list_outputs(self):
513
532
514
533
for tidx , tissue in enumerate (["gm" , "wm" , "csf" ]):
515
534
516
- for idx , (image , prefix ) in enumerate (
517
- [("modulated" , "mw" ), ("dartel" , "r" ), ("native" , "" )]
518
- ):
535
+ for image , prefix in [("modulated" , "mw" ), ("dartel" , "r" ), ("native" , "" )]:
519
536
outtype = f"{ tissue } _output_{ image } "
520
537
if isdefined (getattr (self .inputs , outtype )) and getattr (
521
538
self .inputs , outtype
@@ -552,7 +569,7 @@ def _list_outputs(self):
552
569
str (report ) for report in Path (pth ).glob ("report/*" ) if report .is_file ()
553
570
]
554
571
555
- outputs [f "report" ] = fname_presuffix (
572
+ outputs ["report" ] = fname_presuffix (
556
573
f , prefix = os .path .join ("report" , f"cat_" ), suffix = ".xml" , use_ext = False
557
574
)
558
575
@@ -561,10 +578,18 @@ def _list_outputs(self):
561
578
]
562
579
563
580
outputs ["label_rois" ] = fname_presuffix (
564
- f , prefix = os .path .join ("label" , f "catROIs_" ), suffix = ".xml" , use_ext = False
581
+ f , prefix = os .path .join ("label" , "catROIs_" ), suffix = ".xml" , use_ext = False
565
582
)
566
583
outputs ["label_roi" ] = fname_presuffix (
567
- f , prefix = os .path .join ("label" , f "catROI_" ), suffix = ".xml" , use_ext = False
584
+ f , prefix = os .path .join ("label" , "catROI_" ), suffix = ".xml" , use_ext = False
568
585
)
569
586
570
587
return outputs
588
+
589
+
590
+ class Cell2Str (Cell ):
591
+
592
+ def __str__ (self ):
593
+ """Convert input to appropriate format for cat12
594
+ """
595
+ return "{'%s'}" % self .to_string ()
0 commit comments