Skip to content

Commit e310282

Browse files
committed
Merge branch 'enh/afni2nifti'
Conflicts: CHANGES nipype/interfaces/afni/__init__.py nipype/interfaces/afni/preprocess.py
2 parents 5571a48 + 6167f6a commit e310282

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

CHANGES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Next release
22
============
33

44
* ENH: SelectFiles: a streamlined version of DataGrabber
5-
* ENH: New interfaces: spm.ResliceToReference, FuzzyOverlap
5+
* ENH: New interfaces: spm.ResliceToReference, FuzzyOverlap, afni.AFNItoNIFTI
66
* ENH: W3C PROV support with optional RDF export built into Nipype
77

88
* FIX: Deals properly with 3d files in SPM Realign

nipype/interfaces/afni/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
from .preprocess import (To3D, Refit, Resample, TStat, Automask, Volreg, Merge,
1111
ZCutUp, Calc, TShift, Warp, Detrend, Despike, Copy,
1212
Fourier, Allineate, Maskave, SkullStrip, TCat, Fim,
13+
BlurInMask, Autobox, TCorrMap, Bandpass, Retroicor,
1314
TCorrelate, BrickStat, ROIStats, AutoTcorrelate,
14-
BlurInMask, Autobox, TCorrMap, Bandpass, Retroicor)
15+
AFNItoNIFTI)

nipype/interfaces/afni/preprocess.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,3 +1829,46 @@ class Retroicor(AFNICommand):
18291829
_cmd = '3dretroicor'
18301830
input_spec = RetroicorInputSpec
18311831
output_spec = AFNICommandOutputSpec
1832+
1833+
1834+
class AFNItoNIFTIInputSpec(AFNICommandInputSpec):
1835+
in_file = File(desc='input file to 3dAFNItoNIFTI',
1836+
argstr='%s',
1837+
position=-1,
1838+
mandatory=True,
1839+
exists=True)
1840+
out_file = File("%s.nii", desc='output image file name',
1841+
argstr='-prefix %s', name_source="in_file", usedefault=True)
1842+
hash_files = False
1843+
1844+
class AFNItoNIFTI(AFNICommand):
1845+
"""Changes AFNI format files to NIFTI format using 3dAFNItoNIFTI
1846+
1847+
see AFNI Documentation: <http://afni.nimh.nih.gov/pub/dist/doc/program_help/3dAFNItoNIFTI.html>
1848+
this can also convert 2D or 1D data, which you can numpy.squeeze() to remove extra dimensions
1849+
1850+
Examples
1851+
========
1852+
1853+
>>> from nipype.interfaces import afni as afni
1854+
>>> a2n = afni.AFNItoNIFTI()
1855+
>>> a2n.inputs.in_file = 'afni_output.3D'
1856+
>>> a2n.inputs.out_file = 'afni_output.nii'
1857+
>>> a2n.cmdline
1858+
'3dAFNItoNIFTI afni_output.3D'
1859+
1860+
"""
1861+
1862+
_cmd = '3dAFNItoNIFTI'
1863+
input_spec = AFNItoNIFTIInputSpec
1864+
output_spec = AFNICommandOutputSpec
1865+
1866+
def _overload_extension(self, value):
1867+
path, base, ext = split_filename(value)
1868+
if ext.lower() not in [".1d", ".nii.gz", ".1D"]:
1869+
ext = ext + ".nii"
1870+
return os.path.join(path, base + ext)
1871+
1872+
def _gen_filename(self, name):
1873+
return os.path.abspath(super(AFNItoNIFTI, self)._gen_filename(name))
1874+

nipype/testing/data/afni_output.3D

Whitespace-only changes.

0 commit comments

Comments
 (0)