Exemple #1
0
def _plotMTCombined(conf, data, subject='__'):
    mt, time, idS, id, p = data['all']
    time2 = numpy.linspace(time.min(),time.max(),30000)
    figname = os.path.join(grPath,subject+'_'+conf[0]+'-'+conf[1]+'_'+conf[2]+'_'+'_MTGraph_All'+grExt)
    figtitle = subject+' '+conf[0]+'-'+conf[1]+'  '+conf[2]+'Combined replications'
    fig = pylab.figure()
    
    host = HostAxes(fig, [0.15, 0.1, 0.65, 0.8])
    par1 = ParasiteAxes(host, sharex=host)
    host.parasites.append(par1)

    host.set_ylabel("MT (ms)")
    host.set_xlabel("Time (ms)")

    host.axis["right"].set_visible(False)
    par1.axis["right"].set_visible(True)
    par1.set_ylabel("ID")

    par1.axis["right"].major_ticklabels.set_visible(True)
    par1.axis["right"].label.set_visible(True)

    fig.add_axes(host)

    sigmoidArr = sigmoid(p,time2)
    t2 = time2[numpy.where(abs(sigmoidArr - (sigmoidArr.min() + sigmoidArr.max())/2) < eps2)[0]]
    #t50 = abs(t2-time2.max())
    t50 = t2
    if isinstance(t50, numpy.ndarray):
        t50 = t50.mean()

    #host.set_ylim(mt.min(),mt.max())
    if conf[0] == '4':
        host.set_ylim(200,900)
        host.set_xlim(0, 70000)
    else:
        host.set_ylim(200,1600)
        host.set_xlim(0, 90000)   
    host.scatter(time,mt,s=0.1,marker='x',linewidth=0.1,label="MT")
    host.plot(time2,sigmoid(p,time2),'-r',linewidth=1.5,label="Fitted MT")
    par1.scatter(time, id, s=1, c='r',label="ID", linewidth=0.5) 
    msg = "MT50 = %f" % t50
    host.text(  0.3 , 0.95, msg, fontsize = 8,\
                horizontalalignment='left', verticalalignment='center',\
                transform = host.transAxes)
    host.vlines(t50,mt.min(),mt.max())
    #host.set_ylim(mt.min(),mt.max())
    if conf[0] == '4':
        host.set_ylim(200,900)
        host.set_xlim(0, 70000)
    else:
        host.set_ylim(200,1600)
        host.set_xlim(0, 90000)
    
    par1.set_ylim(min(int(conf[0]),int(conf[1])),max(int(conf[0]),int(conf[1])))
    #host.legend()
    host.set_title(figtitle)
    fig.savefig(figname)
    pylab.close()