code: def test_files_interface():
      # test high-level interface to files mapping
      arr = np.zeros((2, 3, 4))
      aff = np.eye(4)
      img = Nifti1Image(arr, aff)
      # single image
      img.set_filename("test")
      assert img.get_filename() == "test.nii"
      assert img.file_map["image"].filename == "test.nii"
      with pytest.raises(KeyError):
          img.file_map["header"]
      # pair - note new class
      img = Nifti1Pair(arr, aff)
      img.set_filename("test")
      assert img.get_filename() == "test.img"
      assert img.file_map["image"].filename == "test.img"
      assert img.file_map["header"].filename == "test.hdr"
      # fileobjs - single image
      img = Nifti1Image(arr, aff)
      img.file_map["image"].fileobj = BytesIO()
      img.to_file_map()  # saves to files
      img2 = Nifti1Image.from_file_map(img.file_map)
      # img still has correct data
      assert_array_equal(img2.get_fdata(), img.get_fdata())
      # fileobjs - pair
      img = Nifti1Pair(arr, aff)
      img.file_map["image"].fileobj = BytesIO()
      # no header yet
      with pytest.raises(FileHolderError):
          img.to_file_map()
      img.file_map["header"].fileobj = BytesIO()
      img.to_file_map()  # saves to files
      img2 = Nifti1Pair.from_file_map(img.file_map)
      # img still has correct data
      assert_array_equal(img2.get_fdata(), img.get_fdata())
  
file_path: nibabel/nibabel/tests/test_files_interface.py
imports: from io import BytesIO
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from ..None import MGHImage, Nifti1Image, Nifti1Pair, all_image_classes
  from ..fileholders import FileHolderError
  from ..spatialimages import SpatialImage
label_desc: Use image node_id 2 for calling a global function with example usage: test_files_interface() without return types