Skip to content

Commit c26b3de

Browse files
authored
Merge pull request #1974 from chrisfilo/enh/qwarp
Adding 3dQwarpPlusMinus Interface
2 parents b5f1c92 + b823356 commit c26b3de

File tree

4 files changed

+102
-1
lines changed

4 files changed

+102
-1
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Maskave, Means, OutlierCount,
1616
QualityIndex, ROIStats, Retroicor,
1717
Seg, SkullStrip, TCorr1D, TCorrMap, TCorrelate,
18-
TShift, Volreg, Warp)
18+
TShift, Volreg, Warp, QwarpPlusMinus)
1919
from .svm import (SVMTest, SVMTrain)
2020
from .utils import (AFNItoNIFTI, Autobox, BrickStat, Calc, Copy,
2121
Eval, FWHMx,

nipype/interfaces/afni/preprocess.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,3 +2347,104 @@ class Warp(AFNICommand):
23472347
_cmd = '3dWarp'
23482348
input_spec = WarpInputSpec
23492349
output_spec = AFNICommandOutputSpec
2350+
2351+
2352+
class QwarpPlusMinusInputSpec(CommandLineInputSpec):
2353+
source_file = File(
2354+
desc='Source image (opposite phase encoding direction than base image).',
2355+
argstr='-source %s',
2356+
mandatory=True,
2357+
exists=True,
2358+
copyfile=False)
2359+
base_file = File(
2360+
desc='Base image (opposite phase encoding direction than source image).',
2361+
argstr='-base %s',
2362+
mandatory=True,
2363+
exists=True,
2364+
copyfile=False)
2365+
pblur = traits.List(traits.Float(),
2366+
desc='The fraction of the patch size that'
2367+
'is used for the progressive blur by providing a '
2368+
'value between 0 and 0.25. If you provide TWO '
2369+
'values, the first fraction is used for '
2370+
'progressively blurring the base image and the '
2371+
'second for the source image.',
2372+
argstr='-pblur %s',
2373+
minlen=1,
2374+
maxlen=2)
2375+
blur = traits.List(traits.Float(),
2376+
desc="Gaussian blur the input images by (FWHM) voxels "
2377+
"before doing the alignment (the output dataset "
2378+
"will not be blurred). The default is 2.345 (for "
2379+
"no good reason). Optionally, you can provide 2 "
2380+
"values, and then the first one is applied to the "
2381+
"base volume, the second to the source volume. A "
2382+
"negative blur radius means to use 3D median "
2383+
"filtering, rather than Gaussian blurring. This "
2384+
"type of filtering will better preserve edges, "
2385+
"which can be important in alignment.",
2386+
argstr='-blur %s',
2387+
minlen=1,
2388+
maxlen=2)
2389+
noweight = traits.Bool(
2390+
desc='If you want a binary weight (the old default), use this option.'
2391+
'That is, each voxel in the base volume automask will be'
2392+
'weighted the same in the computation of the cost functional.',
2393+
argstr='-noweight')
2394+
minpatch = traits.Int(
2395+
desc="Set the minimum patch size for warp searching to 'mm' voxels.",
2396+
argstr='-minpatch %d')
2397+
nopadWARP = traits.Bool(
2398+
desc='If for some reason you require the warp volume to'
2399+
'match the base volume, then use this option to have the output'
2400+
'WARP dataset(s) truncated.',
2401+
argstr='-nopadWARP')
2402+
2403+
2404+
class QwarpPlusMinusOutputSpec(TraitedSpec):
2405+
warped_source = File(
2406+
desc='Undistorted source file.',
2407+
exists=True)
2408+
warped_base = File(
2409+
desc='Undistorted base file.',
2410+
exists=True)
2411+
source_warp = File(
2412+
desc="Field suceptibility correction warp (in 'mm') for source image.",
2413+
exists=True)
2414+
base_warp = File(
2415+
desc="Field suceptibility correction warp (in 'mm') for base image.",
2416+
exists=True)
2417+
2418+
2419+
class QwarpPlusMinus(CommandLine):
2420+
"""A version of 3dQwarp for performing field susceptibility correction
2421+
using two images with opposing phase encoding directions.
2422+
2423+
For complete details, see the `3dQwarp Documentation.
2424+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dQwarp.html>`_
2425+
2426+
Examples
2427+
========
2428+
2429+
>>> from nipype.interfaces import afni
2430+
>>> qwarp = afni.QwarpPlusMinus()
2431+
>>> qwarp.inputs.source_file = 'sub-01_dir-LR_epi.nii.gz'
2432+
>>> qwarp.inputs.nopadWARP = True
2433+
>>> qwarp.inputs.base_file = 'sub-01_dir-RL_epi.nii.gz'
2434+
>>> qwarp.cmdline # doctest: +ALLOW_UNICODE
2435+
'3dQwarp -prefix Qwarp.nii.gz -plusminus -base sub-01_dir-RL_epi.nii.gz -nopadWARP -source sub-01_dir-LR_epi.nii.gz'
2436+
>>> res = warp.run() # doctest: +SKIP
2437+
2438+
"""
2439+
_cmd = '3dQwarp -prefix Qwarp.nii.gz -plusminus'
2440+
input_spec = QwarpPlusMinusInputSpec
2441+
output_spec = QwarpPlusMinusOutputSpec
2442+
2443+
def _list_outputs(self):
2444+
outputs = self.output_spec().get()
2445+
outputs['warped_source'] = os.path.abspath("Qwarp_PLUS.nii.gz")
2446+
outputs['warped_base'] = os.path.abspath("Qwarp_MINUS.nii.gz")
2447+
outputs['source_warp'] = os.path.abspath("Qwarp_PLUS_WARP.nii.gz")
2448+
outputs['base_warp'] = os.path.abspath("Qwarp_MINUS_WARP.nii.gz")
2449+
2450+
return outputs

nipype/testing/data/sub-01_dir-LR_epi.nii.gz

Whitespace-only changes.

nipype/testing/data/sub-01_dir-RL_epi.nii.gz

Whitespace-only changes.

0 commit comments

Comments
 (0)