@@ -656,7 +656,7 @@ class CenterMassInputSpec(CommandLineInputSpec):
656
656
name_template = '%s_cm.out' ,
657
657
keep_extension = False ,
658
658
descr = "File to write center of mass to" ,
659
- argstr = " > %s" ,
659
+ argstr = "> %s" ,
660
660
position = - 1 )
661
661
mask_file = File (
662
662
desc = 'Only voxels with nonzero values in the provided mask will be '
@@ -681,7 +681,7 @@ class CenterMassInputSpec(CommandLineInputSpec):
681
681
'v1, v2, etc. This option is handy for getting ROI centers of '
682
682
'mass.' ,
683
683
argstr = '-roi_vals %s' )
684
- automask = traits .Bool (
684
+ all_rois = traits .Bool (
685
685
desc = 'Don\' t bother listing the values of ROIs you want: The program '
686
686
'will find all of them and produce a full list' ,
687
687
argstr = '-all_rois' )
@@ -693,8 +693,10 @@ class CenterMassOutputSpec(TraitedSpec):
693
693
desc = 'output file' )
694
694
cm_file = File (
695
695
desc = 'file with the center of mass coordinates' )
696
- cm = traits .Tuple (
697
- traits .Float (), traits .Float (), traits .Float (),
696
+ cm = traits .Either (
697
+ traits .Tuple (traits .Float (), traits .Float (), traits .Float ()),
698
+ traits .List (traits .Tuple (traits .Float (), traits .Float (),
699
+ traits .Float ())),
698
700
desc = 'center of mass' )
699
701
700
702
@@ -716,10 +718,10 @@ class CenterMass(AFNICommandBase):
716
718
>>> from nipype.interfaces import afni
717
719
>>> cm = afni.CenterMass()
718
720
>>> cm.inputs.in_file = 'structural.nii'
719
- >>> cm.inputs.out_file = 'cm.txt'
720
- >>> cm.inputs.set_cm = (0, 0, 0)
721
+ >>> cm.inputs.cm_file = 'cm.txt'
722
+ >>> cm.inputs.roi_vals = [2, 10]
721
723
>>> cm.cmdline # doctest: +ALLOW_UNICODE
722
- '3dcm -set 0 0 0 structural.nii > cm.txt'
724
+ '3dCM -roi_vals 2 10 structural.nii > cm.txt'
723
725
>>> res = 3dcm.run() # doctest: +SKIP
724
726
"""
725
727
@@ -732,7 +734,10 @@ def _list_outputs(self):
732
734
outputs ['out_file' ] = os .path .abspath (self .inputs .in_file )
733
735
outputs ['cm_file' ] = os .path .abspath (self .inputs .cm_file )
734
736
sout = np .loadtxt (outputs ['cm_file' ]) # pylint: disable=E1101
735
- outputs ['cm' ] = tuple (sout )
737
+ if len (sout ) > 1 :
738
+ outputs ['cm' ] = [tuple (s ) for s in sout ]
739
+ else :
740
+ outputs ['cm' ] = tuple (sout )
736
741
return outputs
737
742
738
743
0 commit comments