@@ -1588,6 +1588,95 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
1588
1588
return outputs
1589
1589
1590
1590
1591
+ class MaskToolInputSpec (AFNICommandInputSpec ):
1592
+ in_file = File (desc = 'input file or files to 3dmask_tool' ,
1593
+ argstr = '-input %s' ,
1594
+ position = - 1 ,
1595
+ mandatory = True ,
1596
+ exists = True ,
1597
+ copyfile = False )
1598
+
1599
+ out_file = File (name_template = "%s_mask" , desc = 'output image file name' ,
1600
+ argstr = '-prefix %s' , name_source = "in_file" )
1601
+
1602
+ count = traits .Bool (desc = 'Instead of created a binary 0/1 mask dataset, ' +
1603
+ 'create one with. counts of voxel overlap, i.e ' +
1604
+ 'each voxel will contain the number of masks ' +
1605
+ 'that it is set in.' ,
1606
+ argstr = '-count' ,
1607
+ position = 2 )
1608
+
1609
+ datum = traits .Enum ('byte' ,'short' ,'float' ,
1610
+ argstr = '-datum %s' ,
1611
+ desc = 'specify data type for output. Valid types are ' +
1612
+ '\' byte\' , \' short\' and \' float\' .' )
1613
+
1614
+ dilate_inputs = traits .Str (desc = 'Use this option to dilate and/or erode ' +
1615
+ 'datasets as they are read. ex. ' +
1616
+ '\' 5 -5\' to dilate and erode 5 times' ,
1617
+ argstr = '-dilate_inputs %s' )
1618
+
1619
+ dilate_results = traits .Str (desc = 'dilate and/or erode combined mask at ' +
1620
+ 'the given levels.' ,
1621
+ argstr = '-dilate_results %s' )
1622
+
1623
+ frac = traits .Float (desc = 'When combining masks (across datasets and ' +
1624
+ 'sub-bricks), use this option to restrict the ' +
1625
+ 'result to a certain fraction of the set of ' +
1626
+ 'volumes' ,
1627
+ argstr = '-frac %s' )
1628
+
1629
+ inter = traits .Bool (desc = 'intersection, this means -frac 1.0' ,
1630
+ argstr = '-inter' )
1631
+
1632
+ union = traits .Bool (desc = 'union, this means -frac 0' ,
1633
+ argstr = '-union' )
1634
+
1635
+ fill_holes = traits .Bool (desc = 'This option can be used to fill holes ' +
1636
+ 'in the resulting mask, i.e. after all ' +
1637
+ 'other processing has been done.' ,
1638
+ argstr = '-fill_holes' )
1639
+
1640
+ fill_dirs = traits .Str (desc = 'fill holes only in the given directions. ' +
1641
+ 'This option is for use with -fill holes. ' +
1642
+ 'should be a single string that specifies ' +
1643
+ '1-3 of the axes using {x,y,z} labels (i.e. ' +
1644
+ 'dataset axis order), or using the labels ' +
1645
+ 'in {R,L,A,P,I,S}.' ,
1646
+ argstr = '-fill_dirs %s' ,
1647
+ requires = ['fill_holes' ])
1648
+
1649
+
1650
+ class MaskToolOutputSpec (TraitedSpec ):
1651
+ out_file = File (desc = 'mask file' ,
1652
+ exists = True )
1653
+
1654
+
1655
+ class MaskTool (AFNICommand ):
1656
+ """3dmask_tool - for combining/dilating/eroding/filling masks
1657
+
1658
+ For complete details, see the `3dmask_tool Documentation.
1659
+ <https://afni.nimh.nih.gov/pub../pub/dist/doc/program_help/3dmask_tool.html>`_
1660
+
1661
+ Examples
1662
+ ========
1663
+
1664
+ >>> from nipype.interfaces import afni as afni
1665
+ >>> automask = afni.Automask()
1666
+ >>> automask.inputs.in_file = 'functional.nii'
1667
+ >>> automask.inputs.dilate = 1
1668
+ >>> automask.inputs.outputtype = "NIFTI"
1669
+ >>> automask.cmdline #doctest: +ELLIPSIS
1670
+ '3dAutomask -apply_prefix functional_masked.nii -dilate 1 -prefix functional_mask.nii functional.nii'
1671
+ >>> res = automask.run() # doctest: +SKIP
1672
+
1673
+ """
1674
+
1675
+ _cmd = '3dmask_tool'
1676
+ input_spec = MaskToolInputSpec
1677
+ output_spec = MaskToolOutputSpec
1678
+
1679
+
1591
1680
class SegInputSpec (CommandLineInputSpec ):
1592
1681
in_file = File (desc = 'ANAT is the volume to segment' ,
1593
1682
argstr = '-anat %s' ,
@@ -1646,9 +1735,7 @@ class Seg(AFNICommandBase):
1646
1735
>>> seg = preprocess.Seg()
1647
1736
>>> seg.inputs.in_file = 'structural.nii'
1648
1737
>>> seg.inputs.mask = 'AUTO'
1649
- >>> res = seg.run()
1650
- '3drefit -deoblique structural.nii'
1651
- >>> res = refit.run() # doctest: +SKIP
1738
+ >>> res = seg.run() # doctest: +SKIP
1652
1739
1653
1740
"""
1654
1741
0 commit comments