class_docstr: A medpy header object.
  
  Stores spacing, offset/origin, direction, and possibly further meta information.
  Provide at least one of the parameters. Missing information is extracted from
  the ``sitkimage`` or, if not supplied, set to a default value. 
  
  Parameters
  ----------
  spacing : tuple of floats
      the image's voxel spacing
      defaults to a tuple of `1.0`s
  offset : tuple of floats
      the image's offset/origin
      defaults to a tuple of `0.0`s
  direction : ndarray
      the image's affine transformation matrix
      must be of square shape
      default to the identity matrix
  sitkimage : sitk.Image
      the simple itk image as loaded
class_docstr_tok: ["A","medpy","header","object",".","Stores","spacing",",","offset\/origin",",","direction",",","and","possibly","further","meta","information",".","Provide","at","least","one","of","the","parameters",".","Missing","information","is","extracted","from","the","``","sitkimage","``","or",",","if","not","supplied",",","set","to","a","default","value",".","Parameters","--","--","--","--","--","spacing",":","tuple","of","floats","the","image","'s","voxel","spacing","defaults","to","a","tuple","of","`","1.0","`","s","offset",":","tuple","of","floats","the","image","'s","offset\/origin","defaults","to","a","tuple","of","`","0.0","`","s","direction",":","ndarray","the","image","'s","affine","transformation","matrix","must","be","of","square","shape","default","to","the","identity","matrix","sitkimage",":","sitk.Image","the","simple","itk","image","as","loaded"]
code: def __init__(
      self, spacing=None, offset=None, direction=None, sitkimage=None
  ):
      assert (
          sitkimage is not None
          or spacing is not None
          or offset is not None
          or direction is not None
      )
  
      # determin the image's ndim and default data types
      if direction is not None:
          direction = np.asarray(direction)
          ndim = len(direction.shape[0])
      elif offset is not None:
          offset = tuple(offset)
          ndim = len(offset)
      elif spacing is not None:
          spacing = tuple(spacing)
          ndim = len(spacing)
      else:
          ndim = len(sitkimage.GetSpacing())
  
      # set missing information to extracted or default values
      if spacing is None:
          spacing = (
              sitkimage.GetSpacing()
              if sitkimage is not None
              else (1.0,) * ndim
          )
      if offset is None:
          offset = (
              sitkimage.GetOrigin()
              if sitkimage is not None
              else (0.0,) * ndim
          )
      if direction is None:
          direction = (
              np.asarray(sitkimage.GetDirection()).reshape(ndim, ndim)
              if sitkimage is not None
              else np.identity(ndim)
          )
  
      # assert consistency
      assert len(spacing) == len(offset)
      assert direction.ndim == 2
      assert len(spacing) == direction.shape[0]
      assert direction.shape[0] == direction.shape[1]
  
      # set members
      self.spacing = spacing
      self.offset = offset
      self.direction = direction
      self.sitkimage = sitkimage
  
imports: import warnings
  import numpy
  from ..core import Logger
label_desc: Use image node_id 1 to create a new Header object  with example: obj = Header(spacing, offset, direction, sitkimage)