class_docstr: Class to wrap MINC2 format file
  
  Although it has some of the same methods as a ``Header``, we use
  this only when reading a MINC2 file, to pull out useful header
  information, and for the method of reading the data out
class_docstr_tok: ["Class","to","wrap","MINC2","format","file","Although","it","has","some","of","the","same","methods","as","a","``","Header","``",",","we","use","this","only","when","reading","a","MINC2","file",",","to","pull","out","useful","header","information",",","and","for","the","method","of","reading","the","data","out"]
code: def __init__(self, mincfile):
      self._mincfile = mincfile
      minc_part = mincfile["minc-2.0"]
      # The whole image is the first of the entries in 'image'
      image = minc_part["image"]["0"]
      self._image = image["image"]
      self._dim_names = self._get_dimensions(self._image)
      dimensions = minc_part["dimensions"]
      self._dims = [Hdf5Bunch(dimensions[s]) for s in self._dim_names]
      # We don't currently support irregular spacing
      # https://en.wikibooks.org/wiki/MINC/Reference/MINC2.0_File_Format_Reference#Dimension_variable_attributes
      for dim in self._dims:
          # "If this attribute is absent, a value of regular__ should be assumed."
          spacing = getattr(dim, "spacing", b"regular__")
          if spacing == b"irregular":
              raise ValueError("Irregular spacing not supported")
          elif spacing != b"regular__":
              warnings.warn(
                  f"Invalid spacing declaration: {spacing}; assuming regular"
              )
  
      self._spatial_dims = [
          name for name in self._dim_names if name.endswith("space")
      ]
      self._image_max = image["image-max"]
      self._image_min = image["image-min"]
  
imports: import warnings
  import numpy
  from .minc1 import Minc1File, Minc1Image, MincError, MincHeader
label_desc: Use image node_id 1 to create a new Minc2File object from inherited base classes: Minc1File with example: obj = Minc2File(mincfile)