Skip to content

Commit cd8d504

Browse files
committed
Merge remote-tracking branch 'origin/pr/868'
Conflicts: CHANGES
2 parents 87b0279 + bc3ac60 commit cd8d504

File tree

4 files changed

+73
-8
lines changed

4 files changed

+73
-8
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Next Release
1616
* ENH: New data grabbing interface that works over SSH connections, SSHDataGrabber
1717
* ENH: New color mode for write_graph
1818
* ENH: You can now force MapNodes to be run serially
19+
* ENH: New ANTs interface: LaplacianThickness
1920
* FIX: MRTrix tracking algorithms were ignoring mask parameters.
2021
* FIX: FNIRT registration pathway and associated OpenFMRI example script
2122

nipype/interfaces/afni/preprocess.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,8 @@ class TShiftInputSpec(AFNICommandInputSpec):
111111
desc='different interpolation methods (see 3dTShift for details)' +
112112
' default = Fourier', argstr='-%s')
113113

114-
tpattern = traits.Enum(('alt+z', 'alt+z2', 'alt-z',
115-
'alt-z2', 'seq+z', 'seq-z'),
116-
desc='use specified slice time pattern rather than one in header',
117-
argstr='-tpattern %s')
114+
tpattern = traits.Str(desc='use specified slice time pattern rather than one in header',
115+
argstr='-tpattern %s')
118116

119117
rlt = traits.Bool(desc='Before shifting, remove the mean and linear trend',
120118
argstr="-rlt")
@@ -560,7 +558,6 @@ class VolregInputSpec(AFNICommandInputSpec):
560558
copyfile=False)
561559
out_file = File(name_template="%s_volreg", desc='output image file name',
562560
argstr='-prefix %s', name_source="in_file")
563-
564561
basefile = File(desc='base file for registration',
565562
argstr='-base %s',
566563
position=-6,
@@ -582,12 +579,18 @@ class VolregInputSpec(AFNICommandInputSpec):
582579
argstr='-tshift 0')
583580
copyorigin = traits.Bool(desc='copy base file origin coords to output',
584581
argstr='-twodup')
582+
oned_matrix_save = File(name_template='%s.aff12.1D',
583+
desc='Save the matrix transformation',
584+
argstr='-1Dmatrix_save %s',
585+
keep_extension=True,
586+
name_source="in_file")
585587

586588

587589
class VolregOutputSpec(TraitedSpec):
588590
out_file = File(desc='registered file', exists=True)
589591
md1d_file = File(desc='max displacement info file', exists=True)
590592
oned_file = File(desc='movement parameters info file', exists=True)
593+
oned_matrix_save = File(desc='matrix transformation from base to input', exists=True)
591594

592595

593596
class Volreg(AFNICommand):
@@ -1924,7 +1927,7 @@ class AFNItoNIFTI(AFNICommand):
19241927
input_spec = AFNItoNIFTIInputSpec
19251928
output_spec = AFNICommandOutputSpec
19261929

1927-
def _overload_extension(self, value, name=None):
1930+
def _overload_extension(self, value):
19281931
path, base, ext = split_filename(value)
19291932
if ext.lower() not in [".1d", ".nii.gz", ".1D"]:
19301933
ext = ext + ".nii"

nipype/interfaces/ants/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
# Segmentation Programs
14-
from .segmentation import Atropos, N4BiasFieldCorrection
14+
from .segmentation import Atropos, LaplacianThickness, N4BiasFieldCorrection
1515

1616
# Utility Programs
1717
from .utils import AverageAffineTransform, AverageImages, MultiplyImages, JacobianDeterminant

nipype/interfaces/ants/segmentation.py

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,67 @@ def _list_outputs(self):
160160
outputs['posteriors'].append(os.path.abspath(self.inputs.output_posteriors_name_template % (i + 1)))
161161
return outputs
162162

163+
class LaplacianThicknessInputSpec(ANTSCommandInputSpec):
164+
input_wm = File(argstr='%s', mandatory=True, copyfile=True,
165+
desc=('white matter segmentation image'),
166+
position=1)
167+
input_gm = File(argstr='%s', mandatory=True, copyfile=True,
168+
desc=('gray matter segmentation image'),
169+
position=2)
170+
output_image = File(desc='name of output file', argstr='%s', position=3,
171+
genfile=True, hash_files=False)
172+
smooth_param = traits.Float(argstr='smoothparam=%d', desc='', position=4)
173+
prior_thickness = traits.Float(argstr='priorthickval=%d', desc='',
174+
position=5)
175+
dT = traits.Float(argstr='dT=%d', desc='', position=6)
176+
sulcus_prior = traits.Bool(argstr='use-sulcus-prior', desc='', position=7)
177+
opt_tolerance = traits.Float(argstr='optional-laplacian-tolerance=%d',
178+
desc='', position=8)
179+
180+
181+
class LaplacianThicknessOutputSpec(TraitedSpec):
182+
output_image = File(exists=True, desc='Cortical thickness')
183+
184+
185+
class LaplacianThickness(ANTSCommand):
186+
"""Calculates the cortical thickness from an anatomical image
187+
188+
Examples
189+
--------
190+
191+
>>> from nipype.interfaces.ants import LaplacianThickness
192+
>>> cort_thick = LaplacianThickness()
193+
>>> cort_thick.inputs.input_wm = 'white_matter.nii.gz'
194+
>>> cort_thick.inputs.input_gm = 'gray_matter.nii.gz'
195+
>>> cort_thick.inputs.output_image = 'output_thickness.nii.gz'
196+
>>> cort_thick.cmdline
197+
'LaplacianThickness white_matter.nii.gz gray_matter.nii.gz output_thickness.nii.gz'
198+
199+
"""
200+
201+
_cmd = 'LaplacianThickness'
202+
input_spec = LaplacianThicknessInputSpec
203+
output_spec = LaplacianThicknessOutputSpec
204+
205+
def _gen_filename(self, name):
206+
if name == 'output_image':
207+
output = self.inputs.output_image
208+
if not isdefined(output):
209+
_, name, ext = split_filename(self.inputs.input_wm)
210+
output = name + '_thickness' + ext
211+
return output
212+
return None
213+
214+
def _list_outputs(self):
215+
outputs = self._outputs().get()
216+
_, name, ext = split_filename(os.path.abspath(self.inputs.input_wm))
217+
outputs['output_image'] = os.path.join(os.getcwd(),
218+
''.join((name,
219+
self.inputs.output_image,
220+
ext)))
221+
return outputs
222+
223+
163224
class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec):
164225
dimension = traits.Enum(3, 2, argstr='--image-dimension %d',
165226
usedefault=True,
@@ -228,4 +289,4 @@ def _gen_filename(self, name):
228289
def _list_outputs(self):
229290
outputs = self._outputs().get()
230291
outputs['output_image'] = os.path.abspath(self._gen_filename('output_image'))
231-
return outputs
292+
return outputs

0 commit comments

Comments
 (0)