def cueDiffTest(numLocations, trialMeans, cue1locTrials, cue2locTrials, choices): ########################################################## # 3d F-stat plots ########################################################## # trialMeans = trialMeansDelayOnly # cue1Fs = [list([]) for _ in range(len(trialMeans[0]))] # cue2Fs = [list([]) for _ in range(len(trialMeans[0]))] # cueDiffFs = [list([]) for _ in range(len(trialMeans[0]))] cue1Fs = [] cue2Fs = [] cueDiffFs = [] # This tracks the "pvalue class" of each point. Basically, how significant # were the f-statistics to change the markers to match significance pvalClass = [] # Particularly signficant neurons that may be good to look at sigNeurons = [] #################################################################### # Compile 3 groups: # cue1Fs : F-stat of 1xNumlocs anova for each neuron's mean firing rate for each # trial in which location 'x' appears at cue 1 # cue2Fs : F-stat of 1xNumlocs anova for each neuron's mean firing rate for each # trial in which location 'x' appears at cue 2 # cueDiffFs : F-stat of 1x2 anova for each neurons' mean firing rate for 2 # groups, split between cue 1 and cue 2 #################################################################### for neuron in range(len(trialMeans[0])): locs = [] for loc in range(numLocations): locN = [] for trial in cue1locTrials[loc]: locN.append(trialMeans[trial][neuron]) locs.append(locN) ans1 = f_oneway(*locs) locs = [] for loc in range(numLocations): locN = [] for trial in cue2locTrials[loc]: locN.append(trialMeans[trial][neuron]) locs.append(locN) ans2 = f_oneway(*locs) choice1 = [] choice2 = [] for trial in choices[0]: choice1.append(trialMeans[trial][neuron]) for trial in choices[1]: choice2.append(trialMeans[trial][neuron]) ans3 = f_oneway(choice1, choice2) # includes pvalue cutoffs # if ans1.pvalue < pval and ans2.pvalue < pval and ans3.pvalue < pval: # cue1Fs.append(ans1.statistic) # cue2Fs.append(ans2.statistic) # cueDiffFs.append(ans3.statistic) # without pvalue cutoffs cue1Fs.append(ans1.statistic) cue2Fs.append(ans2.statistic) cueDiffFs.append(ans3.statistic) # assorted point markets by pval if ans1.pvalue < 0.001 and ans2.pvalue < 0.001 and ans3.pvalue < 0.001: pvalClass.append(1) sigNeurons.append(neuron) elif ans1.pvalue < 0.01 and ans2.pvalue < 0.01 and ans3.pvalue < 0.01: pvalClass.append(2) sigNeurons.append(neuron) elif ans1.pvalue < 0.05 and ans2.pvalue < 0.05 and ans3.pvalue < 0.05: pvalClass.append(3) else: pvalClass.append(4) ################### z-score the fstats ################## cue1Fs.remove(max(cue1Fs)) cue1Fs.remove(min(cue1Fs)) # cue1Fs.remove(max(cue1Fs)) # cue1Fs.remove(min(cue1Fs)) cue2Fs.remove(max(cue2Fs)) cue2Fs.remove(min(cue2Fs)) # cue2Fs.remove(max(cue2Fs)) # cue2Fs.remove(min(cue2Fs)) cueDiffFs.remove(max(cueDiffFs)) cueDiffFs.remove(min(cueDiffFs)) # cueDiffFs.remove(max(cueDiffFs)) # cueDiffFs.remove(min(cueDiffFs)) cue1Fs = util.zscore(cue1Fs) cue2Fs = util.zscore(cue2Fs) cueDiffFs = util.zscore(cueDiffFs) plot3dAnova(cue1Fs, cue2Fs, cueDiffFs, 'Cue 1 F-Stat', 'Cue 2 F-Stat', 'Cue Pref F-Stat', pvalClass)
def conjugateTest(numLocations, trialMeans, locTrials, conjTrials): ########################################################## # 2d F-stat plots ########################################################## # featFs = [list([]) for _ in range(len(trialMeans[0]))] # conjFs = [list([]) for _ in range(len(trialMeans[0]))] featFs = [] conjFs = [] # This tracks the "pvalue class" of each point. Basically, how significant # were the f-statistics to change the markers to match significance pvalClass = [] # Particularly signficant neurons that may be good to look at sigNeurons = [] #################################################################### # Compile 2 groups: # featFs : F-stat of 1xNumlocs anova for each neuron's mean firing rate for each # trial in which location 'x' appears at all # conjFs : F-stat of 1x (NumlocsxNumlocs) anova for each neuron's mean firing # rate for each trial in which conjunction 'loc1' & 'loc2' appears #################################################################### for neuron in range(len(trialMeans[0])): locs = [] for loc in range(numLocations): means = [] for trial in locTrials[loc]: means.append(trialMeans[trial][neuron]) locs.append(means) ans1 = f_oneway(*locs) conj = [] for trials in conjTrials: means = [] for trial in trials: means.append(trialMeans[trial][neuron]) conj.append(means) ans2 = f_oneway(*conj) # # includes pvalue cutoffs # if ans1.pvalue < pval and ans2.pvalue < pval: # featFs.append(ans1.statistic) # conjFs.append(ans2.statistic) # without pvalue cutoffs featFs.append(ans1.statistic) conjFs.append(ans2.statistic) # assorted point markets by pval if ans1.pvalue < 0.001 and ans2.pvalue < 0.001: pvalClass.append(1) sigNeurons.append(neuron) elif ans1.pvalue < 0.01 and ans2.pvalue < 0.01: pvalClass.append(2) sigNeurons.append(neuron) elif ans1.pvalue < 0.05 and ans2.pvalue < 0.05: pvalClass.append(3) else: pvalClass.append(4) ################### z-score the fstats ################## # featFs.remove(max(featFs)) # featFs.remove(min(featFs)) # cue1Fs.remove(max(cue1Fs)) # cue1Fs.remove(min(cue1Fs)) # conjFs.remove(max(conjFs)) # conjFs.remove(min(conjFs)) # cue2Fs.remove(max(cue2Fs)) # cue2Fs.remove(min(cue2Fs)) featFs = util.zscore(featFs) # featFs = [featFs[i] for i in sigNeurons] conjFs = util.zscore(conjFs) # conjFs = [conjFs[i] for i in sigNeurons] plot2dAnova(featFs, conjFs, 'Feature Selectivity', 'Conjunctive Selectivity', pvalClass)