Skip to content

Commit 09d55ec

Browse files
authored
Merge pull request #2948 from gpiantoni/3dTsmooth
ENH: add interface for AFNI 3dTsmooth
2 parents 001a56a + 56e5715 commit 09d55ec

File tree

3 files changed

+129
-1
lines changed

3 files changed

+129
-1
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
BlurInMask, BlurToFWHM, ClipLevel, DegreeCentrality, Despike, Detrend, ECM,
1414
Fim, Fourier, Hist, LFCD, Maskave, Means, OutlierCount, QualityIndex,
1515
ROIStats, Retroicor, Seg, SkullStrip, TCorr1D, TCorrMap, TCorrelate, TNorm,
16-
TProject, TShift, Volreg, Warp, QwarpPlusMinus, Qwarp)
16+
TProject, TShift, TSmooth, Volreg, Warp, QwarpPlusMinus, Qwarp)
1717
from .svm import (SVMTest, SVMTrain)
1818
from .utils import (
1919
ABoverlap, AFNItoNIFTI, Autobox, Axialize, BrickStat, Bucket, Calc, Cat,

nipype/interfaces/afni/preprocess.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,6 +2853,79 @@ def _list_outputs(self):
28532853
return outputs
28542854

28552855

2856+
class TSmoothInputSpec(AFNICommandInputSpec):
2857+
in_file = File(
2858+
desc='input file to 3dTSmooth',
2859+
argstr='%s',
2860+
position=-1,
2861+
mandatory=True,
2862+
exists=True,
2863+
copyfile=False)
2864+
out_file = File(
2865+
name_template='%s_smooth',
2866+
desc='output file from 3dTSmooth',
2867+
argstr='-prefix %s',
2868+
name_source='in_file')
2869+
datum = traits.Str(
2870+
desc='Sets the data type of the output dataset',
2871+
argstr='-datum %s')
2872+
lin = traits.Bool(
2873+
desc='3 point linear filter: 0.15*a + 0.70*b + 0.15*c'
2874+
'[This is the default smoother]',
2875+
argstr='-lin')
2876+
med = traits.Bool(
2877+
desc='3 point median filter: median(a,b,c)',
2878+
argstr='-med')
2879+
osf = traits.Bool(
2880+
desc='3 point order statistics filter:'
2881+
'0.15*min(a,b,c) + 0.70*median(a,b,c) + 0.15*max(a,b,c)',
2882+
argstr='-osf')
2883+
lin3 = traits.Int(
2884+
desc='3 point linear filter: 0.5*(1-m)*a + m*b + 0.5*(1-m)*c'
2885+
"Here, 'm' is a number strictly between 0 and 1.",
2886+
argstr='-3lin %d')
2887+
hamming = traits.Int(
2888+
argstr='-hamming %d',
2889+
desc='Use N point Hamming windows.'
2890+
'(N must be odd and bigger than 1.)')
2891+
blackman = traits.Int(
2892+
argstr='-blackman %d',
2893+
desc='Use N point Blackman windows.'
2894+
'(N must be odd and bigger than 1.)')
2895+
custom = File(
2896+
argstr='-custom %s',
2897+
desc='odd # of coefficients must be in a single column in ASCII file')
2898+
adaptive = traits.Int(
2899+
argstr='-adaptive %d',
2900+
desc='use adaptive mean filtering of width N '
2901+
'(where N must be odd and bigger than 3).')
2902+
2903+
2904+
class TSmooth(AFNICommand):
2905+
"""Smooths each voxel time series in a 3D+time dataset and produces
2906+
as output a new 3D+time dataset (e.g., lowpass filter in time).
2907+
2908+
For complete details, see the `3dTsmooth Documentation.
2909+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dTSmooth.html>`_
2910+
2911+
Examples
2912+
========
2913+
2914+
>>> from nipype.interfaces import afni
2915+
>>> from nipype.testing import example_data
2916+
>>> smooth = afni.TSmooth()
2917+
>>> smooth.inputs.in_file = 'functional.nii'
2918+
>>> smooth.inputs.adaptive = 5
2919+
>>> smooth.cmdline
2920+
'3dTsmooth -adaptive 5 -prefix functional_smooth functional.nii'
2921+
>>> res = smooth.run() # doctest: +SKIP
2922+
2923+
"""
2924+
_cmd = '3dTsmooth'
2925+
input_spec = TSmoothInputSpec
2926+
output_spec = AFNICommandOutputSpec
2927+
2928+
28562929
class VolregInputSpec(AFNICommandInputSpec):
28572930
in_file = File(
28582931
desc='input file to 3dvolreg',
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from __future__ import unicode_literals
3+
from ..preprocess import TSmooth
4+
5+
6+
def test_TSmooth_inputs():
7+
input_map = dict(
8+
adaptive=dict(argstr='-adaptive %d', ),
9+
args=dict(argstr='%s', ),
10+
blackman=dict(argstr='-blackman %d', ),
11+
custom=dict(
12+
argstr='-custom %s',
13+
extensions=None,
14+
),
15+
datum=dict(argstr='-datum %s', ),
16+
environ=dict(
17+
nohash=True,
18+
usedefault=True,
19+
),
20+
hamming=dict(argstr='-hamming %d', ),
21+
in_file=dict(
22+
argstr='%s',
23+
copyfile=False,
24+
extensions=None,
25+
mandatory=True,
26+
position=-1,
27+
),
28+
lin=dict(argstr='-lin', ),
29+
lin3=dict(argstr='-3lin %d', ),
30+
med=dict(argstr='-med', ),
31+
num_threads=dict(
32+
nohash=True,
33+
usedefault=True,
34+
),
35+
osf=dict(argstr='-osf', ),
36+
out_file=dict(
37+
argstr='-prefix %s',
38+
extensions=None,
39+
name_source='in_file',
40+
name_template='%s_smooth',
41+
),
42+
outputtype=dict(),
43+
)
44+
inputs = TSmooth.input_spec()
45+
46+
for key, metadata in list(input_map.items()):
47+
for metakey, value in list(metadata.items()):
48+
assert getattr(inputs.traits()[key], metakey) == value
49+
def test_TSmooth_outputs():
50+
output_map = dict(out_file=dict(extensions=None, ), )
51+
outputs = TSmooth.output_spec()
52+
53+
for key, metadata in list(output_map.items()):
54+
for metakey, value in list(metadata.items()):
55+
assert getattr(outputs.traits()[key], metakey) == value

0 commit comments

Comments
 (0)