code: def test_two_to_one():
      # test going from two to one file in save
      shape = (2, 4, 6)
      npt = np.float32
      data = np.arange(np.prod(shape), dtype=npt).reshape(shape)
      affine = np.diag([1, 2, 3, 1])
      affine[:3, 3] = [3, 2, 1]
      # single file format
      img = ni1.Nifti1Image(data, affine)
      assert img.header["magic"] == b"n+1"
      str_io = BytesIO()
      img.file_map["image"].fileobj = str_io
      # check that the single format vox offset stays at zero
      img.to_file_map()
      assert img.header["magic"] == b"n+1"
      assert img.header["vox_offset"] == 0
      # make a new pair image, with the single image header
      pimg = ni1.Nifti1Pair(data, affine, img.header)
      isio = BytesIO()
      hsio = BytesIO()
      pimg.file_map["image"].fileobj = isio
      pimg.file_map["header"].fileobj = hsio
      pimg.to_file_map()
      # the offset stays at zero (but is 352 on disk)
      assert pimg.header["magic"] == b"ni1"
      assert pimg.header["vox_offset"] == 0
      assert_array_equal(pimg.get_fdata(), data)
      # same for from_image, going from single image to pair format
      ana_img = ana.AnalyzeImage.from_image(img)
      assert ana_img.header["vox_offset"] == 0
      # back to the single image, save it again to a stringio
      str_io = BytesIO()
      img.file_map["image"].fileobj = str_io
      img.to_file_map()
      assert img.header["vox_offset"] == 0
      aimg = ana.AnalyzeImage.from_image(img)
      assert aimg.header["vox_offset"] == 0
      aimg = spm99.Spm99AnalyzeImage.from_image(img)
      assert aimg.header["vox_offset"] == 0
      aimg = spm2.Spm2AnalyzeImage.from_image(img)
      assert aimg.header["vox_offset"] == 0
      nfimg = ni1.Nifti1Pair.from_image(img)
      assert nfimg.header["vox_offset"] == 0
      # now set the vox offset directly
      hdr = nfimg.header
      hdr["vox_offset"] = 16
      assert nfimg.header["vox_offset"] == 16
      # check it gets properly set by the nifti single image
      nfimg = ni1.Nifti1Image.from_image(img)
      assert nfimg.header["vox_offset"] == 0
  
imports: import logging
  import pathlib
  import shutil
  from io import BytesIO
  from os.path import dirname
  from os.path import join
  from tempfile import mkdtemp
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from ..None import AnalyzeImage, MGHImage, Minc1Image, Minc2Image, Nifti1Header, Nifti1Image, Nifti1Pair, Nifti2Image, Nifti2Pair, Spm2AnalyzeImage, Spm99AnalyzeImage, all_image_classes
  from ..None import analyze
  from ..None import loadsave
  from ..None import nifti1
  from ..None import spm2analyze
  from ..None import spm99analyze
  from ..optpkg import optional_package
  from ..spatialimages import SpatialImage
  from ..testing import expires
  from ..tmpdirs import InTemporaryDirectory
  from ..volumeutils import native_code, swapped_code
label_desc: Use image node_id 5 for calling a global function with example usage: test_two_to_one() without return types