code: def test_from_header():
      # check from header class method.  Note equality checks below,
      # equality methods used here too.
      empty = SpatialHeader.from_header()
      assert SpatialHeader() == empty
      empty = SpatialHeader.from_header(None)
      assert SpatialHeader() == empty
      hdr = SpatialHeader(
          np.float64, shape=(1, 2, 3), zooms=(3.0, 2.0, 1.0)
      )
      copy = SpatialHeader.from_header(hdr)
      assert hdr == copy
      assert hdr is not copy
  
      class C:
          def get_data_dtype(self):
              return np.dtype("u2")
  
          def get_data_shape(self):
              return (5, 4, 3)
  
          def get_zooms(self):
              return (10.0, 9.0, 8.0)
  
      converted = SpatialHeader.from_header(C())
      assert isinstance(converted, SpatialHeader)
      assert converted.get_data_dtype() == np.dtype("u2")
      assert converted.get_data_shape() == (5, 4, 3)
      assert converted.get_zooms() == (10.0, 9.0, 8.0)
  
imports: from io import BytesIO
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal
  from ..None import load
  from ..imageclasses import spatial_axes_first
  from ..spatialimages import HeaderDataError, SpatialHeader, SpatialImage
  from ..testing import bytesio_round_trip, expires, memmap_after_ufunc
  from ..tmpdirs import InTemporaryDirectory
label_desc: Use image node_id 2 for calling a global function with example usage: test_from_header() and returns: np, int,  int,  int, int,  int,  int