Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

increase allowed section type to 19 #462

Merged
merged 1 commit into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions binds/python/bind_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ void bind_misc(py::module& m) {
.value("custom8", morphio::enums::SectionType::SECTION_CUSTOM_8)
.value("custom9", morphio::enums::SectionType::SECTION_CUSTOM_9)
.value("custom10", morphio::enums::SectionType::SECTION_CUSTOM_10)
.value("custom11", morphio::enums::SectionType::SECTION_CUSTOM_11)
.value("custom12", morphio::enums::SectionType::SECTION_CUSTOM_12)
.value("custom13", morphio::enums::SectionType::SECTION_CUSTOM_13)
.value("custom14", morphio::enums::SectionType::SECTION_CUSTOM_14)
.value("custom15", morphio::enums::SectionType::SECTION_CUSTOM_15)
.value("custom16", morphio::enums::SectionType::SECTION_CUSTOM_16)
.value("custom17", morphio::enums::SectionType::SECTION_CUSTOM_17)
.value("custom18", morphio::enums::SectionType::SECTION_CUSTOM_18)
.value("custom19", morphio::enums::SectionType::SECTION_CUSTOM_19)
.value("glia_perivascular_process",
morphio::enums::SectionType::SECTION_GLIA_PERIVASCULAR_PROCESS)
.value("glia_process", morphio::enums::SectionType::SECTION_GLIA_PROCESS)
Expand Down
30 changes: 24 additions & 6 deletions binds/python/generated/docstrings.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,17 +831,35 @@ static const char *__doc_morphio_enums_SectionType_SECTION_AXON = R"doc(Axon sec

static const char *__doc_morphio_enums_SectionType_SECTION_CNIC_CUSTOM_START = R"doc()doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_10 = R"doc(Custom section type)doc";
static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_10 = R"doc(Custom section type 10)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_5 = R"doc(Custom section type)doc";
static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_11 = R"doc(Custom section type 11)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_6 = R"doc(Custom section type)doc";
static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_12 = R"doc(Custom section type 12)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_7 = R"doc(Custom section type)doc";
static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_13 = R"doc(Custom section type 13)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_8 = R"doc(Custom section type)doc";
static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_14 = R"doc(Custom section type 14)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_9 = R"doc(Custom section type)doc";
static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_15 = R"doc(Custom section type 15)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_16 = R"doc(Custom section type 16)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_17 = R"doc(Custom section type 17)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_18 = R"doc(Custom section type 18)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_19 = R"doc(Custom section type 19)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_5 = R"doc(Custom section type 5)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_6 = R"doc(Custom section type 6)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_7 = R"doc(Custom section type 7)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_8 = R"doc(Custom section type 8)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_CUSTOM_9 = R"doc(Custom section type 9)doc";

static const char *__doc_morphio_enums_SectionType_SECTION_DENDRITE = R"doc(General or basal dendrite (near to soma))doc";

Expand Down
33 changes: 24 additions & 9 deletions include/morphio/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,30 @@ enum SectionType {
SECTION_SPINE_HEAD = 3, // Note: overlaps with SECTION_DENDRITE

// unnamed custom section types
SECTION_CUSTOM_5 = 5, //!< Custom section type
SECTION_CUSTOM_6 = 6, //!< Custom section type
SECTION_CUSTOM_7 = 7, //!< Custom section type
SECTION_CUSTOM_8 = 8, //!< Custom section type
SECTION_CUSTOM_9 = 9, //!< Custom section type
SECTION_CUSTOM_10 = 10, //!< Custom section type
// All section types equal or above this number are invalid custom types according
// to neuromorpho.org standard (http://neuromorpho.org/StdSwc1.21.jsp)
SECTION_OUT_OF_RANGE_START = 11,
SECTION_CUSTOM_5 = 5, //!< Custom section type 5
SECTION_CUSTOM_6 = 6, //!< Custom section type 6
SECTION_CUSTOM_7 = 7, //!< Custom section type 7
SECTION_CUSTOM_8 = 8, //!< Custom section type 8
SECTION_CUSTOM_9 = 9, //!< Custom section type 9
SECTION_CUSTOM_10 = 10, //!< Custom section type 10
// according to neuromorpho.org standard (http://neuromorpho.org/StdSwc1.21.jsp)
// `Codes 5-10 signify custom tags, typically defined in the header of the swc file when used.`

// ... but; we are a bit relaxed, since more is better:
// https://github.com/BlueBrain/MorphIO/issues/432
// https://github.com/BlueBrain/MorphIO/issues/456 (type 18 seen in the wild)
SECTION_CUSTOM_11 = 11, //!< Custom section type 11
SECTION_CUSTOM_12 = 12, //!< Custom section type 12
SECTION_CUSTOM_13 = 13, //!< Custom section type 13
SECTION_CUSTOM_14 = 14, //!< Custom section type 14
SECTION_CUSTOM_15 = 15, //!< Custom section type 15
SECTION_CUSTOM_16 = 16, //!< Custom section type 16
SECTION_CUSTOM_17 = 17, //!< Custom section type 17
SECTION_CUSTOM_18 = 18, //!< Custom section type 18
SECTION_CUSTOM_19 = 19, //!< Custom section type 19

// All section types equal or above this number are invalid custom types
SECTION_OUT_OF_RANGE_START = 20,

// CNIC defined types
// It defines too extra types SWC_SECTION_FORK_POINT and
Expand Down
Binary file modified tests/data/h5/v1/simple-broken-section-type.h5
Binary file not shown.
47 changes: 47 additions & 0 deletions tests/data/simple-all-types.swc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# index, type, x, y, z, radius, parent
1 1 0. 0. 0. .1 -1

2 5 0. 0. 0. .5 1
3 5 4.06736643 9.13545458 0. .5 2

4 6 0. 0. 0. .6 1
5 6 7.43144825 6.69130606 0. .6 4

6 7 0. 0. 0. .7 1
7 7 9.51056516 3.09016994 0. .7 6

8 8 0. 0. 0. .8 1
9 8 9.94521895 -1.04528463 0. .8 8

10 9 0. 0. 0. .9 1
11 9 8.66025404 -5. 0. .9 10

12 10 0. 0. 0. 1.0 1
13 10 5.87785252 -8.09016994 0. 1.0 12

14 11 0. 0. 0. 1.1 1
15 11 2.07911691 -9.78147601 0. 1.1 14

16 12 0. 0. 0. 1.1 1
17 12 -2.07911691 -9.78147601 0. 1.2 16

18 13 0. 0. 0. 1.1 1
19 13 -5.87785252 -8.09016994 0. 1.3 18

20 14 0. 0. 0. 1.1 1
21 14 -8.66025404 -5. 0. 1.4 20

22 15 0. 0. 0. 1.1 1
23 15 -9.94521895 -1.04528463 0. 1.5 22

24 16 0. 0. 0. 1.1 1
25 16 -9.51056516 3.09016994 0. 1.6 24

26 17 0. 0. 0. 1.1 1
27 17 -7.43144825 6.69130606 0. 1.7 26

28 18 0. 0. 0. 1.1 1
29 18 -4.06736643 9.13545458 0. 1.8 28

30 19 0. 0. 0. 1.1 1
31 19 0. 10. 0. 1.9 30
4 changes: 2 additions & 2 deletions tests/test_1_swc.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,12 @@ def test_unsupported_section_type():

content = ('''1 1 0 4 0 3.0 -1
2 3 0 0 2 0.5 1
3 11 0 0 3 0.5 2 # <-- 11 is unsupported section type
3 20 0 0 3 0.5 2 # <-- 20 is unsupported section type
''')

with pytest.raises(RawDataError, match=':3:error') as obj:
Morphology(content, extension='swc')
assert obj.match('Unsupported section type: 11')
assert obj.match('Unsupported section type: 20')


def test_root_node_split():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_3_h5.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_v1():


def test_wrong_section_type():
with pytest.raises(RawDataError, match='Unsupported section type: 12'):
with pytest.raises(RawDataError, match='Unsupported section type: 20'):
Morphology(H5V1_PATH / 'simple-broken-section-type.h5')

with pytest.raises(RawDataError, match='Unsupported section type: -2'):
Expand Down
25 changes: 23 additions & 2 deletions tests/test_morphology_readers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,30 @@ TEST_CASE("LoadH5MorphologySingleNeurite", "[morphology]") {
}

TEST_CASE("LoadSWCMorphology", "[morphology]") {
const morphio::Morphology m("data/simple.swc");
{
const morphio::Morphology m("data/simple.swc");
REQUIRE(m.diameters().size() == 12);
}

REQUIRE(m.diameters().size() == 12);
{
const morphio::Morphology all_types("data/simple-all-types.swc");
REQUIRE(all_types.diameters().size() == 30);
REQUIRE(all_types.rootSections()[0].type() == morphio::SECTION_CUSTOM_5);
REQUIRE(all_types.rootSections()[1].type() == morphio::SECTION_CUSTOM_6);
REQUIRE(all_types.rootSections()[2].type() == morphio::SECTION_CUSTOM_7);
REQUIRE(all_types.rootSections()[3].type() == morphio::SECTION_CUSTOM_8);
REQUIRE(all_types.rootSections()[4].type() == morphio::SECTION_CUSTOM_9);
REQUIRE(all_types.rootSections()[5].type() == morphio::SECTION_CUSTOM_10);
REQUIRE(all_types.rootSections()[6].type() == morphio::SECTION_CUSTOM_11);
REQUIRE(all_types.rootSections()[7].type() == morphio::SECTION_CUSTOM_12);
REQUIRE(all_types.rootSections()[8].type() == morphio::SECTION_CUSTOM_13);
REQUIRE(all_types.rootSections()[9].type() == morphio::SECTION_CUSTOM_14);
REQUIRE(all_types.rootSections()[10].type() == morphio::SECTION_CUSTOM_15);
REQUIRE(all_types.rootSections()[11].type() == morphio::SECTION_CUSTOM_16);
REQUIRE(all_types.rootSections()[12].type() == morphio::SECTION_CUSTOM_17);
REQUIRE(all_types.rootSections()[13].type() == morphio::SECTION_CUSTOM_18);
REQUIRE(all_types.rootSections()[14].type() == morphio::SECTION_CUSTOM_19);
}
}

TEST_CASE("LoadNeurolucidaMorphology", "[morphology]") {
Expand Down