示例#1
0
文件: __init__.py 项目: rgerkin/upsit
def plot_cumul_hist(data, booklet=None):
    """
    Plots cumulative histogram for PPMI data.
    data: output of load()
    booklet: optionally restrict to one of four booklets (1-4).  
    """

    if booklet:
        smell = [value['upsit'][booklet - 1] for key, value in data.items()]
    else:
        smell = [sum(value['upsit']) for key, value in data.items()]
    recruitment = [value['recruitment'] for key, value in data.items()]

    smell_ctl = [
        smell[i] for i in range(len(recruitment)) if recruitment[i] == 0
    ]
    smell_ctl = sorted(smell_ctl)

    smell_pd = [
        smell[i] for i in range(len(recruitment)) if recruitment[i] == 1
    ]
    smell_pd = sorted(smell_pd)

    cumul_hist(smell_ctl, color='k')
    cumul_hist(smell_pd, color='r')

    plt.xlabel('UPSIT score')
    plt.ylabel('Cumulative Probability')
示例#2
0
文件: __init__.py 项目: rgerkin/upsit
def plot_cumul_hist(data,booklet=None):
    """
    Plots cumulative histogram for PPMI data.
    data: output of load()
    booklet: optionally restrict to one of four booklets (1-4).  
    """
    
    if booklet:
        smell = [value['upsit'][booklet-1] for key,value in data.items()]
    else:
        smell = [sum(value['upsit']) for key,value in data.items()]
    recruitment = [value['recruitment'] for key,value in data.items()]
    
    smell_ctl = [smell[i] for i in range(len(recruitment)) if recruitment[i]==0]
    smell_ctl = sorted(smell_ctl)
    
    smell_pd = [smell[i] for i in range(len(recruitment)) if recruitment[i]==1]
    smell_pd = sorted(smell_pd)

    cumul_hist(smell_ctl,color='k')
    cumul_hist(smell_pd,color='r')

    plt.xlabel('UPSIT score')
    plt.ylabel('Cumulative Probability')
示例#3
0
文件: __main__.py 项目: rgerkin/upsit
            pd_p = np.random.binomial(23,pd_p0) / 23.0
            diff[q-1] =  ctrl_p - pd_p

        shuffle_diff = np.zeros(40000)
        for q in range(1,40001):
            q_ctrl = ((q-1) % 40) + 1
            q_pd = np.random.randint(1,41)
            ctrl_p = proportion(q_ctrl,'ctrl')
            ctrl_x = np.log(ctrl_p/(1-ctrl_p))
            pd_x = ctrl_x - 1.4 + 0.7*np.random.randn()
            pd_p0 = np.exp(pd_x)/(1+np.exp(pd_x))
            pd_p = np.random.binomial(23,pd_p0) / 23.0
            shuffle_diff[q-1] = ctrl_p - pd_p
        
        upsit.plt.figure()
        upsit.cumul_hist(diff,color='r')
        upsit.cumul_hist(shuffle_diff,color='k')

        upsit.plt.show()

    if 0:
        for test in tests:
    	   if test.subject.label == 'ctrl':
    		  ctrl.append(test.score)
    	   if test.subject.label == 'pd':
    		  pd.append(test.score)
    
        #pprint(upsit_key)
        #pprint(bbdp_data)
        #upsit.cumul_hist(ctrl,color='k')
        #upsit.cumul_hist(pd,color='r')
示例#4
0
文件: __main__.py 项目: rgerkin/upsit
            pd_p = np.random.binomial(23, pd_p0) / 23.0
            diff[q - 1] = ctrl_p - pd_p

        shuffle_diff = np.zeros(40000)
        for q in range(1, 40001):
            q_ctrl = ((q - 1) % 40) + 1
            q_pd = np.random.randint(1, 41)
            ctrl_p = proportion(q_ctrl, 'ctrl')
            ctrl_x = np.log(ctrl_p / (1 - ctrl_p))
            pd_x = ctrl_x - 1.4 + 0.7 * np.random.randn()
            pd_p0 = np.exp(pd_x) / (1 + np.exp(pd_x))
            pd_p = np.random.binomial(23, pd_p0) / 23.0
            shuffle_diff[q - 1] = ctrl_p - pd_p

        upsit.plt.figure()
        upsit.cumul_hist(diff, color='r')
        upsit.cumul_hist(shuffle_diff, color='k')

        upsit.plt.show()

    if 0:
        for test in tests:
            if test.subject.label == 'ctrl':
                ctrl.append(test.score)
            if test.subject.label == 'pd':
                pd.append(test.score)

        #pprint(upsit_key)
        #pprint(bbdp_data)
        #upsit.cumul_hist(ctrl,color='k')
        #upsit.cumul_hist(pd,color='r')