def test_numpy_image_container_voxel_size_mm_getter( numpy_image_container: NumpyImageContainer, ): """ Test that the correct voxel size is returned from a NumpyImageContainer """ # NIFTI header has mm in xyzt_units np.testing.assert_array_almost_equal(numpy_image_container.voxel_size_mm, np.array([2.0, 2.0, 2.2])) numpy_image_container.space_units = UNITS_METERS np.testing.assert_array_almost_equal(numpy_image_container.voxel_size_mm, np.array([2000.0, 2000.0, 2200.0])) numpy_image_container.space_units = UNITS_MICRONS np.testing.assert_array_almost_equal(numpy_image_container.voxel_size_mm, np.array([2.0e-3, 2.0e-3, 2.2e-3]))
def test_numpy_image_container_voxel_size_mm_setter( numpy_image_container: NumpyImageContainer, ): """ Test that the correct voxel size is set on a NumpyImageContainer """ # voxel size is 2x2x2mm numpy_image_container.voxel_size_mm = [3.0, 2.0, 1.0] numpy_image_container.space_units = UNITS_METERS # Just test that we have 3x2x1m reported in mm np.testing.assert_array_almost_equal(numpy_image_container.voxel_size_mm, np.array([3000.0, 2000.0, 1000.0]))