Skip to content

Commit 7600dcb

Browse files
authored
Merge pull request #2222 from salma1601/afni_qwarp
Afni qwarp output paths
2 parents 5bbd2a4 + ca3e8a3 commit 7600dcb

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
import os
1616
import os.path as op
1717

18-
from ...utils.filemanip import (load_json, save_json, split_filename)
18+
from ...utils.filemanip import (load_json, save_json, split_filename,
19+
fname_presuffix)
1920
from ..base import (
2021
CommandLineInputSpec, CommandLine, TraitedSpec,
2122
traits, isdefined, File, InputMultiPath, Undefined, Str)
@@ -3131,7 +3132,7 @@ class QwarpInputSpec(AFNICommandInputSpec):
31313132
'Note that the source dataset in the second run is the SAME as'
31323133
'in the first run. If you don\'t see why this is necessary,'
31333134
'then you probably need to seek help from an AFNI guru.',
3134-
argstr='-inlev %d',
3135+
argstr='-inilev %d',
31353136
xor=['duplo'])
31363137
minpatch = traits.Int(
31373138
desc='* The value of mm should be an odd integer.'
@@ -3462,7 +3463,7 @@ class Qwarp(AFNICommand):
34623463
>>> qwarp2.inputs.inilev = 7
34633464
>>> qwarp2.inputs.iniwarp = ['Q25_warp+tlrc.HEAD']
34643465
>>> qwarp2.cmdline # doctest: +ALLOW_UNICODE
3465-
'3dQwarp -base mni.nii -blur 0.0 2.0 -source structural.nii -inlev 7 -iniwarp Q25_warp+tlrc.HEAD -prefix Q11'
3466+
'3dQwarp -base mni.nii -blur 0.0 2.0 -source structural.nii -inilev 7 -iniwarp Q25_warp+tlrc.HEAD -prefix Q11'
34663467
>>> res2 = qwarp2.run() # doctest: +SKIP
34673468
"""
34683469
_cmd = '3dQwarp'
@@ -3475,29 +3476,38 @@ def _list_outputs(self):
34753476
if not isdefined(self.inputs.out_file):
34763477
prefix = self._gen_fname(self.inputs.in_file, suffix='_QW')
34773478
ext = '.HEAD'
3479+
suffix ='+tlrc'
34783480
else:
34793481
prefix = self.inputs.out_file
34803482
ext_ind = max([prefix.lower().rfind('.nii.gz'),
34813483
prefix.lower().rfind('.nii.')])
34823484
if ext_ind == -1:
34833485
ext = '.HEAD'
3486+
suffix = '+tlrc'
34843487
else:
34853488
ext = prefix[ext_ind:]
3489+
suffix = ''
34863490
print(ext,"ext")
3487-
outputs['warped_source'] = os.path.abspath(self._gen_fname(prefix, suffix='+tlrc')+ext)
3491+
outputs['warped_source'] = fname_presuffix(prefix, suffix=suffix,
3492+
use_ext=False) + ext
34883493
if not self.inputs.nowarp:
3489-
outputs['source_warp'] = os.path.abspath(self._gen_fname(prefix, suffix='_WARP+tlrc')+ext)
3494+
outputs['source_warp'] = fname_presuffix(prefix,
3495+
suffix='_WARP' + suffix, use_ext=False) + ext
34903496
if self.inputs.iwarp:
3491-
outputs['base_warp'] = os.path.abspath(self._gen_fname(prefix, suffix='_WARPINV+tlrc')+ext)
3497+
outputs['base_warp'] = fname_presuffix(prefix,
3498+
suffix='_WARPINV' + suffix, use_ext=False) + ext
34923499
if isdefined(self.inputs.out_weight_file):
34933500
outputs['weights'] = os.path.abspath(self.inputs.out_weight_file)
34943501

34953502
if self.inputs.plusminus:
3496-
outputs['warped_source'] = os.path.abspath(self._gen_fname(prefix, suffix='_PLUS+tlrc')+ext)
3497-
outputs['warped_base'] = os.path.abspath(self._gen_fname(prefix, suffix='_MINUS+tlrc')+ext)
3498-
outputs['source_warp'] = os.path.abspath(self._gen_fname(prefix, suffix='_PLUS_WARP+tlrc')+ext)
3499-
outputs['base_warp'] = os.path.abspath(self._gen_fname(prefix, suffix='_MINUS_WARP+tlrc',)+ext)
3500-
3503+
outputs['warped_source'] = fname_presuffix(prefix,
3504+
suffix='_PLUS' + suffix, use_ext=False) + ext
3505+
outputs['warped_base'] = fname_presuffix(prefix,
3506+
suffix='_MINUS' + suffix, use_ext=False) + ext
3507+
outputs['source_warp'] = fname_presuffix(prefix,
3508+
suffix='_PLUS_WARP' + suffix, use_ext=False) + ext
3509+
outputs['base_warp'] = fname_presuffix(prefix,
3510+
suffix='_MINUS_WARP' + suffix, use_ext=False) + ext
35013511
return outputs
35023512

35033513
def _gen_filename(self, name):

nipype/interfaces/afni/tests/test_auto_Qwarp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_Qwarp_inputs():
5151
copyfile=False,
5252
mandatory=True,
5353
),
54-
inilev=dict(argstr='-inlev %d',
54+
inilev=dict(argstr='-inilev %d',
5555
xor=['duplo'],
5656
),
5757
iniwarp=dict(argstr='-iniwarp %s',

0 commit comments

Comments
 (0)