-
Notifications
You must be signed in to change notification settings - Fork 530
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
[WIP] FIX - AFNI Zeropad sets out_file #3641
base: master
Are you sure you want to change the base?
Conversation
…ing_and_separators use csvreader for parsing csv files
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3641 +/- ##
==========================================
- Coverage 63.44% 0 -63.45%
==========================================
Files 308 0 -308
Lines 40887 0 -40887
Branches 5655 0 -5655
==========================================
- Hits 25942 0 -25942
+ Misses 13909 0 -13909
+ Partials 1036 0 -1036 ☔ View full report in Codecov by Sentry. |
After trying out this fix for my workflow, I've realized that out_file needs to be an absolute path! Will fix. |
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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): | |
from pathlib import Path | |
from shutil import which | |
import pytest | |
from nipype import Node | |
from nipype.interfaces.afni import Zeropad | |
from nipype.testing.fixtures import create_files_in_directory | |
needs_3dZeropad = pytest.mark.skipif( | |
not which('3dZeropad'), | |
reason='Needs AFNI 3dZeropad installed' | |
) | |
@needs_3dZeropad | |
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" | |
@needs_3dZeropad | |
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" | |
@needs_3dZeropad | |
def test_zeropad_keeps_file_after_node_run(create_files_in_directory): |
Made a suggestion. Haven't tested it, but if you commit and run locally, those tests should pass. They'll skip on CI. |
Summary
Fixes #3640 .
List of changes proposed in this PR (pull-request)
name_template
fromZeropadInputSpec
, since it is useless if it is not a format string and the underlying command doesn't form outputs from the input name._list_outputs
method to set the correct out file.