code: def test_unknown():
      # The 'unknown' coordinate space results from loading an image with no
      # affine set; allow setting into nifti iff the affine corresponds to the
      # default that would be created when there is no affine
      aimg = copy_of(anatfile)
      bare_affine = aimg.metadata["header"].get_base_affine()
      # The affine does not match the header-only affine
      assert not np.allclose(bare_affine, aimg.coordmap.affine)
      unknown_cs = unknown_csm(3)
      out_coords = aimg.reference.coord_names
      # So nipy2nifti raises an error
      displaced_img = aimg.renamed_reference(
          **dict(zip(out_coords[:3], unknown_cs.coord_names))
      )
      pytest.raises(NiftiError, nipy2nifti, displaced_img)
      # If the affine is the same, no error
      displaced_img.coordmap.affine[:] = bare_affine
      assert np.allclose(bare_affine, displaced_img.coordmap.affine)
      nimg = nipy2nifti(displaced_img)
      assert_array_equal(get_affine(nimg), bare_affine)
      # Get and check coordinate map
      inimg = nifti2nipy(nimg)
      assert inimg.coordmap.function_range in unknown_space
      # This also so if there is no header
      displaced_img.metadata.pop("header")
      nimg = nipy2nifti(displaced_img)
      assert_array_equal(get_affine(nimg), bare_affine)
      # Get and check coordinate map
      inimg = nifti2nipy(nimg)
      assert inimg.coordmap.function_range in unknown_space
  
imports: import warnings
  from copy import copy
  import nibabel
  import numpy
  import pytest
  from nibabel.affines import from_matvec
  from nibabel.spatialimages import HeaderDataError
  from numpy.testing import assert_array_equal
  from ...core.api import AffineTransform
  from ...core.api import CoordinateSystem
  from ...core.api import Image
  from ...core.reference.spaces import aligned_csm, mni_csm, scanner_csm, talairach_csm, unknown_csm, unknown_space, vox2mni
  from ...testing import anatfile, funcfile
  from ..files import load
  from ..nibcompat import get_affine, get_header
  from ..nifti_ref import NiftiError, nifti2nipy, nipy2nifti
label_desc: Use image node_id 4 for calling a global function with example usage: test_unknown() without return types