nipype
                                
                                 nipype copied to clipboard
                                
                                    nipype copied to clipboard
                            
                            
                            
                        AttributeError: 'PosixPath' object has no attribute 'lower'
Building backport for debian stable (buster) with python 3.7 leads to test_copy_header to error with
____________________________ test_copy_header[True] ____________________________
tmp_path = PosixPath('/tmp/pytest-of-pbuilder/pytest-0/test_copy_header_True_0')
keep_dtype = True
    @pytest.mark.parametrize("keep_dtype", (True, False))
    def test_copy_header(tmp_path, keep_dtype):
        """Cover copy_header."""
        fname1 = tmp_path / "reference.nii.gz"
        fname2 = tmp_path / "target.nii.gz"
    
        nii = nb.Nifti1Image(np.zeros((10, 10, 10), dtype="uint8"), None, None)
        nii.set_qform(np.diag((1.0, 2.0, 3.0, 1.0)), code=2)
        nii.set_sform(np.diag((1.0, 2.0, 3.0, 1.0)), code=1)
        nii.to_filename(str(fname1))
    
        nii.set_data_dtype("float32")
        nii.set_qform(np.eye(4), code=1)
        nii.to_filename(str(fname2))
    
>       copied = nb.load(copy_header(fname1, fname2, keep_dtype=keep_dtype))
/build/nipype-1.6.0/nipype/utils/tests/test_imagemanip.py:24: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/build/nipype-1.6.0/nipype/utils/imagemanip.py:7: in copy_header
    hdr_img = nb.load(header_file)
/usr/lib/python3/dist-packages/nibabel/loadsave.py:47: in load
    is_valid, sniff = image_klass.path_maybe_image(filename, sniff)
/usr/lib/python3/dist-packages/nibabel/filebasedimages.py:500: in path_maybe_image
    klass._compressed_suffixes)
/usr/lib/python3/dist-packages/nibabel/filename_parser.py:265: in splitext_addext
    if endswith(filename, ext):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
whole = PosixPath('/tmp/pytest-of-pbuilder/pytest-0/test_copy_header_True_0/reference.nii.gz')
end = '.gz'
    def _iendswith(whole, end):
>       return whole.lower().endswith(end.lower())
E       AttributeError: 'PosixPath' object has no attribute 'lower'
/usr/lib/python3/dist-packages/nibabel/filename_parser.py:223: AttributeError
d'oh -- just now realized that it is coming from nibabel, surprised that this code path was not triggered by any of its unittests. Transferring to nibabel
What version of nibabel? nibabel.load should handle pathlib.Paths as of 3.0.
Looks like the problem is that test in nipype assumes nibabel 3+, but nipype's minimum nibabel is 2.1.
@satra @oesteban Which seems more worthwhile, updating the minimum nibabel, or guarding accidental uses of Paths?
oh right -- I have missed that I did not have 3.x yet there, my bad, thank you @effigies !
Going to move this to nipype, since it is a dependency issue there. There is nothing to do in nibabel, since there is no plan to backport Path support to 2.5.x.
Which seems more worthwhile, updating the minimum nibabel
I think to update nibabel's minimum version is the right call here.
3.0 is only a year old. But I suppose if somebody can upgrade to nipype 1.6+, they can upgrade to nibabel 3.0+.