• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python neurom.load_neuron函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中neurom.load_neuron函数的典型用法代码示例。如果您正苦于以下问题:Python load_neuron函数的具体用法?Python load_neuron怎么用?Python load_neuron使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了load_neuron函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_translate_fst_neuron_h5

def test_translate_fst_neuron_h5():

    t = np.array([100.,100.,100.])
    nrn = load_neuron(H5_NRN_PATH)
    tnrn = gtr.translate(nrn, t)

    _check_fst_nrn_translate(nrn, tnrn, t)
开发者ID:juanchopanza,项目名称:NeuroM,代码行数:7,代码来源:test_transform.py


示例2: test_translate_fst_neurite_h5

def test_translate_fst_neurite_h5():

    t = np.array([100.,100.,100.])
    nrn = load_neuron(H5_NRN_PATH)
    nrt_a = nrn.neurites[0]
    nrt_b = gtr.translate(nrt_a, t)
    _check_fst_neurite_translate(nrt_a, nrt_b, t)
开发者ID:juanchopanza,项目名称:NeuroM,代码行数:7,代码来源:test_transform.py


示例3: view

def view(input_file, plane, backend):
    '''A simple neuron viewer'''
    if backend == 'matplotlib':
        from neurom.viewer import draw
        kwargs = {
            'mode': '3d' if plane == '3d' else '2d',
        }
        if plane != '3d':
            kwargs['plane'] = plane
        draw(load_neuron(input_file), **kwargs)
    else:
        from neurom.view.plotly import draw
        draw(load_neuron(input_file), plane=plane)

    if backend == 'matplotlib':
        import matplotlib.pyplot as plt
        plt.show()
开发者ID:BlueBrain,项目名称:NeuroM,代码行数:17,代码来源:__main__.py


示例4: test_terminal_length_per_neurite

def test_terminal_length_per_neurite():
    nrn = nm.load_neuron(os.path.join(SWC_PATH, 'simple.swc'))
    terminal_distances = np.array(_nf.terminal_path_lengths_per_neurite(nrn))
    np.testing.assert_allclose(terminal_distances,
                               np.array([5 + 5., 5 + 6., 4. + 6., 4. + 5]))
    terminal_distances = np.array(_nf.terminal_path_lengths_per_neurite(
        nrn, neurite_type=nm.AXON))
    np.testing.assert_allclose(terminal_distances,
                               np.array([4. + 6., 4. + 5.]))
开发者ID:eleftherioszisis,项目名称:NeuroM,代码行数:9,代码来源:test_neuritefunc.py


示例5: setUp

 def setUp(self):
     self.ref_nrn = 'swc'
     self.sec_nrn = nm.load_neuron(os.path.join(SWC_DATA_PATH, SWC_MORPH_FILENAME))
     self.sec_nrn_trees = [n.root_node for n in self.sec_nrn.neurites]
     self.ref_types = [NeuriteType.axon,
                       NeuriteType.basal_dendrite,
                       NeuriteType.basal_dendrite,
                       NeuriteType.apical_dendrite,
                       ]
开发者ID:jdcourcol,项目名称:NeuroM,代码行数:9,代码来源:test_feature_compat.py


示例6: test_get_nonmonotonic_neurites

def test_get_nonmonotonic_neurites():

    n = load_neuron(os.path.join(SWC_PATH, 'Neuron.swc'))

    nt.assert_equal(len(mt.get_nonmonotonic_neurites(n)), 4)

    _make_monotonic(n)

    nt.assert_equal(len(mt.get_nonmonotonic_neurites(n)), 0)
开发者ID:BlueBrain,项目名称:NeuroM,代码行数:9,代码来源:test_morphtree.py


示例7: test_principal_direction_extents

def test_principal_direction_extents():
    # test with a realistic neuron
    nrn = nm.load_neuron(os.path.join(H5_PATH, 'bio_neuron-000.h5'))

    p_ref = [1672.9694359427331, 142.43704397865031, 226.45895382204986,
             415.50612748523838, 429.83008974193206, 165.95410536922873,
             346.83281498399697]

    p = _nf.principal_direction_extents(nrn)
    _close(np.array(p), np.array(p_ref))
开发者ID:eleftherioszisis,项目名称:NeuroM,代码行数:10,代码来源:test_neuritefunc.py


示例8: test_extract_stats_single_neuron

def test_extract_stats_single_neuron():
    nrn = nm.load_neuron(os.path.join(DATA_PATH, 'Neuron.swc'))
    res = ms.extract_stats(nrn, REF_CONFIG)
    nt.eq_(res.keys(), REF_OUT.keys())
    nt.assert_almost_equal(res['mean_soma_radius'], REF_OUT['mean_soma_radius'])

    for k in ('all', 'axon', 'basal_dendrite', 'apical_dendrite'):
        nt.eq_(res[k].keys(), REF_OUT[k].keys())
        for kk in res[k].keys():
            nt.assert_almost_equal(res[k][kk], REF_OUT[k][kk])
开发者ID:jdcourcol,项目名称:NeuroM,代码行数:10,代码来源:test_morph_stats.py


示例9: test_get_flat_neurites

def test_get_flat_neurites():

    n = load_neuron(os.path.join(SWC_PATH, 'Neuron.swc'))

    nt.assert_equal(len(mt.get_flat_neurites(n, 1e-6, method='tolerance')), 0)
    nt.assert_equal(len(mt.get_flat_neurites(n, 0.1, method='ratio')), 0)

    n = _make_flat(n)

    nt.assert_equal(len(mt.get_flat_neurites(n, 1e-6, method='tolerance')), 4)
    nt.assert_equal(len(mt.get_flat_neurites(n, 0.1, method='ratio')), 4)
开发者ID:BlueBrain,项目名称:NeuroM,代码行数:11,代码来源:test_morphtree.py


示例10: test_extract_stats_single_neuron

def test_extract_stats_single_neuron():
    nrn = nm.load_neuron(os.path.join(DATA_PATH, 'Neuron.swc'))
    res = ms.extract_stats(nrn, REF_CONFIG)
    nt.eq_(set(res.keys()), set(REF_OUT.keys()))
    #Note: soma radius is calculated from the sphere that gives the area
    # of the cylinders described in Neuron.swc
    nt.assert_almost_equal(res['mean_soma_radius'], REF_OUT['mean_soma_radius'])

    for k in ('all', 'axon', 'basal_dendrite', 'apical_dendrite'):
        nt.eq_(set(res[k].keys()), set(REF_OUT[k].keys()))
        for kk in res[k].keys():
            nt.assert_almost_equal(res[k][kk], REF_OUT[k][kk])
开发者ID:BlueBrain,项目名称:NeuroM,代码行数:12,代码来源:test_morph_stats.py


示例11: test_section_radial_distances_endpoint

def test_section_radial_distances_endpoint():
    ref_sec_rad_dist = nf.section_radial_distances(NEURON)

    rad_dists = fst_get('section_radial_distances', NEURON)

    nt.eq_(len(rad_dists), 84)
    nt.ok_(np.all(rad_dists == ref_sec_rad_dist))

    nrns = [nm.load_neuron(os.path.join(SWC_PATH, f)) for
            f in ('point_soma_single_neurite.swc', 'point_soma_single_neurite2.swc')]
    pop = Population(nrns)
    rad_dist_nrns = [nm.get('section_radial_distances', nrn) for nrn in nrns]
    rad_dist_pop = nm.get('section_radial_distances', pop)
    assert_items_equal(rad_dist_pop, rad_dist_nrns)
开发者ID:jdcourcol,项目名称:NeuroM,代码行数:14,代码来源:test_get_features.py


示例12: test_segment_radial_distances_displaced_neurite

def test_segment_radial_distances_displaced_neurite():
    nrns = [nm.load_neuron(os.path.join(SWC_PATH, f)) for
            f in ('point_soma_single_neurite.swc', 'point_soma_single_neurite2.swc')]

    pop = Population(nrns)

    rad_dist_nrns = []
    for nrn in nrns:
        rad_dist_nrns.extend( nm.get('segment_radial_distances', nrn))

    rad_dist_nrns = np.array(rad_dist_nrns)

    rad_dist_pop = nm.get('segment_radial_distances', pop)

    nt.ok_(np.alltrue(rad_dist_pop == rad_dist_nrns))
开发者ID:eleftherioszisis,项目名称:NeuroM,代码行数:15,代码来源:test_neuritefunc.py


示例13: test_has_no_narrow_dendritic_section

def test_has_no_narrow_dendritic_section():
    swc_content = StringIO(u"""
# index, type, x, y, z, radius, parent
    1 1  0  0 0 10. -1
    2 2  0  0 0 10.  1
    3 2  0  50 0 10.  2
    4 2 -5  51 0 10.  3
    5 2  6  53 0 10.  3
    6 3  0  0 0 5.  1  # start of the narrow section
    7 3  0 -4 0 5.  6
    8 3  6 -4 0 10.  7
    9 3 -5 -4 0 10.  7
""")
    nrn = load_neuron(swc_content, reader='swc')
    res = nrn_chk.has_no_narrow_neurite_section(nrn,
                                                dendrite_filter,
                                                radius_threshold=5,
                                                considered_section_min_length=0)

    nt.ok_(res.status)

    res = nrn_chk.has_no_narrow_neurite_section(nrn, dendrite_filter,
                                                radius_threshold=7,
                                                considered_section_min_length=0)
    nt.ok_(not res.status)

    swc_content = StringIO(u"""
# index, type, x, y, z, radius, parent
    1 1  0  0 0 10. -1
    2 2  0  0 0 5  1 # narrow soma
    3 2  0  50 0 5  2
    4 2 -5  51 0 5  3
    5 2  6  53 0 5  3
    6 3  0  0 0 5  1 # narrow axon
    7 3  0 -4 0 10.  6
    8 3  6 -4 0 10.  7
    9 3 -5 -4 0 10.  7
""")
    res = nrn_chk.has_no_narrow_neurite_section(nrn, dendrite_filter,
                                                radius_threshold=5,
                                                considered_section_min_length=0)
    nt.ok_(res.status, 'Narrow soma or axons should not raise bad status when checking for narrow dendrites')
开发者ID:BlueBrain,项目名称:NeuroM,代码行数:42,代码来源:test_neuron_checks.py


示例14: test_segment_radial_distances_origin

def test_segment_radial_distances_origin():
    origin = (-100, -200, -300)
    ref_segs = nf.segment_radial_distances(NEURON)
    ref_segs_origin = nf.segment_radial_distances(NEURON, origin=origin)

    rad_dists = fst_get('segment_radial_distances', NEURON)
    rad_dists_origin = fst_get('segment_radial_distances', NEURON, origin=origin)

    nt.ok_(np.all(rad_dists == ref_segs))
    nt.ok_(np.all(rad_dists_origin == ref_segs_origin))
    nt.ok_(np.all(rad_dists_origin != ref_segs))

    nrns = [nm.load_neuron(os.path.join(SWC_PATH, f)) for
            f in ('point_soma_single_neurite.swc', 'point_soma_single_neurite2.swc')]
    pop = Population(nrns)
    rad_dist_nrns = []
    for nrn in nrns:
        rad_dist_nrns.extend(nm.get('segment_radial_distances', nrn))

    rad_dist_nrns = np.array(rad_dist_nrns)
    rad_dist_pop = nm.get('segment_radial_distances', pop)
    assert_allclose(rad_dist_nrns, rad_dist_pop)
开发者ID:jdcourcol,项目名称:NeuroM,代码行数:22,代码来源:test_get_features.py


示例15: random_color

import numpy as np

_path = os.path.dirname(os.path.abspath(__file__))
DATA_PATH = os.path.join(_path, '../test_data')
SWC_PATH = os.path.join(DATA_PATH, 'swc')


def random_color():
    '''Random color generation'''
    return np.random.rand(3, 1)


def plot_somas(somas):
    '''Plot set of somas on same figure as spheres, each with different color'''
    _, ax = common.get_figure(new_fig=True, subplot=111,
                              params={'projection': '3d', 'aspect': 'equal'})
    for s in somas:
        common.plot_sphere(ax, s.center, s.radius, color=random_color(), alpha=1)
    plt.show()


if __name__ == '__main__':
    #  define set of files containing relevant neurons
    file_nms = [os.path.join(SWC_PATH, file_nm) for file_nm in ['Soma_origin.swc',
                                                                'Soma_translated_1.swc',
                                                                'Soma_translated_2.swc']]

    # load from file and plot
    sms = [load_neuron(file_nm).soma for file_nm in file_nms]
    plot_somas(sms)
开发者ID:BlueBrain,项目名称:NeuroM,代码行数:30,代码来源:plot_somas.py


示例16: _load_neuron

def _load_neuron(name):
    if name.endswith('.swc'):
        path = os.path.join(SWC_PATH, name)
    elif name.endswith('.h5'):
        path = os.path.join(H5V1_PATH, name)
    return name, load_neuron(path)
开发者ID:jdcourcol,项目名称:NeuroM,代码行数:6,代码来源:test_neuron_checks.py


示例17: test_has_nonzero_soma_radius_bad_data

def test_has_nonzero_soma_radius_bad_data():

    nrn = load_neuron(os.path.join(SWC_PATH, 'Single_basal.swc'))
    nt.assert_false(nrn_chk.has_nonzero_soma_radius(nrn).status)
开发者ID:jdcourcol,项目名称:NeuroM,代码行数:4,代码来源:test_neuron_checks.py


示例18: test_has_nonzero_soma_radius

def test_has_nonzero_soma_radius():

    nrn = load_neuron(os.path.join(SWC_PATH, 'Neuron.swc'))
    nt.assert_true(nrn_chk.has_nonzero_soma_radius(nrn))
开发者ID:jdcourcol,项目名称:NeuroM,代码行数:4,代码来源:test_neuron_checks.py


示例19: joinp

# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import os
from os.path import join as joinp

from nose import tools as nt
from neurom.core.population import Population
from neurom import load_neuron

_path = os.path.dirname(os.path.abspath(__file__))
DATA_PATH = joinp(_path, '../../../test_data')

NRN1 = load_neuron(joinp(DATA_PATH, 'swc/Neuron.swc'))
NRN2 = load_neuron(joinp(DATA_PATH, 'swc/Single_basal.swc'))
NRN3 = load_neuron(joinp(DATA_PATH, 'swc/Neuron_small_radius.swc'))

NEURONS = [NRN1, NRN2, NRN3]
TOT_NEURITES = sum(len(N.neurites) for N in NEURONS)
POP = Population(NEURONS, name='foo')


def test_population():
    nt.assert_equal(len(POP.neurons), 3)
    nt.ok_(POP.neurons[0].name, 'Neuron')
    nt.ok_(POP.neurons[1].name, 'Single_basal')
    nt.ok_(POP.neurons[2].name, 'Neuron_small_radius')

    nt.assert_equal(len(POP.somata), 3)
开发者ID:BlueBrain,项目名称:NeuroM,代码行数:31,代码来源:test_population.py


示例20: get_segment

# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

'''Get sections and segments by ID'''

import neurom as nm
from neurom import morphmath as mm
from neurom.core.dataformat import COLS


def get_segment(neuron, section_id, segment_id):
    '''Get a segment given a section and segment id

    Returns:
        array of two [x, y, z, r] points defining segment
    '''
    sec = neuron.sections[section_id]
    return sec.points[segment_id:segment_id + 2][:, 0:4]


if __name__ == '__main__':

    nrn = nm.load_neuron('test_data/h5/v1/Neuron.h5')

    seg = get_segment(nrn, 3, 2)
    print 'Segment:\n', seg
    print 'Mid-point (x, y, z):\n', mm.linear_interpolate(seg[0], seg[1], 0.5)
    print 'Mid-point R:\n', mm.interpolate_radius(seg[0][COLS.R], seg[1][COLS.R], 0.5)
开发者ID:juanchopanza,项目名称:NeuroM,代码行数:30,代码来源:section_ids.py



注:本文中的neurom.load_neuron函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tree.val_iter函数代码示例发布时间:2022-05-27
下一篇:
Python neurom.get函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap