code: def test_slice2volume():
      # Get affine expressing selection of single slice from volume
      for axis, def_aff in zip(
          (0, 1, 2),
          (
              [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
              [[1, 0, 0], [0, 0, 0], [0, 1, 0], [0, 0, 1]],
              [[1, 0, 0], [0, 1, 0], [0, 0, 0], [0, 0, 1]],
          ),
      ):
          for val in (0, 5, 10):
              exp_aff = np.array(def_aff)
              exp_aff[axis, -1] = val
              assert (slice2volume(val, axis) == exp_aff).all()
  
file_path: nibabel/nibabel/tests/test_spaces.py
imports: import numpy
  import numpy.linalg
  import pytest
  from numpy.testing import assert_almost_equal
  from ..affines import apply_affine, from_matvec
  from ..eulerangles import euler2mat
  from ..nifti1 import Nifti1Image
  from ..spaces import slice2volume, vox2out_vox
label_desc: Use image node_id 4 for calling a global function with example usage: test_slice2volume() without return types