예제 #1
0
def test__compute_sholl_data():
    obj = Repair(SIMPLE_PATH)
    obj._fill_repair_type_map()
    branches = [neurite.root_node for neurite in obj.neuron.neurites]
    sholl_data = obj._compute_sholl_data(branches)
    assert_dict_equal(sholl_data[RepairType.basal][0][0], {
        Action.TERMINATION: 0,
        Action.CONTINUATION: 0,
        Action.BIFURCATION: 1
    })
    assert_dict_equal(sholl_data[RepairType.basal][0][1], {
        Action.TERMINATION: 2,
        Action.CONTINUATION: 0,
        Action.BIFURCATION: 0
    })
    assert_dict_equal(sholl_data[RepairType.oblique], {})
    assert_dict_equal(
        sholl_data[RepairType.axon], {
            0: {
                0: {
                    Action.BIFURCATION: 1,
                    Action.CONTINUATION: 0,
                    Action.TERMINATION: 0
                },
                1: {
                    Action.BIFURCATION: 0,
                    Action.CONTINUATION: 0,
                    Action.TERMINATION: 2
                }
            }
        })
예제 #2
0
def test_intact_branching_angles():
    obj = Repair(SIMPLE_PATH)
    obj._fill_repair_type_map()
    branches = [neurite.root_node for neurite in obj.neuron.neurites]
    angles = obj._intact_branching_angles(branches)
    assert_array_almost_equal(angles[test_module.RepairType.basal][0],
                              [1.5707963267948966, 1.5707963267948966])
예제 #3
0
def test__find_intact_sub_trees():
    obj = Repair(SIMPLE_PATH)
    obj.cut_leaves = np.array([[2, 2, 2]])
    obj._fill_repair_type_map()

    assert_equal(len(obj._find_intact_sub_trees()), 2)

    points = test_module.CutPlane.find(SLICE,
                                       bin_width=15).cut_leaves_coordinates
    obj = Repair(SLICE_PATH, cut_leaves_coordinates=points)
    obj._fill_repair_type_map()
    intact_sub_trees = obj._find_intact_sub_trees()
    assert_array_equal([section.id for section in intact_sub_trees], [0, 34])

    obj = Repair(DATA_PATH / 'test-cut-apical' / 'simple-apical-cut.swc',
                 cut_leaves_coordinates=[[1.0, 30.0, 0.0]])
    obj._fill_repair_type_map()
    intact_sub_trees = obj._find_intact_sub_trees()
    assert_array_equal([section.id for section in intact_sub_trees], [1, 0, 3])
    assert_array_equal(
        [obj.repair_type_map[section] for section in intact_sub_trees],
        [RepairType.basal, RepairType.axon, RepairType.tuft])

    filename = DATA_PATH / 'no-intact-basals.h5'
    points = test_module.CutPlane.find(filename,
                                       bin_width=15).cut_leaves_coordinates
    obj = Repair(filename, cut_leaves_coordinates=points)
    obj._fill_repair_type_map()
    intact_sub_trees = obj._find_intact_sub_trees()
    basals = [
        section for section in intact_sub_trees
        if section.type == NeuriteType.basal_dendrite
    ]
    assert_equal(len(basals), 78)
예제 #4
0
def test__compute_statistics_for_intact_subtrees():
    input_file = DATA_PATH / 'neuron-slice.h5'
    points = test_module.CutPlane.find(input_file,
                                       bin_width=15).cut_leaves_coordinates
    obj = Repair(input_file, cut_leaves_coordinates=points)
    obj._fill_repair_type_map()
    obj._fill_statistics_for_intact_subtrees()

    with open(DATA_PATH / 'neuron-slice-sholl-data.json') as f:
        expected = json.load(f)

    basal_data = expected['SectionType.basal_dendrite']

    actual = json_compatible_dict(obj.info['sholl'][RepairType.basal])
    for layer in basal_data:
        for order in basal_data[layer]:
            for action in basal_data[layer][order]:
                assert_equal(basal_data[layer][order][action],
                             actual[layer][order][action])
예제 #5
0
def test__fill_repair_type_map():
    obj = Repair(DATA_PATH / 'repair_type.asc')
    obj.apical_section = obj.neuron.sections[3]
    # Pre check to be sure that the apical point is the one it should be
    assert_array_almost_equal(
        obj.apical_section.points,
        np.array([[0., 0., 4., 1.], [0., 0., 0., 0.5], [1., 0., 0., 0.5]],
                 dtype=np.float32))

    obj._fill_repair_type_map()
    assert_dict_equal({sec.id: v
                       for sec, v in obj.repair_type_map.items()}, {
                           0: test_module.RepairType.axon,
                           1: test_module.RepairType.trunk,
                           2: test_module.RepairType.oblique,
                           3: test_module.RepairType.trunk,
                           4: test_module.RepairType.tuft,
                           5: test_module.RepairType.tuft,
                           6: test_module.RepairType.basal,
                       })