class_docstr: Class for MGH format header
  
  The header also consists of the footer data which MGH places after the data
  chunk.
class_docstr_tok: ["Class","for","MGH","format","header","The","header","also","consists","of","the","footer","data","which","MGH","places","after","the","data","chunk","."]
docstr: classmethod for loading a MGH fileobject
docstr_tok: ["classmethod","for","loading","a","MGH","fileobject"]
code: def from_fileobj(klass, fileobj, check=True):
      """
      classmethod for loading a MGH fileobject
      """
      # We need the following hack because MGH data stores header information
      # after the data chunk too. We read the header initially, deduce the
      # dimensions from the header, skip over and then read the footer
      # information
      hdr_str = fileobj.read(klass._hdrdtype.itemsize)
      hdr_str_to_np = np.ndarray(
          shape=(), dtype=klass._hdrdtype, buffer=hdr_str
      )
      if not np.all(hdr_str_to_np["dims"]):
          raise MGHError("Dimensions of the data should be non-zero")
      tp = int(hdr_str_to_np["type"])
      fileobj.seek(
          DATA_OFFSET
          + int(klass._data_type_codes.bytespervox[tp])
          * np.prod(hdr_str_to_np["dims"])
      )
      ftr_str = fileobj.read(klass._ftrdtype.itemsize)
      return klass(hdr_str + ftr_str, check=check)
  
imports: from os.path import splitext
  import numpy
  from ..affines import from_matvec, voxel_sizes
  from ..arrayproxy import ArrayProxy, reshape_dataobj
  from ..batteryrunners import BatteryRunner, Report
  from ..filebasedimages import SerializableImage
  from ..fileholders import FileHolder
  from ..filename_parser import _stringify_path
  from ..openers import ImageOpener
  from ..spatialimages import HeaderDataError, SpatialHeader, SpatialImage
  from ..volumeutils import Recoder, array_from_file, array_to_file, endian_codes
  from ..wrapstruct import LabeledWrapStruct
label_desc: Use image node_id 5 for calling the MGHHeader obj's underlying member method code with example usage: obj.from_fileobj(klass, fileobj, check) and returns: klass