def remapCategoricalFeatures(allClinDict):

    print " "
    print " in remapCategoricalFeatures "

    keyList = allClinDict.keys()
    keyList.sort()
    for aKey in keyList:

        aKey2 = aKey.lower()
        if (aKey2 in remapDict.keys()):

            numRemap = 0

            print " "
            print " looking at <%s> " % aKey2
            tmpV = allClinDict[aKey]
            # print " part of original vector : ", tmpV[:10]

            newV = [0] * len(tmpV)
            for kk in range(len(tmpV)):
                bKey2 = tmpV[kk].lower()
                if (bKey2.startswith("stage_")):
                    bKey2 = bKey2[6:]
                if (bKey2.startswith("stage ")):
                    bKey2 = bKey2[6:]
                try:
                    newV[kk] = remapDict[aKey2][bKey2]
                    if (newV[kk] != "NA" and newV[kk] != "na"):
                        if (newV[kk].lower() != bKey2):
                            # print "     remapping ... ", aKey, aKey2, kk,
                            # bKey2, remapDict[aKey2][bKey2]
                            numRemap += 1
                except:
                    if (0):
                        print " WARNING in remapCategoricalFeatures ... nothing to remap to ??? "
                        print " <%s>  <%s>  %d  <%s> " % (aKey, aKey2, kk, bKey2)
                        print " <%s> " % remapDict[aKey2]
                        # sys.exit(-1)
                    newV[kk] = bKey2

            if (numRemap > 0):
                print " --> using remapped values for <%s> " % aKey
                print " mapping dictionary : ", remapDict[aKey2]
                print " part of original vector : ", tmpV[:10]
                print " part of new vector      : ", newV[:10]
                allClinDict[aKey] = newV

    return (allClinDict)