def addPairwiseIndicatorFeatures(allClinDict):

    magicStrings = ["patient", "person", "vital", "surviv", "race", "ethnic",
                    "prior", "gender", "age_at", "ageat", "radiation", "chemo",
                    "therapy", "treat", "performance", "days_to_", "daysto",
                    "year_of", "yearof", "surgical", "recurrence", "pregnancies"]

    print " "
    print " "

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

    for aKey in keyList:

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

        if (keyType == "NOMINAL"):

            # we do this only for categorical features with 3-9 categories
            if (nCard > 2 and nCard < 10):

                print " "
                print " in addPairwiseIndicatorFeatures ... ", aKey, keyType, nCard, labelList, labelCount

                for ak in range(len(labelList)):
                    aLabel = labelList[ak]

                    for bk in range(ak + 1, len(labelList)):
                        bLabel = labelList[bk]

                        print " aLabel=<%s>  bLabel=<%s> " % (aLabel, bLabel)

                        try:
                            if (aKey[1] == ":" and aKey[6] == ":"):
                                i1 = aKey[7:].find(':')
                                if (i1 < 0):
                                    i1 = len(aKey)
                                    i2 = len(aKey)
                                else:
                                    i1 = i1 + 7
                                    i2 = aKey[(i1 + 1):].find(':')
                                    if (i2 < 0):
                                        i2 = len(aKey)

                                if (i2 > 0 and i2 < len(aKey)):
                                    newLabel = "B:" + \
                                        aKey[
                                            2:7] + "I(" + aLabel + "," + bLabel + "|" + aKey[7:i1] + ")" + aKey[i2:]
                                else:
                                    newLabel = "B:" + \
                                        aKey[
                                            2:7] + "I(" + aLabel + "," + bLabel + "|" + aKey[7:i1] + ")" + "::::"

                            else:
                                # here we really need to have some way to guess whether this
                                # should be a CLIN or a SAMP feature ...
                                typeString = "UNK"
                                for aString in magicStrings:
                                    if (aKey.find(aString) >= 0):
                                        typeString = "CLIN"
                                if (typeString == "UNK"):
                                    print " defaulting to type SAMP for this feature : <%s> " % (aKey)
                                    typeString = "SAMP"
                                newLabel = "B:" + typeString + ":" + \
                                    "I(" + aLabel + "," + bLabel + "|" + aKey + ")" + \
                                    "::::"

                        except:
                            print " NOT continuing in addPairwiseIndicatorFeatures !!! ", aLabel, bLabel, aKey
                            continue

                        # make sure there are no blanks ...
                        newLabel = tsvIO.replaceBlanks(newLabel, "_")
                        print "             --> new label: <%s> " % newLabel

                        if (newLabel in allClinDict.keys()):
                            print " this indicator variable already exists so I will not make a new one ... ", newLabel
                            continue

                        curV = allClinDict[aKey]
                        numClin = len(curV)
                        tmpV = ["NA"] * numClin
                        for kk in range(numClin):
                            if (allClinDict[aKey][kk].lower() == aLabel.lower()):
                                tmpV[kk] = 1
                            elif (allClinDict[aKey][kk].lower() == bLabel.lower()):
                                tmpV[kk] = 0

                        print " adding new feature : ", newLabel
                        # print tmpV
                        allClinDict[newLabel] = tmpV

    return (allClinDict)