code: def test_from_analyze_map(self):
      # Test that any header can pass values from a mapping
      klass = self.header_class
      # Header needs to implement data_dtype, data_shape, zooms
  
      class H1:
          pass
  
      with pytest.raises(AttributeError):
          klass.from_header(H1())
  
      class H2:
          def get_data_dtype(self):
              return np.dtype("u1")
  
      with pytest.raises(AttributeError):
          klass.from_header(H2())
  
      class H3(H2):
          def get_data_shape(self):
              return (2, 3, 4)
  
      with pytest.raises(AttributeError):
          klass.from_header(H3())
  
      class H4(H3):
          def get_zooms(self):
              return 4.0, 5.0, 6.0
  
      exp_hdr = klass()
      exp_hdr.set_data_dtype(np.dtype("u1"))
      exp_hdr.set_data_shape((2, 3, 4))
      exp_hdr.set_zooms((4, 5, 6))
      assert klass.from_header(H4()) == exp_hdr
      # cal_max, cal_min get properly set from ``as_analyze_map``
  
      class H5(H4):
          def as_analyze_map(self):
              return dict(cal_min=-100, cal_max=100)
  
      exp_hdr["cal_min"] = -100
      exp_hdr["cal_max"] = 100
      assert klass.from_header(H5()) == exp_hdr
      # set_* methods override fields from header
  
      class H6(H5):
          def as_analyze_map(self):
              return dict(
                  datatype=4, bitpix=32, cal_min=-100, cal_max=100
              )
  
      assert klass.from_header(H6()) == exp_hdr
      # Any mapping will do, including a Nifti header
  
      class H7(H5):
          def as_analyze_map(self):
              n_hdr = Nifti1Header()
              n_hdr.set_data_dtype(np.dtype("i2"))
              n_hdr["cal_min"] = -100
              n_hdr["cal_max"] = 100
              return n_hdr
  
      # Values from methods still override values from header (shape, dtype,
      # zooms still at defaults from n_hdr header fields above)
      assert klass.from_header(H7()) == exp_hdr
  
imports: import itertools
  import logging
  import os
  import pickle
  import re
  from io import BytesIO, StringIO
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from ..None import imageglobals
  from ..analyze import AnalyzeHeader, AnalyzeImage
  from ..arraywriters import WriterError
  from ..casting import sctypes_aliases
  from ..nifti1 import Nifti1Header
  from ..optpkg import optional_package
  from ..spatialimages import HeaderDataError, HeaderTypeError, supported_np_types
  from ..testing import assert_dt_equal, bytesio_filemap, bytesio_round_trip, data_path, suppress_warnings
  from ..tmpdirs import InTemporaryDirectory
  from .None import test_spatialimages
  from .None import test_wrapstruct
label_desc: Use image node_id 27 for calling the TestAnalyzeHeader obj's underlying member method code with example usage: obj.test_from_analyze_map() and returns: np, int,  int,  int, int,  int,  int, dict, dict, n_hdr