예제 #1
0
파일: plot.py 프로젝트: vsukhor/TMD
def persistence_image(ph,
                      new_fig=True,
                      subplot=111,
                      xlims=None,
                      ylims=None,
                      masked=False,
                      colorbar=False,
                      norm_factor=None,
                      threshold=0.01,
                      vmin=None,
                      vmax=None,
                      cmap=jet_map,
                      bw_method=None,
                      **kwargs):
    '''Plots the gaussian kernel
       of the ph diagram that is given.
    '''
    if xlims is None or xlims is None:
        xlims, ylims = analysis.get_limits(ph, coll=False)

    # pylint: disable=unexpected-keyword-arg
    Zn = analysis.get_persistence_image_data(ph,
                                             norm_factor=norm_factor,
                                             bw_method=bw_method,
                                             xlims=xlims,
                                             ylims=ylims)
    fig, ax = cm.get_figure(new_fig=new_fig, subplot=subplot)

    if masked:
        Zn = np.ma.masked_where((threshold > Zn), Zn)

    cax = ax.imshow(np.rot90(Zn),
                    vmin=vmin,
                    vmax=vmax,
                    cmap=cmap,
                    interpolation='bilinear',
                    extent=xlims + ylims)

    if colorbar:
        plt.colorbar(cax)

    kwargs['xlim'] = xlims
    kwargs['ylim'] = ylims
    kwargs['title'] = kwargs.get('title', 'Persistence image')
    kwargs['xlabel'] = kwargs.get('xlabel', 'End radial distance from soma')
    kwargs['ylabel'] = kwargs.get('ylabel', 'Start radial distance from soma')

    return Zn, cm.plot_style(fig=fig, ax=ax, **kwargs)
예제 #2
0
파일: plot.py 프로젝트: vsukhor/TMD
def persistence_image_average(ph_list,
                              new_fig=True,
                              subplot=111,
                              xlims=None,
                              ylims=None,
                              norm_factor=1.0,
                              vmin=None,
                              vmax=None,
                              cmap=jet_map,
                              weighted=False,
                              **kwargs):
    """Merges a list of ph diagrams and plots their respective average image.
    """
    # pylint: disable=unexpected-keyword-arg
    av_imgs = analysis.get_average_persistence_image(ph_list,
                                                     xlims=xlims,
                                                     ylims=ylims,
                                                     norm_factor=norm_factor,
                                                     weighted=weighted)
    if xlims is None or xlims is None:
        xlims, ylims = analysis.get_limits(ph_list)

    if vmin is None:
        vmin = np.min(av_imgs)
    if vmax is None:
        vmax = np.max(av_imgs)

    fig, ax = cm.get_figure(new_fig=new_fig, subplot=subplot)
    ax.imshow(np.rot90(av_imgs),
              vmin=vmin,
              vmax=vmax,
              cmap=cmap,
              interpolation='bilinear',
              extent=xlims + ylims)

    kwargs['xlim'] = xlims
    kwargs['ylim'] = ylims
    kwargs['title'] = kwargs.get('title', 'Average persistence image')
    kwargs['xlabel'] = kwargs.get('xlabel', 'End radial distance from soma')
    kwargs['ylabel'] = kwargs.get('ylabel', 'Start radial distance from soma')

    return av_imgs, cm.plot_style(fig=fig, ax=ax, **kwargs)