return neural_data[neurons_idx, :] if pca_comp_num is not None: pca = PCA(pca_comp_num) pca.fit(neural_data.T) return pca.transform(neural_data.T).T # set seed seed = np.random.seed(2020) # #IMPORT DATA dat = np.load('data/stringer_spontaneous.npy', allow_pickle=True).item() neural_data = dat['sresp'] run_data = dat['run'] run_onset, run_speed = movement.detect_movement_onset(run_data) # #%% LOGISTIC REGRESSION ON NEURAL DATA - train model # # SET PARAMETERS # C = np.logspace(-4, 0, 20) # det_window = 13 # neuron_num = 4000 # pca_com = 1 # %% CORR of PCA in windows # window_corr = np.zeros([(neural_data.shape[1]-(det_window+1)),1]) # window_corr = [] # for idx in range(det_window+1, len(neural_data[0,:])): # neural_data_window = neural_data[:,(idx-det_window):idx] # feat_w = extract_features(neural_data_window, pca_comp_num =pca_com)
def load_data(path='data/stringer_spontaneous.npy'): dat = np.load(path, allow_pickle=True).item() neural_data = dat['sresp'] run_data = dat['run'] run_onset, run_speed = movement.detect_movement_onset(run_data) return neural_data, run_onset, run_speed