• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

BlueBrain / MorphIO / 6533524408

16 Oct 2023 12:24PM UTC coverage: 76.051% (-0.02%) from 76.073%
6533524408

push

github

mgeplf
fix test_root_node_split

1972 of 2593 relevant lines covered (76.05%)

903.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

11.36
/src/mut/modifiers.cpp
1
/* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2
 *
3
 * SPDX-License-Identifier: Apache-2.0
4
 */
5
#include <algorithm>
6
#include <cmath>
7
#include <morphio/mut/modifiers.h>
8
#include <morphio/mut/morphology.h>
9

10
namespace morphio {
11
namespace mut {
12
namespace modifiers {
13

14
void two_points_sections(morphio::mut::Morphology& morpho) {
×
15
    for (auto it = morpho.depth_begin(); it != morpho.depth_end(); ++it) {
×
16
        std::shared_ptr<Section> section = *it;
×
17
        size_t size = section->points().size();
×
18
        if (size < 2) {
×
19
            continue;
×
20
        }
21
        section->points() = {section->points()[0], section->points()[size - 1]};
×
22
        section->diameters() = {section->diameters()[0], section->diameters()[size - 1]};
×
23
        if (!section->perimeters().empty()) {
×
24
            section->perimeters() = {section->perimeters()[0], section->perimeters()[size - 1]};
×
25
        }
26
    }
27
}
×
28

29
void no_duplicate_point(morphio::mut::Morphology& morpho) {
×
30
    for (auto it = morpho.depth_begin(); it != morpho.depth_end(); ++it) {
×
31
        std::shared_ptr<Section> section = *it;
×
32
        size_t size = section->points().size();
×
33

34
        if (size < 1 || (*it)->isRoot()) {
×
35
            continue;
×
36
        }
37

38
        section->points().erase(section->points().begin());
×
39
        section->diameters().erase(section->diameters().begin());
×
40

41
        if (!section->perimeters().empty()) {
×
42
            section->perimeters().erase(section->perimeters().begin());
×
43
        }
44
    }
45
}
×
46

47
void soma_sphere(morphio::mut::Morphology& morpho) {
×
48
    auto soma = morpho.soma();
×
49
    const auto size = static_cast<morphio::floatType>(soma->points().size());
×
50

51
    if (size < 2) {
×
52
        return;
×
53
    }
54

55
    floatType x = 0;
×
56
    floatType y = 0;
×
57
    floatType z = 0;
×
58
    floatType r = 0;
×
59

60
    for (const Point& point : soma->points()) {
×
61
        x += point[0] / size;
×
62
        y += point[1] / size;
×
63
        z += point[2] / size;
×
64
    }
65

66
    for (auto point : soma->points()) {
×
67
#ifdef MORPHIO_USE_DOUBLE
68
        r += sqrt(pow(point[0] - x, 2) + pow(point[1] - y, 2) + pow(point[2] - z, 2)) / size;
69
#else
70
        r += sqrtf(powf(point[0] - x, 2) + powf(point[1] - y, 2) + powf(point[2] - z, 2)) / size;
×
71
#endif
72
    }
73

74
    soma->points() = {{x, y, z}};
×
75
    soma->diameters() = {r};
×
76
}
77

78
static bool NRN_order_comparator(std::shared_ptr<Section> a, std::shared_ptr<Section> b) {
8✔
79
    return a->type() < b->type();
8✔
80
}
81

82
void nrn_order(morphio::mut::Morphology& morpho) {
6✔
83
    std::stable_sort(morpho._rootSections.begin(),
6✔
84
                     morpho._rootSections.end(),
85
                     NRN_order_comparator);
86
}
6✔
87

88
}  // namespace modifiers
89

90
}  // namespace mut
91

92
}  // namespace morphio
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc