コード例 #1
0
    #plt.xlim([0,min((W>0).sum(axis=0).max(),pij.sum(axis=0).max())])
    #plt.ylim([0,min((W>0).sum(axis=0).max(),pij.sum(axis=0).max())])

    plt.subplot(2,3,5)
    plt.plot(W.sum(axis=0),wij.sum(axis=0), 'b.')
    plt.plot(np.linspace(0,wij.sum(axis=0).max()),np.linspace(0,wij.sum(axis=0).max()),'r-')
    plt.title('$ s_i - <s_i>$')
    plt.axis('equal')
    #plt.xlim([0,wij.sum(axis=0).max()])
    #plt.ylim([0,wij.sum(axis=0).max()])
    plt.grid(True)
    plt.ylabel('model')
    plt.xlabel('empirical')

    plt.tight_layout()
    plt.show()

if __name__=='__main__':

    thresh = 0.2 # threshold
    T = 200 # number of time points to sample
    eta = 3.0 # localnoise
    mu = 1.0 # globalnoise
    C = np.arctanh(factor_model([1]*40 + [2]*40 + [3]*30, T, eta, mu, True))
    At = bct.threshold_absolute(C, thresh)
    n=len(At)
    k = (At>0).sum(axis=0)
    s = At.sum(axis=0)

    x,y = inference_cEWRGt(At, thresh)
    plot_results(At, x, y, thresh)
コード例 #2
0
  print '   e.g. average_lh_inflated  0.0'
  sys.exit()

root_fname = sys.argv[1]
#nw_fname = sys.argv[2]
nw_fname = "1X4I9DF0_adjacency_matrix_pcc.txt"
threshold = float(sys.argv[2])
print 'threshold=',threshold

adjMtx = np.genfromtxt(nw_fname, delimiter='\t')

"""Rubinov,Sporns 2010:  all self-connections or negative connections
(such as functional anticorrelations) must currently be removed
from the networks prior to analysis"""

bct.threshold_absolute(adjMtx,threshold)

# NB! be sure to put before masking the matrix
[Ci,Q]=bct.modularity_und(adjMtx)

roi_legend = 'roi_legend.txt'
try:
  fp_roi =open(roi_legend, 'r')
except:
  print("Error opening " + roi_legend)

# Create a dictionary mapping ID --> RGB
vc = {}  # vertex color dictionary
count = 0
# colors (rgb) for modules (Q: what's the max # of modules we'll have??)
# rf. http://www.rapidtables.com/web/color/RGB_Color.htm
コード例 #3
0
ファイル: basic_tests.py プロジェクト: Bigxiaofeng/bctpy
def test_threshold_absolute():
    x = load_sample()
    x = bct.threshold_absolute(x, 2.1)
    assert np.allclose(np.sum(x), 13280.17768104)
コード例 #4
0
ファイル: modules.py プロジェクト: rheiland/biovis2014
#mc=[['255 0 0'],['0 255 0'],['0 0 255'],['255 255 0'],['0 255 255']]

threshVal=0.3
threshVal=0.0
threshVal=input("Enter threshold: ")

#testDir = '/Users/heiland/Documents/Heiland/BioVis14/contest_subject_networks/'
#fname = 'U050E1IO_adjacency_matrix_pcc.txt'
fname = '1X4I9DF0_adjacency_matrix_pcc.txt'
#d = np.genfromtxt(testDir + fname, delimiter='\t')
try:
  A = np.genfromtxt(fname, delimiter='\t')
except:
  print "Error opening " + fname

bct.threshold_absolute(A,threshVal)

# Calculate the network's modularity
[Ci,Q]=bct.modularity_und(A)

print Ci
for i in range(len(Ci)):
  for j in range(i+1,len(Ci)):
#    print i,j
    if Ci[i] > Ci[j]:
      temp = Ci[i]
      Ci[i] = Ci[j]
      Ci[j] = temp
      print str(i) + ' <-> ' + str(j)
      A[[i,j]] = A[[j,i]]  # swap rows
      A[:,[i,j]] = A[:,[j,i]]  # swap cols