예제 #1
0
파일: methods.py 프로젝트: Guan-Shuran/TMD
def extract_ph_neuron(neuron, feature='radial_distances', output_file=None,
                      neurite_type='all', sort=False, **kwargs):
    '''Extracts persistent homology from tree'''
    ph = get_ph_neuron(neuron, feature=feature, neurite_type='all', **kwargs)

    if sort:
        sort_ph(ph)
    else:
        p = ph

    if output_file is None:
        output_file = 'PH_' + neuron.name + '_' + neurite_type + '.txt'

    write_ph(p, output_file)
예제 #2
0
파일: methods.py 프로젝트: Guan-Shuran/TMD
def extract_ph(tree, feature='radial_distances', output_file='test.txt',
               sort=False, **kwargs):
    '''Extracts persistent homology from tree'''
    ph = get_persistence_diagram(tree, feature=feature, **kwargs)

    if sort:
        p = sort_ph(ph)
    else:
        p = ph

    write_ph(p, output_file)
예제 #3
0
파일: plot.py 프로젝트: masht18/TMD
def barcode(ph,
            new_fig=True,
            subplot=False,
            color='b',
            linewidth=1.2,
            **kwargs):
    """
    Generates a 2d figure (barcode) of the persistent homology
    of a tree as it has been computed by
    Topology.get_persistent_homology method.
    """
    # Initialization of matplotlib figure and axes.
    fig, ax = _cm.get_figure(new_fig=new_fig, subplot=subplot)
    ph_sort = analysis.sort_ph(ph)

    for ip, p in enumerate(ph_sort):
        ax.plot(p[:2], [ip, ip], c=color, linewidth=linewidth)

    kwargs['title'] = kwargs.get('title', 'Persistence barcode')
    kwargs['xlabel'] = kwargs.get('xlabel',
                                  'Lifetime: radial distance from soma')

    _cm.plt.ylim([-1, len(ph_sort)])
    return _cm.plot_style(fig=fig, ax=ax, **kwargs)