def sum_contrast(value, target, reference):
    """Convenience function for creating sum-coded contrasts.

    :param value: value to convert into 1, 0, or -1
    :param target: target (will be recoded to 1)
    :param reference: reference (will be recoded to -1)
    :return: recoded value
    """
    if value == target:
        return 1
    elif value == reference:
        return -1
    else:
        return 0