Skip to content

Commit ab29ac1

Browse files
committed
REF: QwapPlusMinus
1 parent 91fbcce commit ab29ac1

File tree

1 file changed

+77
-101
lines changed

1 file changed

+77
-101
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 77 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,107 +2953,6 @@ def _list_outputs(self):
29532953
return outputs
29542954

29552955

2956-
class QwarpPlusMinusInputSpec(CommandLineInputSpec):
2957-
source_file = File(
2958-
desc=
2959-
'Source image (opposite phase encoding direction than base image).',
2960-
argstr='-source %s',
2961-
mandatory=True,
2962-
exists=True,
2963-
copyfile=False)
2964-
base_file = File(
2965-
desc=
2966-
'Base image (opposite phase encoding direction than source image).',
2967-
argstr='-base %s',
2968-
mandatory=True,
2969-
exists=True,
2970-
copyfile=False)
2971-
pblur = traits.List(
2972-
traits.Float(),
2973-
desc='The fraction of the patch size that'
2974-
'is used for the progressive blur by providing a '
2975-
'value between 0 and 0.25. If you provide TWO '
2976-
'values, the first fraction is used for '
2977-
'progressively blurring the base image and the '
2978-
'second for the source image.',
2979-
argstr='-pblur %s',
2980-
minlen=1,
2981-
maxlen=2)
2982-
blur = traits.List(
2983-
traits.Float(),
2984-
desc="Gaussian blur the input images by (FWHM) voxels "
2985-
"before doing the alignment (the output dataset "
2986-
"will not be blurred). The default is 2.345 (for "
2987-
"no good reason). Optionally, you can provide 2 "
2988-
"values, and then the first one is applied to the "
2989-
"base volume, the second to the source volume. A "
2990-
"negative blur radius means to use 3D median "
2991-
"filtering, rather than Gaussian blurring. This "
2992-
"type of filtering will better preserve edges, "
2993-
"which can be important in alignment.",
2994-
argstr='-blur %s',
2995-
minlen=1,
2996-
maxlen=2)
2997-
noweight = traits.Bool(
2998-
desc='If you want a binary weight (the old default), use this option.'
2999-
'That is, each voxel in the base volume automask will be'
3000-
'weighted the same in the computation of the cost functional.',
3001-
argstr='-noweight')
3002-
minpatch = traits.Int(
3003-
desc="Set the minimum patch size for warp searching to 'mm' voxels.",
3004-
argstr='-minpatch %d')
3005-
nopadWARP = traits.Bool(
3006-
desc='If for some reason you require the warp volume to'
3007-
'match the base volume, then use this option to have the output'
3008-
'WARP dataset(s) truncated.',
3009-
argstr='-nopadWARP')
3010-
3011-
3012-
class QwarpPlusMinusOutputSpec(TraitedSpec):
3013-
warped_source = File(desc='Undistorted source file.', exists=True)
3014-
warped_base = File(desc='Undistorted base file.', exists=True)
3015-
source_warp = File(
3016-
desc="Field suceptibility correction warp (in 'mm') for source image.",
3017-
exists=True)
3018-
base_warp = File(
3019-
desc="Field suceptibility correction warp (in 'mm') for base image.",
3020-
exists=True)
3021-
3022-
3023-
class QwarpPlusMinus(CommandLine):
3024-
"""A version of 3dQwarp for performing field susceptibility correction
3025-
using two images with opposing phase encoding directions.
3026-
3027-
For complete details, see the `3dQwarp Documentation.
3028-
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dQwarp.html>`_
3029-
3030-
Examples
3031-
========
3032-
3033-
>>> from nipype.interfaces import afni
3034-
>>> qwarp = afni.QwarpPlusMinus()
3035-
>>> qwarp.inputs.source_file = 'sub-01_dir-LR_epi.nii.gz'
3036-
>>> qwarp.inputs.nopadWARP = True
3037-
>>> qwarp.inputs.base_file = 'sub-01_dir-RL_epi.nii.gz'
3038-
>>> qwarp.cmdline
3039-
'3dQwarp -prefix Qwarp.nii.gz -plusminus -base sub-01_dir-RL_epi.nii.gz -nopadWARP -source sub-01_dir-LR_epi.nii.gz'
3040-
>>> res = warp.run() # doctest: +SKIP
3041-
3042-
"""
3043-
_cmd = '3dQwarp -prefix Qwarp.nii.gz -plusminus'
3044-
input_spec = QwarpPlusMinusInputSpec
3045-
output_spec = QwarpPlusMinusOutputSpec
3046-
3047-
def _list_outputs(self):
3048-
outputs = self.output_spec().get()
3049-
outputs['warped_source'] = os.path.abspath("Qwarp_PLUS.nii.gz")
3050-
outputs['warped_base'] = os.path.abspath("Qwarp_MINUS.nii.gz")
3051-
outputs['source_warp'] = os.path.abspath("Qwarp_PLUS_WARP.nii.gz")
3052-
outputs['base_warp'] = os.path.abspath("Qwarp_MINUS_WARP.nii.gz")
3053-
3054-
return outputs
3055-
3056-
30572956
class QwarpInputSpec(AFNICommandInputSpec):
30582957
in_file = File(
30592958
desc=
@@ -3722,3 +3621,80 @@ def _list_outputs(self):
37223621
def _gen_filename(self, name):
37233622
if name == 'out_file':
37243623
return self._gen_fname(self.inputs.source_file, suffix='_QW')
3624+
3625+
3626+
class QwarpPlusMinusInputSpec(QwarpInputSpec):
3627+
in_file = File(
3628+
desc='Source image (opposite phase encoding direction than base image)',
3629+
argstr='-source %s',
3630+
mandatory=True,
3631+
exists=True,
3632+
copyfile=False)
3633+
source_file = File(
3634+
desc='Source image (opposite phase encoding direction than base image)',
3635+
argstr='-source %s',
3636+
exists=True,
3637+
deprecated='1.1.2',
3638+
new_name='in_file',
3639+
copyfile=False)
3640+
out_file = File(
3641+
argstr='-prefix %s',
3642+
value='Qwarp.nii.gz',
3643+
position=0,
3644+
usedefault=True,
3645+
desc="Output file")
3646+
plusminus = traits.Bool(
3647+
True,
3648+
usedefault=True,
3649+
position=1,
3650+
desc='Normally, the warp displacements dis(x) are defined to match'
3651+
'base(x) to source(x+dis(x)). With this option, the match'
3652+
'is between base(x-dis(x)) and source(x+dis(x)) -- the two'
3653+
'images \'meet in the middle\'. For more info, view Qwarp` interface',
3654+
argstr='-plusminus',
3655+
xor=['duplo', 'allsave', 'iwarp'])
3656+
3657+
3658+
class QwarpPlusMinusOutputSpec(QwarpOutputSpec):
3659+
warped_source = File(desc='Undistorted source file.', exists=True)
3660+
warped_base = File(desc='Undistorted base file.', exists=True)
3661+
source_warp = File(
3662+
desc="Field suceptibility correction warp (in 'mm') for source image.",
3663+
exists=True)
3664+
base_warp = File(
3665+
desc="Field suceptibility correction warp (in 'mm') for base image.",
3666+
exists=True)
3667+
3668+
3669+
class QwarpPlusMinus(Qwarp):
3670+
"""A version of 3dQwarp for performing field susceptibility correction
3671+
using two images with opposing phase encoding directions.
3672+
3673+
For complete details, see the `3dQwarp Documentation.
3674+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dQwarp.html>`_
3675+
3676+
Examples
3677+
========
3678+
3679+
>>> from nipype.interfaces import afni
3680+
>>> qwarp = afni.QwarpPlusMinus()
3681+
>>> qwarp.inputs.source_file = 'sub-01_dir-LR_epi.nii.gz'
3682+
>>> qwarp.inputs.nopadWARP = True
3683+
>>> qwarp.inputs.base_file = 'sub-01_dir-RL_epi.nii.gz'
3684+
>>> qwarp.cmdline
3685+
'3dQwarp -prefix Qwarp.nii.gz -plusminus -base sub-01_dir-RL_epi.nii.gz -nopadWARP -source sub-01_dir-LR_epi.nii.gz'
3686+
>>> res = warp.run() # doctest: +SKIP
3687+
3688+
"""
3689+
3690+
input_spec = QwarpPlusMinusInputSpec
3691+
output_spec = QwarpPlusMinusOutputSpec
3692+
3693+
def _list_outputs(self):
3694+
outputs = self.output_spec().get()
3695+
outputs['warped_source'] = os.path.abspath("Qwarp_PLUS.nii.gz")
3696+
outputs['warped_base'] = os.path.abspath("Qwarp_MINUS.nii.gz")
3697+
outputs['source_warp'] = os.path.abspath("Qwarp_PLUS_WARP.nii.gz")
3698+
outputs['base_warp'] = os.path.abspath("Qwarp_MINUS_WARP.nii.gz")
3699+
3700+
return outputs

0 commit comments

Comments
 (0)