#%% print 'running PCA without rank' for kindex, key in enumerate(keyList): resultDict[key]['PCA'] = dr.runPCANormal(dataSets[key], pars) # overview of PCA results and weights mp.plotPCAresults(dataSets, resultDict, keyList, pars, flag='PCA') # correlate PCA with all sorts of stuff mp.plotPCAcorrelates(dataSets, resultDict, keyList, pars, flag='PCA') plt.show() # plot 3D trajectory of PCA # #mp.plotPCAresults3D(dataSets, resultDict, keyList, pars, col = 'phase') #plt.show() mp.plotPCAresults3D(dataSets, resultDict, keyList, pars, col='velocity') mp.plotPCAresults3D(dataSets, resultDict, keyList, pars, col='turns') #plt.show() # save the most prominent 3 neurons for each PCA axis pars['useRank'] = 1 print 'running PCA with rank' for kindex, key in enumerate(keyList): resultDict[key]['RankPCA'] = dr.runPCANormal(dataSets[key], pars) # overview of PCA results and weights mp.plotPCAresults(dataSets, resultDict, keyList, pars, flag='RankPCA') mp.plotPCAcorrelates(dataSets, resultDict, keyList, pars, flag='RankPCA') plt.show() # plot 3D trajectory of PCA
mp.averageResultsPCA(res, keys, labelsPCA, colorsPCA, fitmethod="PCA") plt.show() ############################################### # # use svm to predict discrete behaviors # ############################################## if svm: # overview of SVM results and weights mp.plotPCAresults(dataSets, resultDict, keyList, pars, flag='SVM') plt.show() # plot 3D trajectory of SVM mp.plotPCAresults3D(dataSets, resultDict, keyList, pars, col='etho', flag='SVM') plt.show() # mp.plotPCAresults3D(dataSets, resultDict, keyList, pars, col = 'time', flag = 'SVM') # plt.show() # mp.plotPCAresults3D(dataSets, resultDict, keyList, pars, col = 'velocity', flag = 'SVM') # plt.show() # mp.plotPCAresults3D(dataSets, resultDict, keyList, pars, col = 'turns', flag = 'SVM') # plt.show() ############################################### # # run PCA and store results # ##############################################
# run PCA and store results # ############################################## #%% if pca: print 'running PCA' for kindex, key in enumerate(keyList): resultDict[key]['PCA'] = dr.runPCANormal(dataSets[key], pars, whichPC=0) # overview of data ordered by PCA mp.plotDataOverview2(dataSets, keyList, resultDict) # overview of PCA results and weights mp.plotPCAresults(dataSets, resultDict, keyList, pars) plt.show() mp.plotPCAresults3D(dataSets, resultDict, keyList, pars, col='time') plt.show() # color by before and after colorBy = np.zeros(dataSets[key]['Neurons']['Activity'].shape[1]) colorBy[:int(dataSets[key]['Neurons']['Activity'].shape[1] / 2.)] = 1 mp.plotPCAresults3D(dataSets, resultDict, keyList, pars, col='Immobilization', colorBy=colorBy) plt.show() plt.show(block=True) resultDict['PCA'] = {} resultDict['PCA2'] = {}
testset=None) ############################################### # # use behavior triggered averaging to create non-othogonal axes # ############################################## if bta: for kindex, key in enumerate(keyList): print 'running BTA' resultDict[key]['BTA'] = dr.runBehaviorTriggeredAverage( dataSets[key], pars) mp.plotPCAresults(dataSets, resultDict, keyList, pars, flag='BTA') plt.show() mp.plotPCAresults3D(dataSets, resultDict, keyList, pars, col='etho', flag='BTA') plt.show() ############################################### # # use svm to predict discrete behaviors # ############################################## if svm: for kindex, key in enumerate(keyList): print 'running SVM' splits = resultDict[key]['Training'] resultDict[key]['SVM'] = dr.discreteBehaviorPrediction( dataSets[key], pars, splits)