Esempio n. 1
0
        X = np.array(X)
        y = np.array(y)
        X = X.astype(float)
        y = y.astype(float)

        nTRs = len(y)

        corrC = np.corrcoef(ALL.T)
        corrC = np.abs(
            corrC)  # DO ABS here because negative correlatoion is fine!
        thr = tm.bc_alpha(corrC, alpha=0.05)
        #corrC[corrC < thr] = 0
        signif = []
        for i, e in enumerate(corrC[-1]):
            if tm.RtoP(e, nTRs) < thr:
                signif.append(i)
        signif = signif[:-1]
        X = X.T[signif]
        X = X.T

        # CHANGE THIS TO SK LEARN!
        #OLS STUFF
        #X = sm.add_constant(X)
        #rez = sm.OLS(y, X).fit()
        #B = rez.params

        import sklearn.linear_model
        reg = sklearn.linear_model.Lasso(alpha=0.1)
        reg.fit(X, y)
			fCount = np.zeros(30)
			for l in inFile:
				ALL.append(l)

			ALL = np.array(ALL)
			nTRs = len(ALL)
			ALL = ALL.astype(float)
			corrC = np.corrcoef(ALL.T)
			corrC = np.abs(corrC)					# DO ABS here because negative correlatoion is fine!
			#thr = 0.05			
			thr = tm.bc_alpha(corrC, alpha=0.05)
			#thr = tm.FDR_thresh_corrmat(corrC, nTRs, alpha=0.05)
			#print thr
			#corrC[tm.RtoP(corrC,nTRs) < thr] = 0
			DATA = corrC[:, -1]
			DATA = [tm.RtoP(x, nTRs) for x in DATA]
			#print DATA
			#DATA[DATA > thr] = 100
			#print DATA


			for i in range(len(DATA)):
				if DATA[i] < thr:
					if i == (int(lasts[lastsCount]) - 1):
						fCount[29] += 1
					elif i == 29:
						fCount[int(lasts[lastsCount]) - 1] += 1
					else:
						fCount[i] += 1
			fCount[int(lasts[lastsCount]) - 1] = 1