Skip to content

Commit adc6ed1

Browse files
authored
Merge pull request #1512 from TheChymera/3dblur
Interface for AFNI's 3dBlurToFWHM
2 parents 5e6dd05 + f89db4e commit adc6ed1

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,37 @@
2121
from ...external.six import string_types
2222
from ...utils.filemanip import (load_json, save_json, split_filename)
2323

24+
class BlurToFWHMInputSpec(AFNICommandInputSpec):
25+
in_file = File(desc='The dataset that will be smoothed', argstr='-input %s', mandatory=True, exists=True)
26+
27+
automask = traits.Bool(desc='Create an automask from the input dataset.', argstr='-automask')
28+
fwhm = traits.Float(desc='Blur until the 3D FWHM reaches this value (in mm)', argstr='-FWHM %f')
29+
fwhmxy = traits.Float(desc='Blur until the 2D (x,y)-plane FWHM reaches this value (in mm)', argstr='-FWHMxy %f')
30+
blurmaster = File(desc='The dataset whose smoothness controls the process.', argstr='-blurmaster %s', exists=True)
31+
mask = File(desc='Mask dataset, if desired. Voxels NOT in mask will be set to zero in output.', argstr='-blurmaster %s', exists=True)
32+
33+
34+
class BlurToFWHM(AFNICommand):
35+
"""Blurs a 'master' dataset until it reaches a specified FWHM smoothness (approximately).
36+
37+
For complete details, see the `to3d Documentation
38+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dBlurToFWHM.html>`_
39+
40+
Examples
41+
========
42+
43+
>>> from nipype.interfaces import afni
44+
>>> blur = afni.preprocess.BlurToFWHM()
45+
>>> blur.inputs.in_file = 'epi.nii'
46+
>>> blur.inputs.fwhm = 2.5
47+
>>> blur.cmdline #doctest: +ELLIPSIS
48+
'3dBlurToFWHM -FWHM 2.500000 -input epi.nii -prefix epi_afni'
49+
50+
"""
51+
52+
_cmd = '3dBlurToFWHM'
53+
input_spec = BlurToFWHMInputSpec
54+
output_spec = AFNICommandOutputSpec
2455

2556
class To3DInputSpec(AFNICommandInputSpec):
2657
out_file = File(name_template="%s", desc='output image file name',
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from ....testing import assert_equal
3+
from ..preprocess import BlurToFWHM
4+
5+
6+
def test_BlurToFWHM_inputs():
7+
input_map = dict(args=dict(argstr='%s',
8+
),
9+
automask=dict(argstr='-automask',
10+
),
11+
blurmaster=dict(argstr='-blurmaster %s',
12+
),
13+
environ=dict(nohash=True,
14+
usedefault=True,
15+
),
16+
fwhm=dict(argstr='-FWHM %f',
17+
),
18+
fwhmxy=dict(argstr='-FWHMxy %f',
19+
),
20+
ignore_exception=dict(nohash=True,
21+
usedefault=True,
22+
),
23+
in_file=dict(argstr='-input %s',
24+
mandatory=True,
25+
),
26+
mask=dict(argstr='-blurmaster %s',
27+
),
28+
out_file=dict(argstr='-prefix %s',
29+
name_source=['in_file'],
30+
name_template='%s_afni',
31+
),
32+
outputtype=dict(),
33+
terminal_output=dict(nohash=True,
34+
),
35+
)
36+
inputs = BlurToFWHM.input_spec()
37+
38+
for key, metadata in list(input_map.items()):
39+
for metakey, value in list(metadata.items()):
40+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
41+
42+
43+
def test_BlurToFWHM_outputs():
44+
output_map = dict(out_file=dict(),
45+
)
46+
outputs = BlurToFWHM.output_spec()
47+
48+
for key, metadata in list(output_map.items()):
49+
for metakey, value in list(metadata.items()):
50+
yield assert_equal, getattr(outputs.traits()[key], metakey), value

0 commit comments

Comments
 (0)