Skip to content

Commit 7ec5538

Browse files
committed
Added an interface for 3dSeg.
1 parent 05c95b1 commit 7ec5538

File tree

1 file changed

+84
-1
lines changed

1 file changed

+84
-1
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,8 @@ class ClipLevelOutputSpec(TraitedSpec):
15401540

15411541

15421542
class ClipLevel(AFNICommandBase):
1543-
"""Compute maximum and/or minimum voxel values of an input dataset
1543+
"""Estimates the value at which to clip the anatomical dataset so
1544+
that background regions are set to zero.
15441545
15451546
For complete details, see the `3dClipLevel Documentation.
15461547
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dClipLevel.html>`_
@@ -1587,6 +1588,88 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
15871588
return outputs
15881589

15891590

1591+
class SegInputSpec(CommandLineInputSpec):
1592+
in_file = File(desc='ANAT is the volume to segment',
1593+
argstr='-anat %s',
1594+
position=-1,
1595+
mandatory=True,
1596+
exists=True,
1597+
copyfile=True)
1598+
1599+
mask = traits.Str(desc='only non-zero voxels in mask are analyzed. mask can either be a dataset or the string \'AUTO\' which would use AFNI\'s automask function to create the mask.',
1600+
argstr='-mask %s',
1601+
position=-2,
1602+
mandatory=True,
1603+
exists=True)
1604+
1605+
blur_meth = traits.Enum('BFT', 'BIM',
1606+
argstr='-blur_meth %s',
1607+
desc='set the blurring method for bias field estimation')
1608+
1609+
bias_fwhm = traits.Float(desc='The amount of blurring used when estimating the field bias with the Wells method',
1610+
argstr='-bias_fwhm %f')
1611+
1612+
classes = traits.Str(desc='CLASS_STRING is a semicolon delimited string of class labels',
1613+
argstr='-classes %s')
1614+
1615+
bmrf = traits.Float(desc='Weighting factor controlling spatial homogeneity of the classifications',
1616+
argstr='-bmrf %f')
1617+
1618+
bias_classes = traits.Str(desc='A semcolon demlimited string of classes that contribute to the estimation of the bias field',
1619+
argstr='-bias_classes %s')
1620+
1621+
prefix = traits.Str(desc='the prefix for the output folder containing all output volumes',
1622+
argstr='-prefix %s')
1623+
1624+
mixfrac = traits.Str(desc='MIXFRAC sets up the volume-wide (within mask) tissue fractions while initializing the segmentation (see IGNORE for exception)',
1625+
argstr='-mixfrac %s')
1626+
1627+
mixfloor = traits.Float(desc='Set the minimum value for any class\'s mixing fraction',
1628+
argstr='-mixfloor %f')
1629+
1630+
main_N = traits.Int(desc='Number of iterations to perform.',
1631+
argstr='-main_N %d')
1632+
1633+
1634+
class Seg(AFNICommandBase):
1635+
"""3dSeg segments brain volumes into tissue classes. The program allows
1636+
for adding a variety of global and voxelwise priors. However for the
1637+
moment, only mixing fractions and MRF are documented.
1638+
1639+
For complete details, see the `3dSeg Documentation.
1640+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dSeg.html>
1641+
1642+
Examples
1643+
========
1644+
1645+
>>> from nipype.interfaces.afni import preprocess
1646+
>>> seg = preprocess.Seg()
1647+
>>> seg.inputs.in_file = 'structural.nii'
1648+
>>> seg.inputs.mask = 'AUTO'
1649+
>>> res = seg.run()
1650+
'3drefit -deoblique structural.nii'
1651+
>>> res = refit.run() # doctest: +SKIP
1652+
1653+
"""
1654+
1655+
_cmd = '3dSeg'
1656+
input_spec = SegInputSpec
1657+
output_spec = AFNICommandOutputSpec
1658+
1659+
def aggregate_outputs(self, runtime=None, needed_outputs=None):
1660+
1661+
outputs = self._outputs()
1662+
1663+
if isdefined(self.inputs.prefix):
1664+
outfile = os.path.join(os.getcwd(), self.inputs.prefix, 'Classes+orig.BRIK')
1665+
else:
1666+
outfile = os.path.join(os.getcwd(), 'Segsy', 'Classes+orig.BRIK')
1667+
1668+
outputs.out_file = outfile
1669+
1670+
return outputs
1671+
1672+
15901673
class ROIStatsInputSpec(CommandLineInputSpec):
15911674
in_file = File(desc='input file to 3dROIstats',
15921675
argstr='%s',

0 commit comments

Comments
 (0)