|
21 | 21 | from .arrayproxy import get_obj_dtype |
22 | 22 | from .batteryrunners import Report |
23 | 23 | from .casting import have_binary128 |
| 24 | +from .deprecated import alert_future_error |
24 | 25 | from .filebasedimages import SerializableImage |
25 | 26 | from .optpkg import optional_package |
26 | 27 | from .quaternions import fillpositive, mat2quat, quat2mat |
@@ -1831,13 +1832,16 @@ def __init__(self, dataobj, affine, header=None, extra=None, file_map=None, dtyp |
1831 | 1832 | # already fail. |
1832 | 1833 | danger_dts = (np.dtype('int64'), np.dtype('uint64')) |
1833 | 1834 | if header is None and dtype is None and get_obj_dtype(dataobj) in danger_dts: |
1834 | | - msg = ( |
| 1835 | + alert_future_error( |
1835 | 1836 | f'Image data has type {dataobj.dtype}, which may cause ' |
1836 | | - 'incompatibilities with other tools. This will error in ' |
1837 | | - 'NiBabel 5.0. This warning can be silenced ' |
1838 | | - f'by passing the dtype argument to {self.__class__.__name__}().' |
| 1837 | + 'incompatibilities with other tools.', |
| 1838 | + '5.0', |
| 1839 | + warning_rec='This warning can be silenced by passing the dtype argument' |
| 1840 | + f' to {self.__class__.__name__}().', |
| 1841 | + error_rec='To use this type, pass an explicit header or dtype argument' |
| 1842 | + f' to {self.__class__.__name__}().', |
| 1843 | + error_class=ValueError, |
1839 | 1844 | ) |
1840 | | - warnings.warn(msg, FutureWarning, stacklevel=2) |
1841 | 1845 | super().__init__(dataobj, affine, header, extra, file_map, dtype) |
1842 | 1846 | # Force set of s/q form when header is None unless affine is also None |
1843 | 1847 | if header is None and affine is not None: |
|
0 commit comments