From what I can tell, it makes no sense to provide a name_template that doesn't have any %s characters, and also to provide it when there is no name_source. The underlying AFNI command seems to always just output "zeropad" if you don't provide a prefix, with no reference to the input file at all.
But it gets worse! It also seems like if an input doesn't have a name_source field on the input spec, the out_file field on the outputs will always be undefined!
Actual behavior
When you run the code below in a python interactive environment, it raises an error on the second assertion, and the final line outputs <undefined>. Since the out_file is undefined, if this is a node in a workflow, you cannot connect its output to other nodes without headaches.
Expected behavior
Set the out_file to the full filepath of the padded.nii.gz file. If no output file is specified, set it to the full filepath of the default output file, zeropad+tlrc.BRIK,
How to replicate the behavior
Script/Workflow details
from pathlib import Path
import os
from nipype.interfaces.afni import Zeropad
cwd = os.getcwd()
expected_outfile = Path(cwd) / "test_pad.nii.gz"
if expected_outfile.exists():
expected_outfile.unlink()
zp = Zeropad(I = 1, out_file = "test_pad.nii.gz")
zp.inputs.in_files = "/your/test/nifii.nii.gz"
result = zp.run()
assert expected_outfile.exists()
assert result.outputs.out_file == expected_outfile
result.outputs.out_file
Summary
It looks like something odd is happening with some of the AFNI input specs. Here is the current one for Zeropad:
From what I can tell, it makes no sense to provide a
name_template
that doesn't have any%s
characters, and also to provide it when there is noname_source
. The underlying AFNI command seems to always just output "zeropad" if you don't provide a prefix, with no reference to the input file at all.But it gets worse! It also seems like if an input doesn't have a
name_source
field on the input spec, theout_file
field on the outputs will always be undefined!Actual behavior
When you run the code below in a python interactive environment, it raises an error on the second assertion, and the final line outputs
<undefined>
. Since theout_file
is undefined, if this is a node in a workflow, you cannot connect its output to other nodes without headaches.Expected behavior
Set the
out_file
to the full filepath of thepadded.nii.gz
file. If no output file is specified, set it to the full filepath of the default output file,zeropad+tlrc.BRIK
,How to replicate the behavior
Script/Workflow details
Platform details:
Execution environment
My python environment outside container