[WIP] FIX - AFNI Zeropad sets out_file #3641
[WIP] FIX - AFNI Zeropad sets out_file #3641zachlindsey wants to merge 6 commits intonipy:masterfrom
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.
| 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. |
effigies
left a comment
There was a problem hiding this comment.
Left a suggestion a while back. Marking as requested changes so I can easily see the status. Please re-request review if/when you update this.
Summary
Fixes #3640 .
List of changes proposed in this PR (pull-request)
name_templatefromZeropadInputSpec, since it is useless if it is not a format string and the underlying command doesn't form outputs from the input name._list_outputsmethod to set the correct out file.