xn = np.arange(-10,10,0.01) twocol = Paired_12.mpl_colors plt.figure(figsize=(7,5)) plt.hist(ps,lw=0,facecolor=twocol[0],normed=True,bins=np.arange(-2,10,0.3),label="observed distribution") plt.xlim([-2,10]) plt.ylim([0,0.5]) plt.plot(xn,stats.norm.pdf(xn),color=twocol[1],lw=3,label="null distribution") plt.show() peaks = cluster.cluster(spm) peaks['pval'] = peakdistribution.peakp(peaks.peak.tolist()) bum = BUM.bumOptim(peaks["pval"].tolist(),starts=10) modelfit = neuropower.TFpeakfit(peaks['peak'].tolist(),bum['pi1']) xn = np.arange(-10,10,0.01) twocol = Paired_12.mpl_colors plt.figure(figsize=(7,5)) plt.hist(peaks['peak'].tolist(),lw=0,facecolor=twocol[0],normed=True,bins=np.arange(-2,10,0.3),label="observed distribution") plt.xlim([-2,10]) plt.ylim([0,0.5]) plt.plot(xn,[(1-bum["pi1"])*peakdistribution.peakdens3D(p,1) for p in xn],color=twocol[3],lw=3,label="null distribution") plt.plot(xn,[bum["pi1"]*peakdistribution.peakdens3D(p-modelfit['delta'],1) for p in xn],color=twocol[5],lw=3,label="alternative distribution") plt.plot(xn,neuropower.mixprobdens(modelfit["delta"],bum["pi1"],xn),color=twocol[1],lw=3,label="fitted distribution") plt.title("histogram") plt.xlabel("peak height") plt.ylabel("density") plt.legend(loc="upper right",frameon=False) plt.show()
newsubs = range(10,71) for s in newsubs: projected_effect = effect_cohen*np.sqrt(s) powerpred = {k:1-neuropower.altCDF(v,projected_effect,modelfit['sigma'],exc=exc,method="RFT") for k,v in thresholds.items() if v!='nan'} power_predicted.append(powerpred) power_predicted_df = pd.DataFrame(power_predicted) # figure modelfit twocol = Paired_12.mpl_colors xn = np.arange(-10,10,0.01) nul = [1-bum['pi1']]*neuropower.nulPDF(xn,exc=exc,method="RFT") alt = bum['pi1']*neuropower.altPDF(xn,mu=modelfit['mu'],sigma=modelfit['sigma'],exc=exc,method="RFT") mix = neuropower.mixprobdens(xn,pi1=bum['pi1'],mu=modelfit['mu'],sigma=modelfit['sigma'],exc=2,method="RFT") xn_p = np.arange(0,1,0.01) alt_p = [1-bum['pi1']]*scipy.stats.beta.pdf(xn_p, bum['a'], 1)+1-bum['pi1'] null_p = [1-bum['pi1']]*len(xn_p) mpl.rcParams['font.size']='11.0' fig,axs=plt.subplots(1,2,figsize=(14,5)) fig.subplots_adjust(hspace=.5,wspace=0.3) axs=axs.ravel() axs[0].hist(peaks.pval,lw=0,normed=True,facecolor=twocol[0],bins=np.arange(0,1.1,0.1),label="observed distribution") axs[0].set_ylim([0,3]) axs[0].plot(xn_p,null_p,color=twocol[3],lw=2,label="null distribution") axs[0].plot(xn_p,alt_p,color=twocol[5],lw=2,label="alternative distribution") axs[0].legend(loc="upper right",frameon=False)