@classmethod
def fromdata(cls, data, bps=2):
    """Encode data as payload, using a given number of bits per sample.

        It is assumed that the last dimension is the number of channels.
        """
    if data.dtype.kind == 'c':
        raise ValueError('Mark5B format does not support complex data.')
    encoder = cls._encoders[bps]
    words = encoder(data).view(cls._dtype_word)
    return cls(words, nchan=data.shape[-1], bps=bps)
