-
Notifications
You must be signed in to change notification settings - Fork 533
MAINT: ensure interface _cmd only includes executable #2674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2953,107 +2953,6 @@ def _list_outputs(self): | |
return outputs | ||
|
||
|
||
class QwarpPlusMinusInputSpec(CommandLineInputSpec): | ||
source_file = File( | ||
desc= | ||
'Source image (opposite phase encoding direction than base image).', | ||
argstr='-source %s', | ||
mandatory=True, | ||
exists=True, | ||
copyfile=False) | ||
base_file = File( | ||
desc= | ||
'Base image (opposite phase encoding direction than source image).', | ||
argstr='-base %s', | ||
mandatory=True, | ||
exists=True, | ||
copyfile=False) | ||
pblur = traits.List( | ||
traits.Float(), | ||
desc='The fraction of the patch size that' | ||
'is used for the progressive blur by providing a ' | ||
'value between 0 and 0.25. If you provide TWO ' | ||
'values, the first fraction is used for ' | ||
'progressively blurring the base image and the ' | ||
'second for the source image.', | ||
argstr='-pblur %s', | ||
minlen=1, | ||
maxlen=2) | ||
blur = traits.List( | ||
traits.Float(), | ||
desc="Gaussian blur the input images by (FWHM) voxels " | ||
"before doing the alignment (the output dataset " | ||
"will not be blurred). The default is 2.345 (for " | ||
"no good reason). Optionally, you can provide 2 " | ||
"values, and then the first one is applied to the " | ||
"base volume, the second to the source volume. A " | ||
"negative blur radius means to use 3D median " | ||
"filtering, rather than Gaussian blurring. This " | ||
"type of filtering will better preserve edges, " | ||
"which can be important in alignment.", | ||
argstr='-blur %s', | ||
minlen=1, | ||
maxlen=2) | ||
noweight = traits.Bool( | ||
desc='If you want a binary weight (the old default), use this option.' | ||
'That is, each voxel in the base volume automask will be' | ||
'weighted the same in the computation of the cost functional.', | ||
argstr='-noweight') | ||
minpatch = traits.Int( | ||
desc="Set the minimum patch size for warp searching to 'mm' voxels.", | ||
argstr='-minpatch %d') | ||
nopadWARP = traits.Bool( | ||
desc='If for some reason you require the warp volume to' | ||
'match the base volume, then use this option to have the output' | ||
'WARP dataset(s) truncated.', | ||
argstr='-nopadWARP') | ||
|
||
|
||
class QwarpPlusMinusOutputSpec(TraitedSpec): | ||
warped_source = File(desc='Undistorted source file.', exists=True) | ||
warped_base = File(desc='Undistorted base file.', exists=True) | ||
source_warp = File( | ||
desc="Field suceptibility correction warp (in 'mm') for source image.", | ||
exists=True) | ||
base_warp = File( | ||
desc="Field suceptibility correction warp (in 'mm') for base image.", | ||
exists=True) | ||
|
||
|
||
class QwarpPlusMinus(CommandLine): | ||
"""A version of 3dQwarp for performing field susceptibility correction | ||
using two images with opposing phase encoding directions. | ||
|
||
For complete details, see the `3dQwarp Documentation. | ||
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dQwarp.html>`_ | ||
|
||
Examples | ||
======== | ||
|
||
>>> from nipype.interfaces import afni | ||
>>> qwarp = afni.QwarpPlusMinus() | ||
>>> qwarp.inputs.source_file = 'sub-01_dir-LR_epi.nii.gz' | ||
>>> qwarp.inputs.nopadWARP = True | ||
>>> qwarp.inputs.base_file = 'sub-01_dir-RL_epi.nii.gz' | ||
>>> qwarp.cmdline | ||
'3dQwarp -prefix Qwarp.nii.gz -plusminus -base sub-01_dir-RL_epi.nii.gz -nopadWARP -source sub-01_dir-LR_epi.nii.gz' | ||
>>> res = warp.run() # doctest: +SKIP | ||
|
||
""" | ||
_cmd = '3dQwarp -prefix Qwarp.nii.gz -plusminus' | ||
input_spec = QwarpPlusMinusInputSpec | ||
output_spec = QwarpPlusMinusOutputSpec | ||
|
||
def _list_outputs(self): | ||
outputs = self.output_spec().get() | ||
outputs['warped_source'] = os.path.abspath("Qwarp_PLUS.nii.gz") | ||
outputs['warped_base'] = os.path.abspath("Qwarp_MINUS.nii.gz") | ||
outputs['source_warp'] = os.path.abspath("Qwarp_PLUS_WARP.nii.gz") | ||
outputs['base_warp'] = os.path.abspath("Qwarp_MINUS_WARP.nii.gz") | ||
|
||
return outputs | ||
|
||
|
||
class QwarpInputSpec(AFNICommandInputSpec): | ||
in_file = File( | ||
desc= | ||
|
@@ -3722,3 +3621,80 @@ def _list_outputs(self): | |
def _gen_filename(self, name): | ||
if name == 'out_file': | ||
return self._gen_fname(self.inputs.source_file, suffix='_QW') | ||
|
||
|
||
class QwarpPlusMinusInputSpec(QwarpInputSpec): | ||
in_file = File( | ||
desc='Source image (opposite phase encoding direction than base image)', | ||
argstr='-source %s', | ||
mandatory=True, | ||
exists=True, | ||
copyfile=False) | ||
source_file = File( | ||
desc='Source image (opposite phase encoding direction than base image)', | ||
argstr='-source %s', | ||
exists=True, | ||
deprecated='1.1.2', | ||
new_name='in_file', | ||
copyfile=False) | ||
out_file = File( | ||
argstr='-prefix %s', | ||
value='Qwarp.nii.gz', | ||
position=0, | ||
usedefault=True, | ||
desc="Output file") | ||
plusminus = traits.Bool( | ||
True, | ||
usedefault=True, | ||
position=1, | ||
desc='Normally, the warp displacements dis(x) are defined to match' | ||
'base(x) to source(x+dis(x)). With this option, the match' | ||
'is between base(x-dis(x)) and source(x+dis(x)) -- the two' | ||
'images \'meet in the middle\'. For more info, view Qwarp` interface', | ||
argstr='-plusminus', | ||
xor=['duplo', 'allsave', 'iwarp']) | ||
|
||
|
||
class QwarpPlusMinusOutputSpec(QwarpOutputSpec): | ||
warped_source = File(desc='Undistorted source file.', exists=True) | ||
warped_base = File(desc='Undistorted base file.', exists=True) | ||
source_warp = File( | ||
desc="Field suceptibility correction warp (in 'mm') for source image.", | ||
exists=True) | ||
base_warp = File( | ||
desc="Field suceptibility correction warp (in 'mm') for base image.", | ||
exists=True) | ||
|
||
|
||
class QwarpPlusMinus(Qwarp): | ||
"""A version of 3dQwarp for performing field susceptibility correction | ||
using two images with opposing phase encoding directions. | ||
|
||
For complete details, see the `3dQwarp Documentation. | ||
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dQwarp.html>`_ | ||
|
||
Examples | ||
======== | ||
|
||
>>> from nipype.interfaces import afni | ||
>>> qwarp = afni.QwarpPlusMinus() | ||
>>> qwarp.inputs.source_file = 'sub-01_dir-LR_epi.nii.gz' | ||
>>> qwarp.inputs.nopadWARP = True | ||
>>> qwarp.inputs.base_file = 'sub-01_dir-RL_epi.nii.gz' | ||
>>> qwarp.cmdline | ||
'3dQwarp -prefix Qwarp.nii.gz -plusminus -base sub-01_dir-RL_epi.nii.gz -nopadWARP -source sub-01_dir-LR_epi.nii.gz' | ||
>>> res = warp.run() # doctest: +SKIP | ||
|
||
""" | ||
|
||
input_spec = QwarpPlusMinusInputSpec | ||
output_spec = QwarpPlusMinusOutputSpec | ||
|
||
def _list_outputs(self): | ||
outputs = self.output_spec().get() | ||
outputs['warped_source'] = os.path.abspath("Qwarp_PLUS.nii.gz") | ||
outputs['warped_base'] = os.path.abspath("Qwarp_MINUS.nii.gz") | ||
outputs['source_warp'] = os.path.abspath("Qwarp_PLUS_WARP.nii.gz") | ||
outputs['base_warp'] = os.path.abspath("Qwarp_MINUS_WARP.nii.gz") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would drop |
||
|
||
return outputs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as in superclass.