Skip to content

Commit 49b1d41

Browse files
committed
FIX: Better
1 parent 4630e0d commit 49b1d41

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

nibabel/nifti1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,7 @@ def _get_analyze_compat_dtype(arr):
24432443
return np.dtype('int16' if arr.max() <= np.iinfo(np.int16).max else 'int32')
24442444

24452445
mn, mx = arr.min(), arr.max()
2446-
if arr.dtype.kind == 'i':
2446+
if arr.dtype.kind in 'iu':
24472447
info = np.iinfo('int32')
24482448
if mn >= info.min and mx <= info.max:
24492449
return np.dtype('int32')

nibabel/tests/test_spm99analyze.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ def test_no_scaling(self, in_dtype, supported_dtype):
328328
inter = 10 if hdr.has_data_intercept else 0
329329

330330
mn_in, mx_in = _dt_min_max(in_dtype)
331-
arr = np.array([mn_in, -1, 0, 1, 10, mx_in], dtype=in_dtype)
331+
mn = -1 if np.dtype(in_dtype).kind != 'u' else 0
332+
arr = np.array([mn_in, mn, 0, 1, 10, mx_in], dtype=in_dtype)
332333
img = img_class(arr, np.eye(4), hdr)
333334
img.set_data_dtype(supported_dtype)
334335
# Setting the scaling means we don't calculate it later

0 commit comments

Comments
 (0)