diff --git a/nipype/interfaces/afni/tests/test_auto_Zeropad.py b/nipype/interfaces/afni/tests/test_auto_Zeropad.py index 4d6742f21e..bd5cd1eb34 100644 --- a/nipype/interfaces/afni/tests/test_auto_Zeropad.py +++ b/nipype/interfaces/afni/tests/test_auto_Zeropad.py @@ -70,7 +70,6 @@ def test_Zeropad_inputs(): out_file=dict( argstr="-prefix %s", extensions=None, - name_template="zeropad", ), outputtype=dict(), z=dict( diff --git a/nipype/interfaces/afni/tests/test_extra_Zeropad.py b/nipype/interfaces/afni/tests/test_extra_Zeropad.py new file mode 100644 index 0000000000..086d65bbf9 --- /dev/null +++ b/nipype/interfaces/afni/tests/test_extra_Zeropad.py @@ -0,0 +1,39 @@ +from pathlib import Path +from nipype import Node +from nipype.interfaces.afni import Zeropad +from nipype.testing.fixtures import create_files_in_directory + + +def test_zeropad_handles_outfile_default(create_files_in_directory): + filelist, outdir = create_files_in_directory + zp = Zeropad(I=1) + zp.inputs.in_files = filelist[0] + + result = zp.run() + + assert (Path(outdir) / "zeropad+tlrc.BRIK").exists() + assert Path(result.outputs.out_file).name == "zeropad+tlrc.BRIK" + + +def test_zeropad_handles_outfile_specified_nii_gz(create_files_in_directory): + filelist, outdir = create_files_in_directory + zp = Zeropad(I=1, out_file="padded.nii.gz") + zp.inputs.in_files = filelist[0] + + result = zp.run() + + assert (Path(outdir) / "padded.nii.gz").exists() + assert Path(result.outputs.out_file).name == "padded.nii.gz" + + +def test_zeropad_keeps_file_after_node_run(create_files_in_directory): + filelist, outdir = create_files_in_directory + + zp = Node( + Zeropad(I=1, out_file="padded.nii.gz"), name="test_zeropad", base_dir=outdir + ) + zp.inputs.in_files = Path(outdir) / filelist[0] + + result = zp.run() + assert (Path(zp.output_dir()) / "padded.nii.gz").exists() + assert Path(result.outputs.out_file).name == "padded.nii.gz" diff --git a/nipype/interfaces/afni/utils.py b/nipype/interfaces/afni/utils.py index 5fb1cd1e64..f10ca43048 100644 --- a/nipype/interfaces/afni/utils.py +++ b/nipype/interfaces/afni/utils.py @@ -3391,7 +3391,6 @@ class ZeropadInputSpec(AFNICommandInputSpec): copyfile=False, ) out_file = File( - name_template="zeropad", desc="output dataset prefix name (default 'zeropad')", argstr="-prefix %s", ) @@ -3497,3 +3496,10 @@ class Zeropad(AFNICommand): _cmd = "3dZeropad" input_spec = ZeropadInputSpec output_spec = AFNICommandOutputSpec + + def _list_outputs(self): + out_file = getattr(self.inputs, "out_file") + + if not isdefined(out_file): + out_file = "zeropad+tlrc.BRIK" + return {"out_file": op.abspath(out_file)}