|
26 | 26 | from . import analyze # module import
|
27 | 27 | from .spm99analyze import SpmAnalyzeHeader
|
28 | 28 | from .casting import have_binary128
|
| 29 | +from nibabel.__future__ import future_flags |
29 | 30 |
|
30 | 31 | pdcm, have_dicom, _ = optional_package("pydicom")
|
31 | 32 |
|
@@ -1757,11 +1758,18 @@ def __init__(self, dataobj, affine, header=None,
|
1757 | 1758 | extra=None, file_map=None, dtype=None):
|
1758 | 1759 | danger_dts = (np.dtype("int64"), np.dtype("uint64"))
|
1759 | 1760 | if header is None and dtype is None and dataobj.dtype in danger_dts:
|
1760 |
| - msg = (f"Image data has type {dataobj.dtype}, which may cause " |
1761 |
| - "incompatibilities with other tools. This will error in " |
1762 |
| - "future versions of Nibabel. This warning can be silenced " |
1763 |
| - f"by passing the dtype argument to {self.__class__.__name__}().") |
1764 |
| - warnings.warn(msg, FutureWarning) |
| 1761 | + if future_flags['int64_error']: |
| 1762 | + raise ValueError( |
| 1763 | + f"Image data has type {dataobj.dtype}, which may cause " |
| 1764 | + "incompatibilities with other tools. To set an alternative " |
| 1765 | + f"on-disk dtype or force use of {dataobj.dtype}, pass a " |
| 1766 | + f"dtype argument to {self.__class__.__name__}().") |
| 1767 | + warnings.warn( |
| 1768 | + f"Image data has type {dataobj.dtype}, which may cause " |
| 1769 | + "incompatibilities with other tools. This will error in " |
| 1770 | + "future versions of Nibabel. This warning can be silenced " |
| 1771 | + f"by passing the dtype argument to {self.__class__.__name__}().", |
| 1772 | + FutureWarning) |
1765 | 1773 | super(Nifti1Pair, self).__init__(dataobj,
|
1766 | 1774 | affine,
|
1767 | 1775 | header,
|
|
0 commit comments