code: def test_origin_affine():
      hdr = Spm99AnalyzeHeader()
      aff = hdr.get_origin_affine()
      assert_array_equal(aff, hdr.get_base_affine())
      hdr.set_data_shape((3, 5, 7))
      hdr.set_zooms((3, 2, 1))
      assert hdr.default_x_flip
      assert_array_almost_equal(
          hdr.get_origin_affine(),  # from center of image
          [
              [-3.0, 0.0, 0.0, 3.0],
              [0.0, 2.0, 0.0, -4.0],
              [0.0, 0.0, 1.0, -3.0],
              [0.0, 0.0, 0.0, 1.0],
          ],
      )
      hdr["origin"][:3] = [3, 4, 5]
      assert_array_almost_equal(
          hdr.get_origin_affine(),  # using origin
          [
              [-3.0, 0.0, 0.0, 6.0],
              [0.0, 2.0, 0.0, -6.0],
              [0.0, 0.0, 1.0, -4.0],
              [0.0, 0.0, 0.0, 1.0],
          ],
      )
      hdr["origin"] = 0  # unset origin
      hdr.set_data_shape((3, 5))
      assert_array_almost_equal(
          hdr.get_origin_affine(),
          [
              [-3.0, 0.0, 0.0, 3.0],
              [0.0, 2.0, 0.0, -4.0],
              [0.0, 0.0, 1.0, -0.0],
              [0.0, 0.0, 0.0, 1.0],
          ],
      )
      hdr.set_data_shape((3, 5, 7))
      assert_array_almost_equal(
          hdr.get_origin_affine(),  # from center of image
          [
              [-3.0, 0.0, 0.0, 3.0],
              [0.0, 2.0, 0.0, -4.0],
              [0.0, 0.0, 1.0, -3.0],
              [0.0, 0.0, 0.0, 1.0],
          ],
      )
  
imports: import itertools
  import unittest
  from io import BytesIO
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from ..optpkg import optional_package
  from ..casting import sctypes_aliases, shared_range, type_info
  from ..spatialimages import HeaderDataError
  from ..spm99analyze import HeaderTypeError, Spm99AnalyzeHeader, Spm99AnalyzeImage
  from ..testing import assert_allclose_safely, bytesio_filemap, bytesio_round_trip, suppress_warnings
  from ..volumeutils import _dt_min_max, apply_read_scaling
  from .None import test_analyze
label_desc: Use image node_id 1 for calling a global function with example usage: test_origin_affine() without return types