Slicer does not accept certain transform values

3d slicer does not import volumes that I create with the python code below.
What constraint in 3D slicer is causing this?

import numpy as np

import nibabel as nib
from nibabel import affines

data = np.random.normal(size=(100, 100, 100))

# this works, imports into 3D Slicer:
rotation = 4.683045966258175
translation = np.round(np.array([364049.08509937, 5991031.44814528, 0.]))

# this works, imports into 3D Slicer:
rotation = 4.69
translation = np.round(np.array([364049.08509937, 5991031.44814528, 0.]))

# this does not import into 3D Slicer:
rotation = 4.683045966258175
translation = np.array([364049.08509937, 5991031.44814528, 0.])

dxv = 0.05
dyv = 0.05
affine = np.array([[np.cos(rotation) * dxv, -np.sin(rotation) * dyv, 0],
                   [np.sin(rotation) * dxv, np.cos(rotation) * dyv, 0],
                   [0, 0, 1]]
                  )


nii_matrix = affines.from_matvec(affine, translation)

nifti_img = nib.Nifti1Image(data, nii_matrix)
nib.save(nifti_img, r"D:\TEST\test.nii")

I suspect it might have to do with units within 3D slicer. I tested with these settings:

Probably the non-normalized image position values cause the problem.

Units are not causing the problem: support in Slicer is added to be able to avoid such extreme position values by choosing the most appropriate coordinate system. However, current units implementation has many limitations, so it cannot yet automatically fix such files yet.

I see that you added an issue for this, let’s continue the discussion there: