def sanitize_labels(labels, number):
    """Sanitizes the labels for the channels of data sets such as signals, spectrums
    or filters:

    * the returned labels are stored in a tuple
    * the length of the tuple will be the same as the given number
    * for missing labels, empty strings are added
    * surplus labels are cropped

    :param labels: a possibly incomplete sequence of string labels or None to
                   generate a tuple of empty strings
    :param number: the desired length of the returned tuple, which should e.g.
                   be the number of channels of the signal or spectrum
    :returns: a tuple of string labels
    """
    if labels is None:
        return ('',) * number
    elif len(labels) < number:
        return tuple(labels) + ('',) * (number - len(labels))
    elif len(labels) > number:
        return tuple(labels[0:number])
    else:
        return tuple(labels)
