class_docstr: Template class to implement header protocol
class_docstr_tok: ["Template","class","to","implement","header","protocol"]
code: def from_header(
      klass: type[SpatialHdrT],
      header: SpatialProtocol
      | FileBasedHeader
      | ty.Mapping
      | None = None,
  ) -> SpatialHdrT:
      if header is None:
          return klass()
      # I can't do isinstance here because it is not necessarily true
      # that a subclass has exactly the same interface as its parent
      # - for example Nifti1Images inherit from Analyze, but have
      # different field names
      if type(header) == klass:
          return header.copy()
      if isinstance(header, SpatialProtocol):
          return klass(
              header.get_data_dtype(),
              header.get_data_shape(),
              header.get_zooms(),
          )
      return super().from_header(header)
  
imports: from __future__ import annotations
  import io
  import typing
  from collections.abc import Sequence
  from typing import Literal
  import numpy
  from .arrayproxy import ArrayLike
  from .casting import sctypes_aliases
  from .dataobj_images import DataobjImage
  from .filebasedimages import FileBasedHeader, FileBasedImage
  from .fileholders import FileMap
  from .fileslice import canonical_slicers
  from .orientations import apply_orientation, inv_ornt_aff
  from .viewers import OrthoSlicer3D
  from .volumeutils import shape_zoom_affine
label_desc: Use image node_id 2 for calling the SpatialHeader obj's underlying member method code with example usage: obj.from_header(klass, header) and returns: super, klass, header, klass