예제 #1
0
def DegreeNetAlgs(undirected=False, startdeg=10, enddeg=10):
    for i in range(startdeg, enddeg + 1):
        print i
        count = 0
        for key, value in data.iteritems():
            count += 1
            print count, i
            mats = value[1]

            corr = mats['corr']
            lcorr = mats['lcorr']
            lacorr = mats['lacorr']

            if undirected:
                corr += transpose(corr)
                lcorr += transpose(lcorr)
                lacorr += transpose(lacorr)

            corr = corr > findThresh(corr, i)
            lcorr = lcorr > findThresh(lcorr, i)
            lacorr = lacorr > findThresh(lacorr, i)

            corr = myallmeasures(nx.DiGraph(corr))
            lcorr = myallmeasures(nx.DiGraph(lcorr))
            lacorr = myallmeasures(nx.DiGraph(lacorr))
            for k in range(len(corr[0])):
                measure = corr[0][k]
                value[0][(measure, 'corr')] = corr[1][k]
                value[0][(measure, 'lcorr')] = lcorr[1][k]
                value[0][(measure, 'lacorr')] = lacorr[1][k]
        dump(convert('AD', i), open('totalD_AD_D' + str(i) + '.pkl', 'wb'))
        dump(convert('NL', i), open('totalD_NL_D' + str(i) + '.pkl', 'wb'))
        dump(convert('MCI', i), open('totalD_MCI_D' + str(i) + '.pkl', 'wb'))
        dump(convert('CONVERT', i),
             open('totalD_CONVERT_D' + str(i) + '.pkl', 'wb'))
예제 #2
0
def DegreeNetAlgs(undirected = False,startdeg = 10,enddeg = 10):
    for i in range(startdeg,enddeg+1):
        print i
        count = 0
        for key, value in data.iteritems():
            count += 1
            print count, i
            mats = value[1]

            corr = mats['corr']
            lcorr = mats['lcorr']
            lacorr = mats['lacorr']

            if undirected:
                corr += transpose(corr)
                lcorr += transpose(lcorr)
                lacorr += transpose(lacorr)
            
            corr = corr > findThresh(corr,i)
            lcorr = lcorr > findThresh(lcorr,i)
            lacorr = lacorr > findThresh(lacorr,i)
            
            corr = myallmeasures(nx.DiGraph(corr))
            lcorr = myallmeasures(nx.DiGraph(lcorr))
            lacorr = myallmeasures(nx.DiGraph(lacorr))
            for k in range(len(corr[0])):
                measure = corr[0][k]
                value[0][(measure,'corr')] = corr[1][k]
                value[0][(measure,'lcorr')] = lcorr[1][k]
                value[0][(measure,'lacorr')] = lacorr[1][k]
        dump(convert('AD',i),open('totalD_AD_D'+str(i)+'.pkl','wb'))
        dump(convert('NL',i),open('totalD_NL_D'+str(i)+'.pkl','wb'))
        dump(convert('MCI',i),open('totalD_MCI_D'+str(i)+'.pkl','wb'))
        dump(convert('CONVERT',i),open('totalD_CONVERT_D'+str(i)+'.pkl','wb'))
예제 #3
0
def RandomDegrees(undirected=False, startdeg=10, enddeg=10):
    for des in range(startdeg, enddeg + 1):
        print des
        count = 0
        anslist = []
        orderedans = []
        for nn in range(100):
            x = random.rand(88, 88)
            x -= diag(diag(x))
            if undirected:
                x = triu(x, 1)
                x += x.T
            x = x > findThresh(x, des)
            patientGraph = nx.DiGraph(x)
            m = myallmeasures(patientGraph)
            anslist.append(m[1])
            if nn % 10 == 0:
                print nn, des
        mnames = m[0]
        for j in range(len(mnames)):
            measure = [i[j] for i in anslist]
            measure = [i for i in measure if i != None]
            orderedans.append(measure)
        corr = zip(mnames, orderedans)
        g = lambda n: n[0]
        corr.sort(key=g)
        dump([mnames, orderedans],
             open("ufinal_rand_D" + str(des) + ".pkl", "wb"))
예제 #4
0
def RandomDegrees(undirected = False,startdeg = 10, enddeg = 10):
    for des in range(startdeg,enddeg + 1):
        print des
        count = 0
        anslist = []
        orderedans = []
        for nn in range(100):
            x = random.rand(88,88)
            x -= diag(diag(x))
            if undirected:
                x = triu(x,1)
                x += x.T
            x = x > findThresh(x, des)
            patientGraph = nx.DiGraph(x)
            m = myallmeasures(patientGraph)
            anslist.append(m[1])
            if nn % 10 == 0:
                print nn, des
        mnames = m[0]; 
        for j in range(len(mnames)):
            measure = [i[j] for i in anslist]
            measure = [i for i in measure if i != None]
            orderedans.append(measure)    
        corr = zip(mnames,orderedans)
        g = lambda n: n[0]
        corr.sort(key = g)
        dump([mnames,orderedans], open("ufinal_rand_D"+str(des)+".pkl","wb"))
예제 #5
0
def RunNetAlgs(dumpData=True):
    for key, value in data.iteritems():
        print key
        mats = value[1]
        corr = myallmeasures(nx.DiGraph(mats['tcorr']))
        lcorr = myallmeasures(nx.DiGraph(mats['tlcorr']))
        lacorr = myallmeasures(nx.DiGraph(mats['tlacorr']))
        for i in range(len(corr[0])):
            measure = corr[0][i]
            value[0][(measure, 'corr')] = corr[1][i]
            value[0][(measure, 'lcorr')] = lcorr[1][i]
            value[0][(measure, 'lacorr')] = lacorr[1][i]
    if dumpData:
        dump(data, open('computed_data', 'wb'))
        dump(convert('AD'), open('final_AD.pkl', 'wb'))
        dump(convert('NL'), open('final_NL.pkl', 'wb'))
        dump(convert('MCI'), open('final_MCI.pkl', 'wb'))
        dump(convert('CONVERT'), open('final_CONVERT.pkl', 'wb'))
예제 #6
0
def RunNetAlgs(dumpData = True):
    for key, value in data.iteritems():
        print key
        mats = value[1]
        corr = myallmeasures(nx.DiGraph(mats['tcorr']))
        lcorr = myallmeasures(nx.DiGraph(mats['tlcorr']))
        lacorr = myallmeasures(nx.DiGraph(mats['tlacorr']))
        for i in range(len(corr[0])):
            measure = corr[0][i]
            value[0][(measure,'corr')] = corr[1][i]
            value[0][(measure,'lcorr')] = lcorr[1][i]
            value[0][(measure,'lacorr')] = lacorr[1][i]
    if dumpData:
        dump(data,open('computed_data','wb'))
        dump(convert('AD'),open('final_AD.pkl','wb'))
        dump(convert('NL'),open('final_NL.pkl','wb'))
        dump(convert('MCI'),open('final_MCI.pkl','wb'))
        dump(convert('CONVERT'),open('final_CONVERT.pkl','wb'))