コード例 #1
0
                
            else:
                for j, gv.trial in enumerate(gv.trials): 
                    X_S1 = X_epochs[j,0,:,:,i] 
                    X_S2 = X_epochs[j,1,:,:,i] 
                    X_S1_S2 = np.vstack([X_S1, X_S2])                    
                    coefs_boot.append(fct.bootstrap_clf_epoch(X_S1_S2, y_trials, clf, shuffle=0))
                        
        coefs_boot = np.array(coefs_boot) 
        print('coefs', coefs_boot.shape)        
        break
    
        alpha_samples = [] 
        cos_alp_samples = [] 
        for sample in range(coefs_boot.shape[0]):
            alpha, cos_alp = fct.get_cos(coefs_boot[sample]) 

            alpha_samples.append(alpha)
            cos_alp_samples.append(cos_alp)

        alpha_samples = np.asarray(alpha_samples)
        cos_alp_samples = np.asarray(cos_alp_samples)

        print('samples', cos_alp_samples.shape)                
        mean_cos_samples = np.mean(cos_alp_samples,axis=0) 
        
        q1 = mean_cos_samples - np.percentile(cos_alp_samples, 25, axis=0) 
        q3 = np.percentile(cos_alp_samples, 75, axis=0) - mean_cos_samples
        y_err = np.asarray([q1[1:],q3[1:]]) 
                
        print('trial', gv.trial, 'cos_alp', mean_cos_samples, 'q1', q1, 'q3', q3) 
コード例 #2
0
    print('X', X_trials.shape)

    
    dC = []
    for i in range(X_trials.shape[2]):
        X = StandardScaler().fit_transform(X_trials[:,:,i])
        kmeans = KMeans(n_clusters=2, n_init=100).fit(X)
        cluster_center = kmeans.cluster_centers_
        # print(cluster_center.shape)
        
        dC.append(cluster_center[0]-cluster_center[1])

    dC = np.asarray(dC)
    # print(dC.shape)
    
    alpha, cos_alp = fct.get_cos(dC) 
    print('trial', gv.trial, 'cos_alp', cos_alp) 

# idx = np.where(X_trials<0)
# X = np.delete(X_trials, idx, axis=1)

# print('# trials, neurons, time')
# print('X', X.shape,'y', y_trials.shape)


# # for epoch in range(0, len(gv.epochs)):
# #     dum = X[:,:,epoch]
# #     X.append(StandardScaler().fit_transform(dum))

# # X = np.asarray(X)
# # X = np.rollaxis(X,2,1).transpose()
コード例 #3
0
 X_trials, y_trials = data.get_X_y_epochs(X_S1_trials, X_S2_trials) 
 print('X', X_trials.shape,'y', y_trials.shape)
 
 if IF_GRID :
     coefs, clf = fct.grid_search_cv_clf(X_trials, y_trials, shuffle=0, cv=10)
 else :
     X_detrend = []
     for n_trial in range(0,X_trials.shape[0]): 
         fit_values = fct.detrend_data(X_trials[n_trial], poly_fit=1, degree=10) 
         X_detrend.append(fit_values) 
         
     X_detrend = np.asarray(X_detrend) 
     coefs = fct.coefs_clf(X_trials-X_detrend, y_trials, clf=clf) 
 print('coefs', coefs.shape)
 
 alpha, cos_alp = fct.get_cos(coefs) 
 print('trial', gv.trial, 'cos_alp', cos_alp) 
 
 alpha_trials.append(alpha) 
 cos_alp_trials.append(cos_alp)
 
 if IF_SHUFFLE: 
     mat_cos = [] 
     
     for i in range(1000): 
         coefs_shuffle = fct.coefs_clf(X_trials, y_trials, clf=clf, shuffle=1) 
         alpha_shuffle, cos_alp_shuffle = fct.get_cos(coefs_shuffle) 
         
         mat_cos.append(cos_alp_shuffle) 
         
     mat_cos = np.asarray(mat_cos)