from collections import (
        OrderedDict,
)  # Need OrderedDict internally to ensure consistent ordering


def make_label_dictionary(inputColorLookUpTableFilename):
    """
    Construct dictionary:
        label No.: label name

    :param inputColorLookUpTableFilename:
    :return:
    """
    # inputColorLookUpTableFilename="/Shared/johnsonhj/HDNI/ReferenceData/20150709_HDAdultAtlas/BAWHDAdultAtlas_FreeSurferConventionColorLUT_20150709.txt"
    # import csv

    labelDictionary = OrderedDict()
    with open(inputColorLookUpTableFilename) as f:
        contents = f.readlines()
        for line in contents:
            currentline = line.split()
            # print(currentline)
            if len(currentline) > 0 and currentline[0].isdigit():
                # print( currentline )
                labelNo = int(currentline[0])
                labelName = currentline[1]
                labelDictionary[labelNo] = labelName
                # print(labelDictionary)
    return labelDictionary