def addNumericalFeatures(allClinDict):

    print " "
    print " "
    print " in addNumericalFeatures ... "

    keyList = allClinDict.keys()
    keyList.sort()

    # CAREFUL: add on things only at the end of this list ...
    prefixList = ["T", "N", "M", "STAGE", "GRADE", "G", "PT"]
    nPrefix = len(prefixList)
    prefixBits = [0] * nPrefix

    for aKey in keyList:
        if (aKey == "bcr_patient_barcode"):
            continue
        (keyType, nCount, nNA, nCard, labelList,
         labelCount) = miscClin.lookAtKey(allClinDict[aKey])

        if (keyType == "NOMINAL"):
            if (nCard > 2 and nCard < 15):

                tmpKey = aKey.lower()
                if (tmpKey.find("stage") >= 0 or tmpKey.find("grade") >= 0 or
                        tmpKey.find("pathologic_spread") >= 0):
                    print " considering this categorical feature ... ", aKey, keyType, nCard, labelList, labelCount

                    for iP in range(nPrefix):
                        aPrefix = prefixList[iP]
                        prefixBits[iP] = checkPrefix(labelList, aPrefix)

                    # if the 'GRADE' bit gets set, then unset the 'G' bit
                    if (prefixBits[4]):
                        prefixBits[5] = 0

                    # print prefixBits
                    usePrefix = ""
                    if (sum(prefixBits) == 1):
                        for iP in range(nPrefix):
                            if (prefixBits[iP]):
                                usePrefix = prefixList[iP]
                    elif (sum(prefixBits) > 1):
                        print " ERROR ??? how can it have multiple prefix bits ON ??? "
                        sys.exit(-1)

                    # print " usePrefix <%s> " % usePrefix

                    isRoman = checkRomanNumerals(labelList, usePrefix)
                    # print " isRoman = %d " % isRoman

                    if (aKey[1] == ":"):
                        tokenList = aKey.split(':')
                        newLabel = "N:" + \
                            tokenList[1] + ":" + tokenList[2] + "_derived"
                        for ii in range(3, len(tokenList)):
                            newLabel += ":" + tokenList[ii]
                    else:
                        newLabel = "N:CLIN:" + aKey + "_derived"
                    if (newLabel in allClinDict.keys()):
                        print " this feature label already exists ??? ", newLabel
                        sys.exit(-1)

                    curV = allClinDict[aKey]
                    numClin = len(curV)
                    tmpV = [0] * numClin

                    for kk in range(numClin):
                        if (curV[kk] == "NA"):
                            tmpV[kk] = "NA"
                        elif (isRoman):
                            tmpV[kk] = translateRoman(curV[kk], usePrefix)
                        else:
                            tmpV[kk] = translateArabic(curV[kk], usePrefix)

                        if (0):
                            if (tmpV[kk] == 0):
                                print " why is tmpV[kk] still ZERO ??? ", kk, numClin, curV[kk], usePrefix, tmpV[kk]

                    numNA = 0
                    notNA = 0
                    for kk in range(numClin):
                        if (tmpV[kk] == "NA"):
                            numNA += 1
                        else:
                            notNA += 1

                    if (numNA > 10 * notNA):
                        print " --> NOT adding this new feature <%s> " % newLabel, list(set(tmpV)), numNA, notNA, usePrefix, isRoman
                    else:
                        print " --> ADDING new feature !!! <%s> " % newLabel, list(set(tmpV)), numNA, notNA, usePrefix, isRoman
                        allClinDict[newLabel] = tmpV

                    print " "

    print " "
    print " "

    return (allClinDict)