conmatrix.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:SyConn 作者: StructuralNeurobiologyLab 项目源码 文件源码
def plot_wiring_cs(wiring, den_borders, ax_borders, confidence_lvl,
                binary, wd, add_fname='_CS'):
    """Same as plot_wiring, but using all contact sites
    """
    fig = plt.figure()
    ax = plt.gca()
    max_val = np.max(wiring)
    for k, b in enumerate(den_borders):
        b += k * 1
        wiring = np.concatenate((wiring[:b, :], np.ones((1, wiring.shape[1], 1)),
                                 wiring[b:, :]), axis=0)
    for k, b in enumerate(ax_borders):
        b += k * 1
        wiring = np.concatenate((wiring[:, :b], np.ones((wiring.shape[0], 1, 1)),
                                 wiring[:, b:]), axis=1)
    ax.matshow(np.max(wiring.transpose(1, 0, 2), axis=2), interpolation="none",
                   extent=[0, wiring.shape[0], wiring.shape[1], 0], cmap='gray')
    ax.set_xlabel('Post', fontsize=18)
    ax.set_ylabel('Pre', fontsize=18)
    ax.set_xlim(0, wiring.shape[0])
    ax.set_ylim(0, wiring.shape[1])
    plt.grid(False)
    plt.axis('off')
    divider = make_axes_locatable(ax)
    cax = divider.append_axes("right", size="5%", pad=0.1)
    a = np.array([[0, 1]])
    plt.figure()
    plt.imshow(a, cmap='gray')
    plt.gca().set_visible(False)
    cb = plt.colorbar(cax=cax, ticks=[0, 1])
    if not binary:
        cb.ax.set_yticklabels(['0', "%0.3g+" % max_val], rotation=90)
        cb.set_label(u'Area of Synaptic Junctions [µm$^2$]')
    else:
        cb.ax.set_yticklabels(['0', '1'], rotation=90)
        cb.set_label(u'Synaptic Junction')
    plt.close()
    if not binary:
        fig.savefig(wd + '/figures/type_wiring%s_conf'
                    'lvl%d.png' % (add_fname, int(confidence_lvl*10)), dpi=600)
    else:
        fig.savefig(wd + '/figures/type_wiring%s_conf'
            'lvl%d_binary.png' % (add_fname, int(confidence_lvl*10)), dpi=600)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号