1818)
1919from nipype .utils .filemanip import split_filename , fname_presuffix
2020
21+ from src .interfaces .cat12 .surface import Cell
22+
2123
2224class CAT12SegmentInputSpec (SPMCommandInputSpec ):
2325 in_files = InputMultiPath (
@@ -41,6 +43,27 @@ class CAT12SegmentInputSpec(SPMCommandInputSpec):
4143 copyfile = False ,
4244 )
4345
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+
4467 n_jobs = traits .Int (
4568 1 , usedefault = True , mandatory = True , field = "nproc" , desc = "Number of threads"
4669 )
@@ -239,13 +262,6 @@ class CAT12SegmentInputSpec(SPMCommandInputSpec):
239262 copyfile = False ,
240263 )
241264
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-
249265 # Grey matter
250266 gm_output_native = traits .Bool (
251267 False ,
@@ -495,11 +511,14 @@ def __init__(self, **inputs):
495511
496512 def _format_arg (self , opt , spec , val ):
497513 """Convert input to appropriate format for spm"""
498- if opt in [ "in_files" ] :
514+ if opt == "in_files" :
499515 if isinstance (val , list ):
500516 return scans_for_fnames (val )
501517 else :
502518 return scans_for_fname (val )
519+ elif opt in ["tpm" , "shooting_tpm" ]:
520+ return Cell2Str (val )
521+
503522 return super (CAT12Segment , self )._format_arg (opt , spec , val )
504523
505524 def _list_outputs (self ):
@@ -513,9 +532,7 @@ def _list_outputs(self):
513532
514533 for tidx , tissue in enumerate (["gm" , "wm" , "csf" ]):
515534
516- for idx , (image , prefix ) in enumerate (
517- [("modulated" , "mw" ), ("dartel" , "r" ), ("native" , "" )]
518- ):
535+ for image , prefix in [("modulated" , "mw" ), ("dartel" , "r" ), ("native" , "" )]:
519536 outtype = f"{ tissue } _output_{ image } "
520537 if isdefined (getattr (self .inputs , outtype )) and getattr (
521538 self .inputs , outtype
@@ -552,7 +569,7 @@ def _list_outputs(self):
552569 str (report ) for report in Path (pth ).glob ("report/*" ) if report .is_file ()
553570 ]
554571
555- outputs [f "report" ] = fname_presuffix (
572+ outputs ["report" ] = fname_presuffix (
556573 f , prefix = os .path .join ("report" , f"cat_" ), suffix = ".xml" , use_ext = False
557574 )
558575
@@ -561,10 +578,18 @@ def _list_outputs(self):
561578 ]
562579
563580 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
565582 )
566583 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
568585 )
569586
570587 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