Skip to content
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

AFNI Zeropad out_file undefined #3640

Open
zachlindsey opened this issue Mar 20, 2024 · 1 comment · May be fixed by #3641
Open

AFNI Zeropad out_file undefined #3640

zachlindsey opened this issue Mar 20, 2024 · 1 comment · May be fixed by #3641

Comments

@zachlindsey
Copy link

zachlindsey commented Mar 20, 2024

Summary

It looks like something odd is happening with some of the AFNI input specs. Here is the current one for Zeropad:

    out_file = File(
        name_template="zeropad",
        desc="output dataset prefix name (default 'zeropad')",
        argstr="-prefix %s",
    )

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

Platform details:

{'commit_hash': '<not found>',
 'commit_source': '(none found)',
 'networkx_version': '3.2.1',
 'nibabel_version': '5.2.1',
 'nipype_version': '1.8.6',
 'numpy_version': '1.26.4',
 'pkg_path': '/home/epl6876/.cache/pypoetry/virtualenvs/abc-image-processing-bNVxWkFq-py3.9/lib/python3.9/site-packages/nipype',
 'scipy_version': '1.12.0',
 'sys_executable': '/home/epl6876/.cache/pypoetry/virtualenvs/abc-image-processing-bNVxWkFq-py3.9/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.9.18 (main, Feb  1 2024, 11:48:51) \n[GCC 11.4.0]',
 'traits_version': '6.3.2'}

Execution environment

My python environment outside container

@zachlindsey zachlindsey linked a pull request Mar 20, 2024 that will close this issue
@zachlindsey
Copy link
Author

I should mention I think that several other of the AFNI commands suffer from the same problem. If I should fix all of them, I can do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant