From 70970d319375d2eb8ca4aca78e9b2364d78f6d4b Mon Sep 17 00:00:00 2001 From: salma1601 Date: Mon, 9 Oct 2017 17:18:35 +0200 Subject: [PATCH 1/2] fix typo and output paths in qwarp --- nipype/interfaces/afni/preprocess.py | 30 ++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index 9fdb1cbc5d..ca9b4e8414 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -15,7 +15,8 @@ import os import os.path as op -from ...utils.filemanip import (load_json, save_json, split_filename) +from ...utils.filemanip import (load_json, save_json, split_filename, + fname_presuffix) from ..base import ( CommandLineInputSpec, CommandLine, TraitedSpec, traits, isdefined, File, InputMultiPath, Undefined, Str) @@ -3131,7 +3132,7 @@ class QwarpInputSpec(AFNICommandInputSpec): 'Note that the source dataset in the second run is the SAME as' 'in the first run. If you don\'t see why this is necessary,' 'then you probably need to seek help from an AFNI guru.', - argstr='-inlev %d', + argstr='-inilev %d', xor=['duplo']) minpatch = traits.Int( desc='* The value of mm should be an odd integer.' @@ -3475,29 +3476,38 @@ def _list_outputs(self): if not isdefined(self.inputs.out_file): prefix = self._gen_fname(self.inputs.in_file, suffix='_QW') ext = '.HEAD' + suffix ='+tlrc' else: prefix = self.inputs.out_file ext_ind = max([prefix.lower().rfind('.nii.gz'), prefix.lower().rfind('.nii.')]) if ext_ind == -1: ext = '.HEAD' + suffix = '+tlrc' else: ext = prefix[ext_ind:] + suffix = '' print(ext,"ext") - outputs['warped_source'] = os.path.abspath(self._gen_fname(prefix, suffix='+tlrc')+ext) + outputs['warped_source'] = fname_presuffix(prefix, suffix=suffix, + use_ext=False) + ext if not self.inputs.nowarp: - outputs['source_warp'] = os.path.abspath(self._gen_fname(prefix, suffix='_WARP+tlrc')+ext) + outputs['source_warp'] = fname_presuffix(prefix, + suffix='_WARP' + suffix, use_ext=False) + ext if self.inputs.iwarp: - outputs['base_warp'] = os.path.abspath(self._gen_fname(prefix, suffix='_WARPINV+tlrc')+ext) + outputs['base_warp'] = fname_presuffix(prefix, + suffix='_WARPINV' + suffix, use_ext=False) + ext if isdefined(self.inputs.out_weight_file): outputs['weights'] = os.path.abspath(self.inputs.out_weight_file) if self.inputs.plusminus: - outputs['warped_source'] = os.path.abspath(self._gen_fname(prefix, suffix='_PLUS+tlrc')+ext) - outputs['warped_base'] = os.path.abspath(self._gen_fname(prefix, suffix='_MINUS+tlrc')+ext) - outputs['source_warp'] = os.path.abspath(self._gen_fname(prefix, suffix='_PLUS_WARP+tlrc')+ext) - outputs['base_warp'] = os.path.abspath(self._gen_fname(prefix, suffix='_MINUS_WARP+tlrc',)+ext) - + outputs['warped_source'] = fname_presuffix(prefix, + suffix='_PLUS' + suffix, use_ext=False) + ext + outputs['warped_base'] = fname_presuffix(prefix, + suffix='_MINUS' + suffix, use_ext=False) + ext + outputs['source_warp'] = fname_presuffix(prefix, + suffix='_PLUS_WARP' + suffix, use_ext=False) + ext + outputs['base_warp'] = fname_presuffix(prefix, + suffix='_MINUS_WARP' + suffix, use_ext=False) + ext return outputs def _gen_filename(self, name): From ca3e8a3f28e37faff2bac5de272a486a41823206 Mon Sep 17 00:00:00 2001 From: salma1601 Date: Mon, 9 Oct 2017 22:40:49 +0200 Subject: [PATCH 2/2] update test --- nipype/interfaces/afni/preprocess.py | 2 +- nipype/interfaces/afni/tests/test_auto_Qwarp.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index ca9b4e8414..736732042c 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -3463,7 +3463,7 @@ class Qwarp(AFNICommand): >>> qwarp2.inputs.inilev = 7 >>> qwarp2.inputs.iniwarp = ['Q25_warp+tlrc.HEAD'] >>> qwarp2.cmdline # doctest: +ALLOW_UNICODE - '3dQwarp -base mni.nii -blur 0.0 2.0 -source structural.nii -inlev 7 -iniwarp Q25_warp+tlrc.HEAD -prefix Q11' + '3dQwarp -base mni.nii -blur 0.0 2.0 -source structural.nii -inilev 7 -iniwarp Q25_warp+tlrc.HEAD -prefix Q11' >>> res2 = qwarp2.run() # doctest: +SKIP """ _cmd = '3dQwarp' diff --git a/nipype/interfaces/afni/tests/test_auto_Qwarp.py b/nipype/interfaces/afni/tests/test_auto_Qwarp.py index 2ea08c4c0e..358d80efb2 100644 --- a/nipype/interfaces/afni/tests/test_auto_Qwarp.py +++ b/nipype/interfaces/afni/tests/test_auto_Qwarp.py @@ -51,7 +51,7 @@ def test_Qwarp_inputs(): copyfile=False, mandatory=True, ), - inilev=dict(argstr='-inlev %d', + inilev=dict(argstr='-inilev %d', xor=['duplo'], ), iniwarp=dict(argstr='-iniwarp %s',