class_docstr: Class for MINC2 images
  
  The MINC2 image class uses the default header type, rather than a
  specific MINC header type - and reads the relevant information from
  the MINC file on load.
class_docstr_tok: ["Class","for","MINC2","images","The","MINC2","image","class","uses","the","default","header","type",",","rather","than","a","specific","MINC","header","type","-","and","reads","the","relevant","information","from","the","MINC","file","on","load","."]
code: def from_file_map(klass, file_map, *, mmap=True, keep_file_open=None):
      # Import of h5py might take awhile for MPI-enabled builds
      # So we are importing it here "on demand"
      import h5py  # type: ignore[import-not-found]
  
      holder = file_map["image"]
      if holder.filename is None:
          raise MincError("MINC2 needs filename for load")
      minc_file = Minc2File(h5py.File(holder.filename, "r"))
      affine = minc_file.get_affine()
      if affine.shape != (4, 4):
          raise MincError("Image does not have 3 spatial dimensions")
      data_dtype = minc_file.get_data_dtype()
      shape = minc_file.get_data_shape()
      zooms = minc_file.get_zooms()
      header = klass.header_class(data_dtype, shape, zooms)
      data = klass.ImageArrayProxy(minc_file)
      return klass(data, affine, header, extra=None, file_map=file_map)
  
imports: import warnings
  import numpy
  from .minc1 import Minc1File, Minc1Image, MincError, MincHeader
label_desc: Use image node_id 1 for calling the Minc2Image obj's underlying member method code with example usage: obj.from_file_map(klass, file_map) and returns: klass