def number_of_patients(dataset, feature_files, label_files):
    """
    Calculates number of unique patients in the list of given filenames.

    :param dataset: string. Dataset train/val/test.
    :param feature_files: list of strings. List of filenames with patient names containing features.
    :param label_files: list of strings. List of filenames with patient names containing labels.
    :return: int. Number of unique patients.
    """
    if len(feature_files) != len(label_files):
        raise AssertionError(dataset, 'files have different length.')
    print('Number of', dataset, 'files:', len(feature_files))

    patients = []
    for file in feature_files:
        patient = file[:4]
        if patient not in patients:
            patients.append(patient)
    print(dataset, 'patients:', patients)
    num_patients = len(patients)
    print('Num', dataset, 'patients:', num_patients)
    return num_patients