def create_from_header(cls, header, ebins=None, pixels=None):
        """ Creates an HPX object from a FITS header.

        header : The FITS header
        ebins  : Energy bin edges [optional]
        """
        convname = HPX.identify_HPX_convention(header)
        conv = HPX_FITS_CONVENTIONS[convname]

        if conv.convname not in ['GALPROP', 'GALPROP2']:
            if header["PIXTYPE"] != "HEALPIX":
                raise Exception("PIXTYPE != HEALPIX")
        if header["PIXTYPE"] != "HEALPIX":
            raise Exception("PIXTYPE != HEALPIX")
        if header["ORDERING"] == "RING":
            nest = False
        elif header["ORDERING"] == "NESTED":
            nest = True
        else:
            raise Exception("ORDERING != RING | NESTED")

        try:
            order = header["ORDER"]
        except KeyError:
            order = -1

        if order < 0:
            nside = header["NSIDE"]
        else:
            nside = -1

        try:
            coordsys = header[conv.coordsys]
        except KeyError:
            coordsys = header['COORDSYS']

        try:
            region = header["HPX_REG"]
        except KeyError:
            try:
                region = header["HPXREGION"]
            except KeyError:
                region = None

        try:
            if header['INDXSCHM'] in ['EXPLICIT', 'PARTIAL']:
                use_pixels = pixels
            else:
                use_pixels = None
        except KeyError:
            use_pixels = None

        return cls(nside, nest, coordsys, order, ebins, region=region, conv=conv, pixels=use_pixels)