├── .clang-format
├── .github
└── workflows
│ ├── check-sdist.yml
│ ├── clang_format_check.yaml
│ ├── coverage_test.yaml
│ ├── docstring_check.yaml
│ ├── publish-sdist-wheels.yml
│ └── run-tests.yml
├── .gitignore
├── .gitmodules
├── .readthedocs.yaml
├── 3rdparty
└── CMakeLists.txt
├── AUTHORS.txt
├── CHANGELOG.md
├── CMake
├── CodeCoverage.cmake
├── CompilerFlags.cmake
└── MorphIOConfig.cmake
├── CMakeLists.txt
├── CONTRIBUTING.md
├── LICENSE.txt
├── MANIFEST.in
├── README.rst
├── binds
└── python
│ ├── CMakeLists.txt
│ ├── bind_enums.cpp
│ ├── bind_enums.h
│ ├── bind_immutable.cpp
│ ├── bind_immutable.h
│ ├── bind_misc.cpp
│ ├── bind_misc.h
│ ├── bind_mutable.cpp
│ ├── bind_mutable.h
│ ├── bind_vasculature.cpp
│ ├── bind_vasculature.h
│ ├── bind_warnings_exceptions.cpp
│ ├── bind_warnings_exceptions.h
│ ├── bindings_utils.cpp
│ ├── bindings_utils.h
│ ├── generated
│ ├── .clang-format
│ └── docstrings.h
│ └── morphio.cpp
├── ci
├── check_clang_format.sh
├── check_generated_docstrings.sh
├── coverage_test.sh
├── cpp_test.sh
├── hdf5-build.sh
└── python_test.sh
├── doc
├── Makefile
├── README.md
└── source
│ ├── Doxyfile
│ ├── DoxygenLayout.xml
│ ├── _templates
│ └── doxygen_page.rst_t
│ ├── conf.py
│ ├── cpp.rst
│ ├── doxygen
│ └── .gitignore
│ ├── footer.html
│ ├── glia.rst
│ ├── header.html
│ ├── images
│ ├── section_segment.svg
│ ├── sections.svg
│ └── swc
│ │ ├── sequential.svg
│ │ ├── sphere.svg
│ │ ├── split.svg
│ │ ├── three_pt.svg
│ │ └── two_pt.svg
│ ├── index.rst
│ ├── install.rst
│ ├── logo
│ └── BBP-MorphIO.jpg
│ ├── markers.rst
│ ├── mitochondria.rst
│ ├── morphology.rst
│ ├── python.rst
│ ├── reticulum.rst
│ ├── specification.rst
│ ├── specification_neurolucida.rst
│ └── warnings.rst
├── examples
├── getting_started.ipynb
└── getting_started_mutable.ipynb
├── include
└── morphio
│ ├── collection.h
│ ├── dendritic_spine.h
│ ├── endoplasmic_reticulum.h
│ ├── enums.h
│ ├── errorMessages.h
│ ├── exceptions.h
│ ├── glial_cell.h
│ ├── mito_section.h
│ ├── mitochondria.h
│ ├── morphology.h
│ ├── mut
│ ├── dendritic_spine.h
│ ├── endoplasmic_reticulum.h
│ ├── glial_cell.h
│ ├── mito_section.h
│ ├── mitochondria.h
│ ├── modifiers.h
│ ├── morphology.h
│ ├── section.h
│ ├── soma.h
│ └── writers.h
│ ├── properties.h
│ ├── section.h
│ ├── section_base.h
│ ├── section_iterators.hpp
│ ├── soma.h
│ ├── types.h
│ ├── vasc
│ ├── iterators.hpp
│ ├── properties.h
│ ├── section.h
│ └── vasculature.h
│ ├── vector_types.h
│ ├── version.h
│ └── warning_handling.h
├── morphio
├── __init__.py
├── mut
│ └── __init__.py
└── vasculature
│ └── __init__.py
├── pyproject.toml
├── scripts
└── check-clang-format-all
├── setup.py
├── src
├── CMakeLists.txt
├── collection.cpp
├── dendritic_spine.cpp
├── endoplasmic_reticulum.cpp
├── enums.cpp
├── errorMessages.cpp
├── error_message_generation.cpp
├── error_message_generation.h
├── glial_cell.cpp
├── mito_section.cpp
├── mitochondria.cpp
├── morphology.cpp
├── mut
│ ├── dendritic_spine.cpp
│ ├── endoplasmic_reticulum.cpp
│ ├── glial_cell.cpp
│ ├── mito_section.cpp
│ ├── mitochondria.cpp
│ ├── modifiers.cpp
│ ├── morphology.cpp
│ ├── section.cpp
│ ├── soma.cpp
│ ├── writer_asc.cpp
│ ├── writer_hdf5.cpp
│ ├── writer_swc.cpp
│ ├── writer_utils.cpp
│ └── writer_utils.h
├── point_utils.cpp
├── point_utils.h
├── properties.cpp
├── readers
│ ├── NeurolucidaLexer.inc
│ ├── morphologyASC.cpp
│ ├── morphologyASC.h
│ ├── morphologyHDF5.cpp
│ ├── morphologyHDF5.h
│ ├── morphologySWC.cpp
│ ├── morphologySWC.h
│ ├── utils.cpp
│ ├── utils.h
│ ├── vasculatureHDF5.cpp
│ └── vasculatureHDF5.h
├── section.cpp
├── shared_utils.cpp
├── shared_utils.hpp
├── soma.cpp
├── vasc
│ ├── properties.cpp
│ ├── section.cpp
│ └── vasculature.cpp
├── version.cpp.in
└── warning_handling.cpp
└── tests
├── CMakeLists.txt
├── data
├── annotations.asc
├── astrocyte.h5
├── circle_contour.asc
├── complexe.swc
├── disconnected_neurite.swc
├── h5
│ ├── empty.h5
│ ├── merged.h5
│ ├── non-valid.h5
│ ├── v1
│ │ ├── Neuron-no-soma.h5
│ │ ├── Neuron.h5
│ │ ├── endoplasmic-reticulum.h5
│ │ ├── glia.h5
│ │ ├── glia_empty_perimeters.h5
│ │ ├── glia_soma_only.h5
│ │ ├── glia_wrong_sized_perimeters.h5
│ │ ├── h5v1.4.h5
│ │ ├── incorrect_point_columns.h5
│ │ ├── incorrect_structure_columns.h5
│ │ ├── make-dendritic-spine.py
│ │ ├── merged.h5
│ │ ├── metadata_group_only.h5
│ │ ├── mitochondria.h5
│ │ ├── monodim.h5
│ │ ├── reversed_NRN_neurite_order.h5
│ │ ├── simple-broken-section-type.h5
│ │ ├── simple-dendritric-spine.h5
│ │ ├── simple-negative-section-type.h5
│ │ ├── simple-single-point-soma.h5
│ │ ├── simple-two-point-soma.h5
│ │ ├── simple.h5
│ │ ├── single-neurite.h5
│ │ ├── soma_after_dendrite.h5
│ │ ├── soma_no_neurites.h5
│ │ ├── three-point-soma-two-offset.h5
│ │ ├── two_child_unmerged.h5
│ │ └── unknown_section_type_structure.h5
│ ├── v2
│ │ └── Neuron.h5
│ ├── vasculature-broken-section-type.h5
│ ├── vasculature1.h5
│ └── vasculature2.h5
├── invalid-incomplete.asc
├── iterators.asc
├── marker-with-string.asc
├── markers.asc
├── mono-type.asc
├── multiple_point_section.asc
├── multiple_soma.swc
├── nested_single_children.asc
├── neurite_wrong_root_point.swc
├── no_soma.swc
├── nrn-order-already-sorted.h5
├── nrn_ordering.swc
├── pia.asc
├── reversed_NRN_neurite_order.swc
├── sections-block.asc
├── simple-all-types.swc
├── simple-heterogeneous-neurite.swc
├── simple-trailing-space.swc
├── simple-windows-eol.swc
├── simple-with-font.asc
├── simple-with-image-coord.asc
├── simple.asc
├── simple.swc
├── simple.unknown
├── simple2.asc
├── single_point_root.asc
├── soma_cylinders.swc
├── soma_multiple_frustums.swc
├── soma_single_frustum.swc
├── soma_three_points_cylinder.swc
├── spine.asc
└── three_point_soma.swc
├── main.cpp
├── requirement_tests.txt
├── test_0_API.py
├── test_10_vasculature.py
├── test_11_collection.py
├── test_1_swc.py
├── test_2_neurolucida.py
├── test_3_h5.py
├── test_4_immut.py
├── test_5_mut.py
├── test_6_writers.py
├── test_7_modifiers.py
├── test_8_all_morphologies.py
├── test_9_surfaces.py
├── test_collection.cpp
├── test_enums.cpp
├── test_immutable_morphology.cpp
├── test_mitochondria.cpp
├── test_morphology_readers.cpp
├── test_mutable_morphology.cpp
├── test_point_utils.cpp
├── test_properties.cpp
├── test_soma.cpp
├── test_swc_reader.cpp
├── test_utilities.cpp
├── test_vasculature_morphology.cpp
├── test_vector_utils.cpp
└── utils.py
/.clang-format:
--------------------------------------------------------------------------------
1 | ---
2 | AccessModifierOffset: -2
3 | AlignAfterOpenBracket: Align
4 | AlignConsecutiveAssignments: false
5 | AlignConsecutiveDeclarations: false
6 | AlignEscapedNewlinesLeft: true
7 | AlignOperands: true
8 | AlignTrailingComments: true
9 | AllowAllParametersOfDeclarationOnNextLine: true
10 | AllowShortBlocksOnASingleLine: false
11 | AllowShortCaseLabelsOnASingleLine: false
12 | AllowShortFunctionsOnASingleLine: Empty
13 | AllowShortIfStatementsOnASingleLine: false
14 | AllowShortLoopsOnASingleLine: false
15 | AlwaysBreakBeforeMultilineStrings: true
16 | AlwaysBreakTemplateDeclarations: true
17 | BasedOnStyle: WebKit
18 | BinPackArguments: false
19 | BinPackParameters: false
20 | BraceWrapping:
21 | AfterClass: true
22 | AfterControlStatement: false
23 | AfterEnum: false
24 | AfterExternBlock: false
25 | AfterFunction: false
26 | AfterNamespace: false
27 | AfterStruct: false
28 | AfterUnion: false
29 | BeforeCatch: false
30 | BeforeElse: false
31 | BreakBeforeBraces: Custom
32 | BreakBeforeBinaryOperators: false
33 | BreakBeforeTernaryOperators: true
34 | BreakConstructorInitializersBeforeComma: true
35 | BreakStringLiterals: true
36 | ColumnLimit: 100
37 | CommentPragmas: '^ IWYU pragma:'
38 | ConstructorInitializerAllOnOneLineOrOnePerLine: false
39 | ConstructorInitializerIndentWidth: 4
40 | ContinuationIndentWidth: 4
41 | Cpp11BracedListStyle: true
42 | DerivePointerAlignment: false
43 | DerivePointerBinding: true
44 | ExperimentalAutoDetectBinPacking: false
45 | FixNamespaceComments: true
46 | ForEachMacros: [ foreach, ]
47 | IncludeCategories:
48 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
49 | Priority: 2
50 | - Regex: '^(<|"(gtest|isl|json)/)'
51 | Priority: 3
52 | - Regex: '.*'
53 | Priority: 1
54 | IncludeIsMainRegex: '$'
55 | IndentCaseLabels: false
56 | IndentWidth: 4
57 | IndentWrappedFunctionNames: false
58 | KeepEmptyLinesAtTheStartOfBlocks: false
59 | Language: Cpp
60 | MaxEmptyLinesToKeep: 2
61 | NamespaceIndentation: None
62 | PenaltyBreakAssignment: 40
63 | PenaltyBreakBeforeFirstCallParameter: 100
64 | PenaltyBreakComment: 60
65 | PenaltyBreakFirstLessLess: 120
66 | PenaltyBreakString: 1000
67 | PenaltyExcessCharacter: 1000000
68 | PenaltyReturnTypeOnItsOwnLine: 200
69 | PointerAlignment: Left
70 | PointerBindsToType: true
71 | ReflowComments: true
72 | SortIncludes: true
73 | SpaceAfterCStyleCast: true
74 | SpaceAfterTemplateKeyword: true
75 | SpaceBeforeAssignmentOperators: true
76 | SpaceBeforeCpp11BracedList: false
77 | SpaceBeforeCtorInitializerColon: false
78 | SpaceBeforeInheritanceColon: false
79 | SpaceBeforeParens: ControlStatements
80 | SpaceBeforeRangeBasedForLoopColon: true
81 | SpaceInEmptyParentheses: false
82 | SpacesBeforeTrailingComments: 2
83 | SpacesInAngles: false # '< ' style
84 | SpacesInContainerLiterals: false
85 | SpacesInCStyleCastParentheses: false
86 | SpacesInParentheses: false # '(' style
87 | SpacesInSquareBrackets: false
88 | Standard: Cpp11
89 | TabWidth: 4
90 | UseTab: Never
91 | ...
92 |
--------------------------------------------------------------------------------
/.github/workflows/check-sdist.yml:
--------------------------------------------------------------------------------
1 | name: Check that `sdist` builds and installs
2 | on: [pull_request, push]
3 |
4 | env:
5 | apt_options: -o Acquire::Retries=3
6 |
7 | jobs:
8 | build_sdist:
9 | name: Build sdist
10 | runs-on: ubuntu-latest
11 |
12 | # Run on external PRs, but not internal PRs as they'll be run by the push
13 | if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
14 |
15 | steps:
16 | - uses: actions/checkout@v4
17 | with:
18 | submodules: 'true'
19 |
20 | - name: Set up Python 3.10
21 | uses: actions/setup-python@v5
22 | with:
23 | python-version: '3.10'
24 |
25 | - name: Build a source tarball
26 | run:
27 | python setup.py sdist
28 |
29 | - name: Test tarball
30 | run: |
31 | sudo apt-get ${{env.apt_options}} update -y
32 | sudo apt-get ${{env.apt_options}} install -y libhdf5-dev
33 | pip install -r tests/requirement_tests.txt
34 | pip install dist/*
35 | pytest -s -v tests
36 |
--------------------------------------------------------------------------------
/.github/workflows/clang_format_check.yaml:
--------------------------------------------------------------------------------
1 | name: clang-format-check
2 | on: [pull_request, push]
3 |
4 | env:
5 | apt_options: -o Acquire::Retries=3
6 |
7 | jobs:
8 | build:
9 | name: clang-format-check
10 | runs-on: ubuntu-22.04
11 |
12 | # Run on external PRs, but not internal PRs as they'll be run by the push
13 | if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
14 |
15 | steps:
16 | - name: Fetch repository
17 | uses: actions/checkout@v4
18 | with:
19 | fetch-depth: 2
20 | - name: Install packages
21 | run: |
22 | sudo apt-get ${{env.apt_options}} update -y
23 | sudo apt-get ${{env.apt_options}} install -y python3-venv
24 | - name: check_clang_format
25 | run: ci/check_clang_format.sh
26 |
--------------------------------------------------------------------------------
/.github/workflows/coverage_test.yaml:
--------------------------------------------------------------------------------
1 | name: coverage-test
2 | on: [pull_request, push]
3 |
4 | env:
5 | CC: gcc-9
6 | CXX: g++-9
7 | apt_options: -o Acquire::Retries=3
8 |
9 | jobs:
10 | build:
11 | name: coverage-test
12 | runs-on: ubuntu-20.04
13 |
14 | # Run on external PRs, but not internal PRs as they'll be run by the push
15 | if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
16 |
17 | steps:
18 | - name: Checkout repository
19 | uses: actions/checkout@v4
20 | - name: Fetch repository
21 | run: git fetch --prune --unshallow
22 |
23 | - name: Get submodules
24 | run: git submodule update --init --force --recursive
25 |
26 | - name: Install packages
27 | run: |
28 | sudo apt-get ${{env.apt_options}} update -y
29 | sudo apt-get ${{env.apt_options}} install -y build-essential libhdf5-dev lcov language-pack-de
30 | - name: Build and run unittests
31 | run: |
32 | locale -a
33 | ci/coverage_test.sh
34 |
35 | - name: Upload Coverage to Coveralls
36 | uses: coverallsapp/github-action@master
37 | with:
38 | github-token: ${{ secrets.GITHUB_TOKEN }}
39 | path-to-lcov: build/build-coverage/coverage.info
40 |
--------------------------------------------------------------------------------
/.github/workflows/docstring_check.yaml:
--------------------------------------------------------------------------------
1 | name: docstring-check
2 | on: [pull_request, push]
3 |
4 | env:
5 | apt_options: -o Acquire::Retries=3
6 |
7 | jobs:
8 | build:
9 | name: docstring-check
10 | runs-on: ubuntu-20.04
11 |
12 | # Run on external PRs, but not internal PRs as they'll be run by the push
13 | if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
14 |
15 | steps:
16 | - name: Fetch repository
17 | uses: actions/checkout@v4
18 | with:
19 | submodules: recursive
20 | - name: Install packages
21 | run: |
22 | sudo apt-get ${{env.apt_options}} update -y
23 | sudo apt-get ${{env.apt_options}} install -y build-essential libhdf5-dev python3-venv libclang1-12
24 | - name: Check docstrings
25 | run: |
26 | export LIBCLANG_PATH=/usr/lib/x86_64-linux-gnu/libclang-12.so
27 | ci/check_generated_docstrings.sh || true
28 |
--------------------------------------------------------------------------------
/.github/workflows/run-tests.yml:
--------------------------------------------------------------------------------
1 | name: Run tests
2 | on: [pull_request, push]
3 |
4 | env:
5 | apt_options: -o Acquire::Retries=3
6 |
7 | jobs:
8 | build:
9 | name: Run tests on ${{ matrix.os }}.${{ matrix.compiler.CC }}
10 | runs-on: ${{ matrix.os }}
11 |
12 | # Run on external PRs, but not internal PRs as they'll be run by the push
13 | if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
14 |
15 | strategy:
16 | matrix:
17 | os: [ubuntu-latest, macos-latest]
18 | compiler:
19 | - {CC: clang, CXX: clang++}
20 | - {CC: gcc, CXX: g++}
21 | exclude:
22 | - os: macos-latest
23 | compiler: {CC: gcc, CXX: g++}
24 |
25 | steps:
26 | - name: Checkout repository
27 | uses: actions/checkout@v4
28 | with:
29 | submodules: 'true'
30 |
31 | - name: Setup python
32 | uses: actions/setup-python@v5
33 | with:
34 | python-version: '3.10'
35 |
36 | - name: Install packages on Linux
37 | if: runner.os == 'Linux'
38 | run: |
39 | sudo apt-get ${{env.apt_options}} update -y
40 | sudo apt-get ${{env.apt_options}} install -y build-essential libhdf5-dev language-pack-de
41 |
42 | - name: Install packages on MacOS
43 | if: runner.os == 'macOS'
44 | run: |
45 | # { work around https://github.com/actions/setup-python/issues/577
46 | #brew update
47 | #brew --version
48 | export HOMEBREW_NO_AUTO_UPDATE=1
49 | # }
50 | brew install cmake || true # macos image has cmake installed, but a new version may exist; ignore it if so
51 | brew install hdf5
52 |
53 | - name: Build and run unittests
54 | env:
55 | CC: ${{ matrix.compiler.CC }}
56 | CXX: ${{ matrix.compiler.CXX }}
57 | run: |
58 | locale -a
59 | ./ci/python_test.sh
60 | ./ci/cpp_test.sh
61 | ./ci/cpp_test.sh "-DMORPHIO_USE_DOUBLE=ON"
62 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Python wheels
2 | *.whl
3 |
4 | .eggs/
5 | bin/
6 | src/version.cpp
7 | morphio.egg-info/
8 | MorphIO.egg-info/
9 | .venv
10 |
11 | *.pyc
12 |
13 | # Compiled Object files
14 | *.slo
15 | *.lo
16 | *.o
17 | *.obj
18 |
19 | # Precompiled Headers
20 | *.gch
21 | *.pch
22 |
23 | # Compiled Dynamic libraries
24 | *.so
25 | *.dylib
26 | *.dll
27 |
28 | # Fortran module files
29 | *.mod
30 |
31 | # Compiled Static libraries
32 | *.lai
33 | *.la
34 | *.a
35 | *.lib
36 |
37 | # Executables
38 | *.exe
39 | *.out
40 | *.app
41 |
42 | # Custom
43 | .tags
44 | build/
45 | .*.swp
46 | *.idea
47 | ci/venv*
48 | cmake-build*
49 | env*
50 | venv-clang-format/
51 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "3rdparty/HighFive"]
2 | path = 3rdparty/HighFive
3 | url = https://github.com/BlueBrain/HighFive.git
4 | [submodule "3rdparty/pybind11"]
5 | path = binds/python/pybind11
6 | url = https://github.com/pybind/pybind11.git
7 | [submodule "3rdparty/GSL_LITE"]
8 | path = 3rdparty/GSL_LITE
9 | url = https://github.com/martinmoene/gsl-lite.git
10 | [submodule "3rdparty/lexertl14"]
11 | path = 3rdparty/lexertl14
12 | url = https://github.com/BenHanson/lexertl14
13 | [submodule "3rdparty/Catch2"]
14 | path = 3rdparty/Catch2
15 | url = https://github.com/catchorg/Catch2.git
16 | [submodule "3rdparty/ghc_filesystem"]
17 | path = 3rdparty/ghc_filesystem
18 | url = https://github.com/gulrak/filesystem.git
19 |
--------------------------------------------------------------------------------
/.readthedocs.yaml:
--------------------------------------------------------------------------------
1 | # .readthedocs.yml
2 | # Read the Docs configuration file
3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4 |
5 | # Required
6 | version: 2
7 |
8 | submodules:
9 | include: all
10 | recursive: true
11 |
12 | # it appears that the conda `cmake` finds `conda` installed packages
13 | # fine, but if cmake is installed through `pyproject.toml`, that CMake
14 | # doesn't find HDF5, if the hdf5 headers are available by the system, then
15 | # it works
16 | build:
17 | os: "ubuntu-20.04"
18 | apt_packages:
19 | - libhdf5-dev
20 | tools:
21 | python: "3.9"
22 |
23 | sphinx:
24 | configuration: doc/source/conf.py
25 |
26 | python:
27 | install:
28 | - method: pip
29 | path: .
30 | extra_requirements:
31 | - docs
32 |
--------------------------------------------------------------------------------
/3rdparty/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | find_package(HDF5 REQUIRED)
2 |
3 | if (NOT EXTERNAL_HIGHFIVE)
4 | set(HIGHFIVE_EXAMPLES OFF CACHE BOOL "" FORCE)
5 | set(HIGHFIVE_UNIT_TESTS OFF CACHE BOOL "" FORCE)
6 | set(HIGHFIVE_USE_BOOST OFF CACHE BOOL "" FORCE)
7 | set(HIGHFIVE_USE_INSTALL_DEPS ON CACHE BOOL "" FORCE)
8 | add_subdirectory(HighFive)
9 | target_include_directories(HighFive SYSTEM INTERFACE)
10 | endif()
11 |
12 | add_subdirectory(GSL_LITE)
13 | target_include_directories(gsl-lite SYSTEM INTERFACE)
14 |
15 | add_library(lexertl INTERFACE)
16 | target_include_directories(lexertl SYSTEM INTERFACE lexertl14/include)
17 |
18 | add_subdirectory(ghc_filesystem)
19 |
20 |
--------------------------------------------------------------------------------
/AUTHORS.txt:
--------------------------------------------------------------------------------
1 | Adrien Devresse
2 | Ahmet Bilgili
3 | Aleksei Sanin
4 | Alexander Dietz
5 | Alexandru Săvulescu
6 | Andrew Hale
7 | Antonio Bellotta
8 | Arseny V. Povolotsky
9 | Ben Beasley
10 | Benoît Coste
11 | Chevtchenko Grigori
12 | Cyrille Favreau
13 | Daniel Nachbaur
14 | Eleftherios Zisis
15 | Fernando Pereira
16 | Jafet Villafranca
17 | Jean-Denis Courcol
18 | Juan Hernando Vieites
19 | Matthias Wolf
20 | Mike Gevaert (maintainer)
21 | Mohamed-Ghaith Kaabi
22 | Nicolas Cornu
23 | Pablo Toharia
24 | Raphael Dumusc
25 | Snigda Dagar
26 | Stefan Eilemann
27 | Thomas Delemontex
28 | Tristan Carel
29 |
--------------------------------------------------------------------------------
/CMake/CompilerFlags.cmake:
--------------------------------------------------------------------------------
1 | if (WIN32)
2 | set(FLAGS "${FLAGS} /DH5_BUILT_AS_DYNAMIC_LIB")
3 |
4 | # Exception handling
5 | # s: Enables standard C++ stack unwinding.
6 | # c: [assume] functions declared as extern "C" never throw a C++ exception.
7 | set(FLAGS "${FLAGS} /EHsc")
8 |
9 | # get access to M_PI constant
10 | set(FLAGS "${FLAGS} /D_USE_MATH_DEFINES")
11 |
12 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
13 | # Taken from https://github.com/BlueBrain/hpc-coding-conventions/blob/master/cpp/cmake/bob.cmake#L192-L255
14 | if(${PROJECT_NAME}_CXX_WARNINGS)
15 | if(${PROJECT_NAME}_WERROR)
16 | set(FLAGS "${FLAGS} -Werror")
17 | endif()
18 | set(FLAGS "${FLAGS} -Weverything")
19 | # Using std=c++11, no need for 98 compat
20 | set(FLAGS "${FLAGS} -Wno-c++98-compat")
21 | set(FLAGS "${FLAGS} -Wno-c++98-compat-pedantic")
22 |
23 | # allow static objects
24 | set(FLAGS "${FLAGS} -Wno-global-constructors")
25 | set(FLAGS "${FLAGS} -Wno-exit-time-destructors")
26 |
27 | set(FLAGS "${FLAGS} -Wno-documentation")
28 | set(FLAGS "${FLAGS} -Wno-documentation-unknown-command")
29 |
30 | set(FLAGS "${FLAGS} -Wno-padded")
31 | set(FLAGS "${FLAGS} -Wno-weak-vtables")
32 | set(FLAGS "${FLAGS} -Wno-covered-switch-default")
33 | set(FLAGS "${FLAGS} -Wno-poison-system-directories")
34 | endif()
35 | if(APPLE)
36 | set(FLAGS "${FLAGS} -Wno-undef")
37 | if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "8.0.0")
38 | set(FLAGS "${FLAGS} -fcomment-block-commands=file")
39 | endif()
40 | else()
41 | if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "5.0.0")
42 | set(FLAGS "${FLAGS} -fcomment-block-commands=file")
43 | endif()
44 | if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.0.0")
45 | set(FLAGS "${FLAGS} -fcomment-block-commands=file")
46 | endif()
47 | endif()
48 |
49 | elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
50 | if(${PROJECT_NAME}_CXX_WARNINGS)
51 | if(${PROJECT_NAME}_WERROR)
52 | set(FLAGS "${FLAGS} -Werror")
53 | endif()
54 | set(FLAGS "${FLAGS} -Wall")
55 | set(FLAGS "${FLAGS} -Wcast-align")
56 | set(FLAGS "${FLAGS} -Wconversion")
57 | set(FLAGS "${FLAGS} -Wdouble-promotion")
58 | set(FLAGS "${FLAGS} -Wextra")
59 | set(FLAGS "${FLAGS} -Wformat=2")
60 | set(FLAGS "${FLAGS} -Wnon-virtual-dtor")
61 | set(FLAGS "${FLAGS} -Wold-style-cast")
62 | set(FLAGS "${FLAGS} -Woverloaded-virtual")
63 | set(FLAGS "${FLAGS} -Wshadow")
64 | set(FLAGS "${FLAGS} -Wsign-conversion")
65 | set(FLAGS "${FLAGS} -Wunused")
66 | set(FLAGS "${FLAGS} -Wuseless-cast")
67 | if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "6.0")
68 | set(FLAGS "${FLAGS} -Wduplicated-cond")
69 | set(FLAGS "${FLAGS} -Wmisleading-indentation")
70 | set(FLAGS "${FLAGS} -Wnull-dereference")
71 | endif()
72 | if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.0")
73 | set(FLAGS "${FLAGS} -Wduplicated-branches")
74 | set(FLAGS "${FLAGS} -Wlogical-op")
75 | set(FLAGS "${FLAGS} -Wrestrict")
76 | endif()
77 | if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "8.0")
78 | set(FLAGS "${FLAGS} -Wclass-memaccess")
79 | endif()
80 | endif()
81 | elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
82 |
83 | else()
84 | message(WARNING "Unexpected compiler type ${CMAKE_CXX_COMPILER_ID}")
85 | endif()
86 |
--------------------------------------------------------------------------------
/CMake/MorphIOConfig.cmake:
--------------------------------------------------------------------------------
1 | include(CMakeFindDependencyMacro)
2 |
3 | find_dependency(gsl-lite)
4 | find_dependency(HighFive)
5 |
6 | include("${CMAKE_CURRENT_LIST_DIR}/MorphIOTargets.cmake")
7 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.2)
2 | #allow using of HDF5_ROOT for building with a custom HDF5 version
3 | cmake_policy(SET CMP0074 NEW)
4 | project(MorphIO VERSION 2.0.0)
5 |
6 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
7 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
8 | set(CMAKE_VERBOSE_MAKEFILE ON)
9 |
10 | option(BUILD_BINDINGS "Build the python bindings" ON)
11 | option(MorphIO_CXX_WARNINGS "Compile C++ with warnings" ON)
12 | option(MorphIO_WERROR "If compiled with warnings, additionally activate '-Werror'" ON)
13 | option(EXTERNAL_CATCH2 "Use Catch2 from external source" OFF)
14 | option(EXTERNAL_HIGHFIVE "Use HighFive from external source" OFF)
15 | option(EXTERNAL_PYBIND11 "Use pybind11 from external source" OFF)
16 | option(MORPHIO_TESTS "Build tests" ON)
17 | option(MORPHIO_USE_DOUBLE "Use doubles instead of floats" OFF)
18 |
19 | if (NOT DEFINED MORPHIO_ENABLE_COVERAGE)
20 | if (CMAKE_BUILD_TYPE STREQUAL "Debug")
21 | set(MORPHIO_ENABLE_COVERAGE ON)
22 | else()
23 | set(MORPHIO_ENABLE_COVERAGE OFF)
24 | endif()
25 | endif()
26 |
27 | if(MORPHIO_USE_DOUBLE)
28 | add_definitions(-DMORPHIO_USE_DOUBLE)
29 | message("Floating Point Type: double")
30 | else()
31 | message("Floating Point Type: float")
32 | endif()
33 |
34 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake)
35 | include(CompilerFlags)
36 |
37 | set(CMAKE_CXX_FLAGS "${FLAGS}")
38 |
39 | set(CMAKE_CXX_STANDARD 14)
40 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
41 |
42 | if (EXTERNAL_HIGHFIVE)
43 | find_package(HighFive REQUIRED)
44 | endif()
45 | if (EXTERNAL_PYBIND11)
46 | find_package(pybind11 REQUIRED CONFIG)
47 | endif()
48 | set(MORPHIO_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include/)
49 |
50 | add_subdirectory(3rdparty)
51 | add_subdirectory(src)
52 |
53 | if(BUILD_BINDINGS)
54 | add_subdirectory(binds/python)
55 | endif(BUILD_BINDINGS)
56 |
57 | include(GNUInstallDirs)
58 |
59 | install(
60 | DIRECTORY ${MORPHIO_INCLUDE_DIR}
61 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
62 | )
63 |
64 | install(
65 | EXPORT MorphIOTargets
66 | NAMESPACE MorphIO::
67 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MorphIO
68 | )
69 |
70 | install(
71 | FILES ${CMAKE_CURRENT_LIST_DIR}/CMake/MorphIOConfig.cmake
72 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MorphIO
73 | )
74 |
75 |
76 | if (MORPHIO_TESTS)
77 | enable_testing()
78 | if (EXTERNAL_CATCH2)
79 | find_package(Catch2 REQUIRED)
80 | else()
81 | add_subdirectory(3rdparty/Catch2)
82 | include(3rdparty/Catch2/contrib/Catch.cmake)
83 | endif()
84 | add_subdirectory(tests)
85 | endif()
86 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | # MorphIO c++
2 | graft src
3 | graft include
4 | include CMakeLists.txt
5 |
6 | # MorphIO submodule dependencies
7 | include 3rdparty/GSL_LITE/CMakeLists.txt 3rdparty/GSL_LITE/gsl-lite.natvis
8 | recursive-include 3rdparty/GSL_LITE/cmake *
9 | recursive-include 3rdparty/GSL_LITE/include *
10 |
11 | include 3rdparty/HighFive/CMakeLists.txt
12 | recursive-include 3rdparty/HighFive/include *
13 | recursive-include 3rdparty/HighFive/CMake *
14 | recursive-include 3rdparty/HighFive/doc *
15 |
16 | include 3rdparty/lexertl14/CMakeLists.txt
17 | recursive-include 3rdparty/lexertl14/include/lexertl *
18 |
19 | # ghc::filesystem
20 | recursive-include 3rdparty/ghc_filesystem/include *
21 | recursive-include 3rdparty/ghc_filesystem/cmake *
22 | include 3rdparty/ghc_filesystem/CMakeLists.txt
23 | include 3rdparty/ghc_filesystem/LICENSE
24 |
25 | # pybind11 for python bindings
26 | recursive-include binds/python/pybind11/include *
27 | recursive-include binds/python/pybind11/tools *.cmake
28 | include binds/python/pybind11/CMakeLists.txt
29 | include binds/python/pybind11/LICENSE
30 |
31 | # setuptools_scm forces all SCM files to be packaged into sdist
32 | # we need to manually exclude them to prevent their inclusion
33 | # see https://github.com/pypa/setuptools_scm/issues/190
34 | prune ci
35 | prune doc
36 | prune tests
37 | prune scripts
38 | prune examples
39 |
40 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | .. warning::
2 | The Blue Brain Project concluded in December 2024, so development has ceased under the BlueBrain GitHub organization.
3 | Future development will take place at: https://github.com/openbraininstitute/MorphIO
4 |
5 | .. image:: doc/source/logo/BBP-MorphIO.jpg
6 |
7 |
8 | |license| |docs|
9 |
10 | MorphIO
11 | =======
12 |
13 | Documentation
14 | -------------
15 |
16 | MorphIO documentation is built and hosted on `readthedocs `_.
17 |
18 | * `latest snapshot `_
19 | * `latest release `_
20 |
21 | Introduction
22 | ------------
23 |
24 | MorphIO is a library for reading and writing neuron morphology files. It supports the following
25 | formats:
26 |
27 | * SWC
28 | * ASC (aka. neurolucida)
29 | * H5 v1
30 | * H5 v2 is not supported anymore, see `H5v2`_
31 |
32 | It provides 3 C++ classes that are the starting point of every morphology analysis:
33 |
34 | * ``Soma``: contains the information related to the soma.
35 |
36 | * ``Section``: a section is the succession of points between two bifurcations. To the bare minimum
37 | the ``Section`` object will contain the section type, the position and diameter of each point.
38 |
39 | * ``Morphology``: the morphology object contains general information about the loaded cell
40 | but also provides accessors to the different sections.
41 |
42 | One important concept is that MorphIO is split into a *read-only* part and a *read/write* one.
43 |
44 |
45 | H5v2
46 | ====
47 |
48 | Starting at version 2.6.0, the file format ``h5v2`` is no longer supported. If you have
49 | morphologies in this format, you can convert them to h5v1 with:
50 |
51 | .. code-block:: bash
52 |
53 | pip install "morphio<2.6" "morph-tool==2.3.0"
54 |
55 | and then:
56 |
57 | .. code-block:: bash
58 |
59 | # single file, OUTPUT must end with `.h5`
60 | morph-tool convert file INPUTFILE OUTPUT
61 | # bulk conversion
62 | morph-tool convert folder -ext h5 INPUTDIR OUTPUTDIR
63 |
64 |
65 | Contributing
66 | ============
67 | If you want to improve the project or you see any issue, every contribution is welcome.
68 | Please check the `contribution guidelines `_ for more
69 | information.
70 |
71 | Acknowledgements
72 | ================
73 | The development of this software was supported by funding to the Blue Brain Project, a research center of the École polytechnique fédérale de Lausanne (EPFL), from the Swiss government’s ETH Board of the Swiss Federal Institutes of Technology.
74 |
75 | This research was supported by the EBRAINS research infrastructure, funded from the European Union’s Horizon 2020 Framework Programme for Research and Innovation under the Specific Grant Agreement No. 945539 (Human Brain Project SGA3).
76 |
77 | License
78 | =======
79 | MorphIO is licensed under the terms of the Apache License 2.0.
80 | See LICENSE.txt for further details.
81 |
82 | Copyright (c) 2013-2024 Blue Brain Project/EPFL
83 |
84 | .. |license| image:: https://img.shields.io/pypi/l/morphio
85 | :target: https://github.com/BlueBrain/morphio/blob/master/COPYING.LESSER
86 |
87 | .. |docs| image:: https://readthedocs.org/projects/morphio/badge/?version=latest
88 | :target: https://morphio.readthedocs.io/
89 | :alt: documentation status
90 |
91 |
--------------------------------------------------------------------------------
/binds/python/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (NOT EXTERNAL_PYBIND11)
2 | add_subdirectory(pybind11 EXCLUDE_FROM_ALL)
3 | endif()
4 |
5 | pybind11_add_module(_morphio SYSTEM
6 | morphio.cpp
7 |
8 | bind_enums.cpp
9 | bind_immutable.cpp
10 | bind_misc.cpp
11 | bind_mutable.cpp
12 | bind_vasculature.cpp
13 | bind_warnings_exceptions.cpp
14 | bindings_utils.cpp
15 | )
16 |
17 | target_link_libraries(_morphio
18 | PRIVATE morphio_static
19 | PRIVATE pybind11::module
20 | )
21 |
--------------------------------------------------------------------------------
/binds/python/bind_enums.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2 | *
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 | #pragma once
6 |
7 | #include
8 |
9 | enum IterType { DEPTH_FIRST, BREADTH_FIRST, UPSTREAM };
10 |
11 | void bind_enums(pybind11::module&);
12 |
--------------------------------------------------------------------------------
/binds/python/bind_immutable.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2 | *
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 | #pragma once
6 |
7 | #include
8 |
9 | void bind_immutable(pybind11::module& m);
10 |
--------------------------------------------------------------------------------
/binds/python/bind_misc.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2 | *
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 | #pragma once
6 |
7 | #include
8 |
9 | void bind_misc(pybind11::module&);
10 |
--------------------------------------------------------------------------------
/binds/python/bind_mutable.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2 | *
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 | #pragma once
6 |
7 | #include
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | void bind_mutable(pybind11::module& m);
22 |
--------------------------------------------------------------------------------
/binds/python/bind_vasculature.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2 | *
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 | #pragma once
6 |
7 | #include
8 |
9 | void bind_vasculature(pybind11::module&);
10 |
--------------------------------------------------------------------------------
/binds/python/bind_warnings_exceptions.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2 | *
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 | #pragma once
6 |
7 | #include
8 |
9 | void bind_warnings_exceptions(pybind11::module&);
10 |
--------------------------------------------------------------------------------
/binds/python/bindings_utils.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2 | *
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 | #include "bindings_utils.h"
6 |
7 | #include
8 |
9 | #include // py::array_t
10 |
11 | #include
12 | #include
13 |
14 | #include // morphio::MorphioError
15 | #include
16 |
17 | namespace py = pybind11;
18 |
19 | namespace {
20 |
21 | void _raise_if_wrong_shape(const py::buffer_info& info) {
22 | const auto& shape = info.shape;
23 | if (shape.size() != 2 || info.shape[1] != 3) {
24 | std::string shape_str;
25 | for (unsigned int i = 0; i < shape.size(); ++i) {
26 | shape_str += std::to_string(shape[i]);
27 | if (i != shape.size() - 1) {
28 | shape_str += ", ";
29 | }
30 | }
31 | throw morphio::MorphioError("Wrong array shape. Expected: (X, 3), got: (" + shape_str +
32 | ")");
33 | }
34 | }
35 | } // anonymous namespace
36 |
37 | morphio::Points array_to_points(const py::array_t& buf) {
38 | py::buffer_info info = buf.request();
39 | _raise_if_wrong_shape(info);
40 | morphio::Points points;
41 | points.reserve(static_cast(info.shape[0]));
42 |
43 | for (int i = 0; i < info.shape[0]; ++i) {
44 | points.push_back({*buf.data(i, 0), *buf.data(i, 1), *buf.data(i, 2)});
45 | }
46 | return points;
47 | }
48 |
49 | py::array_t span_array_to_ndarray(
50 | const morphio::range>& span) {
51 | const void* ptr = static_cast(span.data());
52 | const auto buffer_info = py::buffer_info(
53 | // Cast from (const void*) to (void*) for function signature matching
54 | const_cast(ptr), /* Pointer to buffer */
55 | sizeof(morphio::floatType), /* Size of one scalar */
56 | py::format_descriptor::format(), /* Python struct-style format
57 | descriptor */
58 | 2, /* Number of dimensions */
59 |
60 | // Forced cast to prevent error:
61 | // template argument deduction/substitution failed */
62 | {static_cast(span.size()), 3}, /* buffer dimentions */
63 | {sizeof(morphio::floatType) * 3, /* Strides (in bytes) for each index */
64 | sizeof(morphio::floatType)});
65 | return py::array(buffer_info);
66 | }
67 |
--------------------------------------------------------------------------------
/binds/python/bindings_utils.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2 | *
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 | #pragma once
6 |
7 | #include
8 | #include
9 |
10 | #include
11 |
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 |
26 | namespace py = pybind11;
27 |
28 | morphio::Points array_to_points(const py::array_t& buf);
29 | py::array_t span_array_to_ndarray(
30 | const morphio::range& span);
31 |
32 | template
33 | py::array_t span_to_ndarray(const morphio::range& span) {
34 | const void* ptr = static_cast(span.data());
35 | const auto buffer_info = py::buffer_info(
36 | // Cast from (const void*) to (void*) for function signature matching
37 | const_cast(ptr), /* Pointer to buffer */
38 | sizeof(T), /* Size of one scalar */
39 | py::format_descriptor::format(), /* Python struct-style format descriptor */
40 | 1, /* Number of dimensions */
41 |
42 | // Forced cast to prevent error:
43 | // template argument deduction/substitution failed */
44 | {static_cast(span.size())}, /* buffer dimentions */
45 | {sizeof(T)}); /* Strides (in bytes) for each index */
46 | return py::array(buffer_info);
47 | }
48 |
49 |
50 | /**
51 | * @brief "Casts" a Cpp sequence to a python array (no memory copies)
52 | * Python capsule handles void pointers to objects and makes sure
53 | * that they will remain alive.
54 | *
55 | * https://github.com/pybind/pybind11/issues/1042#issuecomment-325941022
56 | */
57 | template
58 | inline py::array_t as_pyarray(Sequence&& seq) {
59 | // Move entire object to heap. Memory handled via Python capsule
60 | Sequence* seq_ptr = new Sequence(std::move(seq));
61 | // Capsule shall delete sequence object when done
62 | auto capsule = py::capsule(seq_ptr, [](void* p) { delete reinterpret_cast(p); });
63 |
64 | return py::array(static_cast(seq_ptr->size()), // shape of array
65 | seq_ptr->data(), // c-style contiguous strides for Sequence
66 | capsule // numpy array references this parent
67 | );
68 | }
69 |
--------------------------------------------------------------------------------
/binds/python/generated/.clang-format:
--------------------------------------------------------------------------------
1 | ---
2 | DisableFormat: true
3 | SortIncludes: false
4 | ...
5 |
--------------------------------------------------------------------------------
/binds/python/morphio.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2 | *
3 | * SPDX-License-Identifier: Apache-2.0
4 | */
5 | #include
6 |
7 | #include "bind_enums.h"
8 | #include "bind_immutable.h"
9 | #include "bind_misc.h"
10 | #include "bind_mutable.h"
11 | #include "bind_vasculature.h"
12 | #include "bind_warnings_exceptions.h"
13 |
14 |
15 | namespace py = pybind11;
16 |
17 | #if defined(__clang__)
18 | #pragma clang diagnostic push
19 | #pragma clang diagnostic ignored "-Wunknown-warning-option"
20 | #pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
21 | #endif
22 |
23 | PYBIND11_MODULE(_morphio, m) {
24 | bind_enums(m);
25 | bind_warnings_exceptions(m);
26 | bind_misc(m);
27 |
28 | bind_immutable(m);
29 |
30 | py::module mut_module = m.def_submodule("mut");
31 | bind_mutable(mut_module);
32 |
33 | py::module vasc_module = m.def_submodule("vasculature");
34 | bind_vasculature(vasc_module);
35 | }
36 |
37 | #if defined(__clang__)
38 | #pragma clang diagnostic pop
39 | #endif
40 |
--------------------------------------------------------------------------------
/ci/check_clang_format.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Install the desired clang-format, check the lines
4 | # changed by this diff are formatted correctly
5 |
6 | set -euo pipefail
7 |
8 | VENV=venv-clang-format
9 | CLANG_FORMAT_VERSION=9.0.0
10 |
11 | if [[ ! -d $VENV ]]; then
12 | python3 -mvenv "$VENV"
13 | "$VENV/bin/pip" install --upgrade pip
14 | "$VENV/bin/pip" install clang-format=="$CLANG_FORMAT_VERSION"
15 | fi
16 |
17 | set +u # ignore errors in virtualenv's activate
18 | source "$VENV/bin/activate"
19 | set -u
20 |
21 | changes=$(git-clang-format 'HEAD~1')
22 | if [[ $(echo "$changes" | grep -n1 'changed files') ]]; then
23 | echo "The following files require changes to pass the current clang-format"
24 | echo "$changes"
25 | echo "Run ./ci/check_clang_format.sh to apply the required changes to your repo"
26 | exit 1
27 | fi
28 |
--------------------------------------------------------------------------------
/ci/check_generated_docstrings.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Check the generated docstrings
4 | #
5 | # pybind11 ships with mkdoc.py which extracts python docstrings
6 | # from the C++ doxygen comments. This is beneficial for maintaining
7 | # consistency and reducing duplication.
8 | #
9 | # In order to enable morphio to be built without enforcing clang
10 | # as a dependency (required by mkdoc.py), we include the generated
11 | # docstrings in source control.
12 | #
13 | # In order to ensure they are being kept up-to-date, the CI process
14 | # regenerates them and checks there are no diffs.
15 |
16 | set -x
17 | set -euo pipefail
18 |
19 | if [[ -z $LIBCLANG_PATH ]]; then
20 | echo "Expect a \$LIBCLANG_PATH in the environment, it should have the path to the libclang.so"
21 | exit -1
22 | fi
23 |
24 |
25 | VERSION=no-reserved
26 | PACKAGE=git+https://github.com/mgeplf/pybind11_mkdoc.git@$VERSION
27 | #PACKAGE=git+https://github.com/pybind/pybind11_mkdoc.git@master
28 |
29 | VENV=build/venv-docstrings
30 | if [[ ! -d $VENV ]]; then
31 | python3 -mvenv "$VENV"
32 | $VENV/bin/pip install -U pip setuptools wheel
33 | $VENV/bin/pip install 'clang==12.0.1' # keep in sync w/ .github/workflows/docstring_check.yaml
34 | $VENV/bin/python -m pip install $PACKAGE
35 | fi
36 |
37 | DOCSTRING_PATH=./binds/python/generated/docstrings.h
38 | rm -f $DOCSTRING_PATH
39 |
40 | $VENV/bin/python -m pybind11_mkdoc \
41 | -o $DOCSTRING_PATH \
42 | -Wno-pragma-once-outside-header \
43 | -ferror-limit=100000 \
44 | -I/usr/include/hdf5/serial \
45 | -I./3rdparty/HighFive/include \
46 | -I./3rdparty/GSL_LITE/include \
47 | -I./include \
48 | ./include/morphio/mut/*.h \
49 | ./include/morphio/vasc/*.h \
50 | ./include/morphio/*.h
51 |
52 | # fail if there are diffs in the generated docstrings
53 | git diff --exit-code -- ./binds/python/generated/docstrings.h
54 |
--------------------------------------------------------------------------------
/ci/coverage_test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # This builds coverage information, including HTML output
4 |
5 | set -euxo pipefail
6 |
7 | if [ $# -ge 1 ]; then
8 | EXTRA_OPTIONS=$1
9 | else
10 | EXTRA_OPTIONS=""
11 | fi
12 |
13 | BUILD_DIR=build/build-coverage
14 |
15 | rm -rf "$BUILD_DIR"
16 | mkdir -p "$BUILD_DIR"
17 | pushd "$BUILD_DIR"
18 |
19 | cmake \
20 | -DCMAKE_BUILD_TYPE=Debug \
21 | -DHIGHFIVE_EXAMPLES=OFF \
22 | -DHIGHFIVE_UNIT_TESTS=OFF \
23 | -G"Unix Makefiles" \
24 | ${EXTRA_OPTIONS} \
25 | ../..
26 |
27 | make -j all coverage
28 |
--------------------------------------------------------------------------------
/ci/cpp_test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # This file runs the C++ tests, as well as compiling the code with warnings on
4 | # so that errors should be caught quicker. Extra options can be passed in via $1
5 | # i.e. : ./cpp_test.sh "-DMORPHIO_USE_DOUBLE=ON"
6 |
7 | set -euxo pipefail
8 |
9 | BUILD_DIR=build/cpp_test
10 |
11 | if [ $# -ge 1 ]; then
12 | EXTRA_OPTIONS=$1
13 | else
14 | EXTRA_OPTIONS=""
15 | fi
16 |
17 | rm -rf $BUILD_DIR
18 | mkdir -p $BUILD_DIR
19 | pushd $BUILD_DIR
20 | cmake -DMorphIO_CXX_WARNINGS=ON -G "${CMAKE_GENERATOR:-Unix Makefiles}" ${EXTRA_OPTIONS} ../..
21 | cmake --build . -j
22 | ctest -VV
23 | popd
24 |
--------------------------------------------------------------------------------
/ci/hdf5-build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e -x
3 |
4 | : "${UNIXY_HDF5_VERSION:=1.14.3}"
5 | : "${CIBW_ARCHS_MACOS:=$(uname -m)}"
6 |
7 | export INPUT=$(cd $(dirname "$1") && pwd -P)/$(basename "$1")
8 | export OUTPUT="$INPUT/install-$CIBW_ARCHS_MACOS"
9 |
10 |
11 | function download_unpack_hdf5 {
12 | pushd "$INPUT"
13 | local name=CMake-hdf5-$UNIXY_HDF5_VERSION.tar.gz
14 | if [[ ! -e $name ]]; then
15 | echo "Downloading & unpacking HDF5 ${UNIXY_HDF5_VERSION}"
16 | curl -fsSLO "https://hdf-wordpress-1.s3.amazonaws.com/wp-content/uploads/manual/HDF5/HDF5_${UNIXY_HDF5_VERSION//\./_}/src/$name"
17 | fi
18 | tar xzf "$name"
19 | popd
20 | }
21 |
22 | if [[ "$OSTYPE" == "darwin"* ]]; then
23 | NPROC=$(sysctl -n hw.ncpu)
24 | else
25 | NPROC=$(nproc)
26 | fi
27 |
28 | INSTALL="$OUTPUT/install"
29 |
30 | if [[ -f "$INSTALL/lib/libhdf5.a" ]]; then
31 | echo "using cached build"
32 | else
33 | if [[ "$OSTYPE" == "darwin"* ]]; then
34 | export CC="/usr/bin/clang"
35 | export CXX="/usr/bin/clang"
36 | export CFLAGS="$CFLAGS -arch $CIBW_ARCHS_MACOS"
37 | export CPPFLAGS="$CPPFLAGS -arch $CIBW_ARCHS_MACOS"
38 | export CXXFLAGS="$CXXFLAGS -arch $CIBW_ARCHS_MACOS"
39 | fi
40 |
41 | echo "Building & installing hdf5"
42 | download_unpack_hdf5
43 |
44 | cmake -B "$OUTPUT/build" -G'Unix Makefiles' \
45 | -DCMAKE_BUILD_TYPE=RelWithDebInfo \
46 | -DBUILD_SHARED_LIBS=OFF \
47 | -DHDF5_BUILD_UTILS=OFF \
48 | -DHDF5_BUILD_HL_LIB=OFF \
49 | -DHDF5_BUILD_EXAMPLES=OFF \
50 | -DBUILD_TESTING=OFF \
51 | -DHDF5_BUILD_TOOLS=OFF \
52 | -DHDF5_ENABLE_SZIP_ENCODING=OFF \
53 | -DHDF5_ENABLE_Z_LIB_SUPPORT=OFF \
54 | -DCMAKE_INSTALL_PREFIX="$INSTALL" \
55 | -S "$INPUT/CMake-hdf5-$UNIXY_HDF5_VERSION/hdf5-$UNIXY_HDF5_VERSION"
56 |
57 | cmake --build "$OUTPUT/build" -j "$NPROC"
58 | cmake --install "$OUTPUT/build"
59 | fi
60 |
61 | find "$OUTPUT"
62 |
--------------------------------------------------------------------------------
/ci/python_test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -euxo pipefail
4 |
5 | VENV=env
6 |
7 | function create_venv()
8 | {
9 | if [[ "$OSTYPE" != "msys" ]]; then
10 | rm -rf "$VENV"
11 | python3 -mvenv "$VENV"
12 |
13 | set +u # ignore errors in virtualenv's activate
14 | source "$VENV/bin/activate"
15 | set -u
16 |
17 | $VENV/bin/pip install --upgrade pip setuptools wheel
18 | fi
19 | }
20 |
21 | # in tree install
22 | create_venv
23 |
24 | $VENV/bin/pip -v install --force .
25 | $VENV/bin/pip -v install -r tests/requirement_tests.txt
26 |
27 |
28 | pushd $(pwd)/tests
29 | pytest .
30 | popd
31 |
32 | deactivate
33 |
34 | # sdist install
35 | DIST_DIR="$VENV/dist"
36 | mkdir -p "$DIST_DIR"
37 | create_venv
38 |
39 | python3 -m pip install build
40 | python3 -m build . --outdir "$DIST_DIR"
41 | python3 -m pip install "$DIST_DIR"/morphio*.tar.gz
42 | python3 -m pip install -r tests/requirement_tests.txt
43 |
44 | pushd $(pwd)/tests
45 | pytest .
46 | popd
47 |
--------------------------------------------------------------------------------
/doc/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line, and also
5 | # from the environment for the first two.
6 | SPHINXOPTS ?=
7 | SPHINXBUILD ?= sphinx-build
8 | SOURCEDIR = source
9 | BUILDDIR = build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 | # @source/build_intersphinx_objects.sh
15 |
16 | .PHONY: help Makefile
17 |
18 | # Catch-all target: route all unknown targets to Sphinx using the new
19 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
20 | %: Makefile
21 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
22 |
--------------------------------------------------------------------------------
/doc/README.md:
--------------------------------------------------------------------------------
1 | ### Local doc building
2 |
3 | For building documentation locally, make sure you have `sphinx-bluebrain-theme` and `doxygen`.
4 |
5 | ```bash
6 | pip install sphinx-bluebrain-theme
7 | ```
8 |
9 | and
10 |
11 | ```bash
12 | # for Linux
13 | sudo apt install doxygen
14 | # for MacOS
15 | brew install doxygen
16 | ```
17 |
--------------------------------------------------------------------------------
/doc/source/_templates/doxygen_page.rst_t:
--------------------------------------------------------------------------------
1 | {{ title }}
2 | {{ "=" * title | length }}
3 |
4 | .. iframe:: ../cpp/{{ file }}
5 |
--------------------------------------------------------------------------------
/doc/source/cpp.rst:
--------------------------------------------------------------------------------
1 | C++ API
2 | =======
3 |
4 | .. toctree::
5 | :hidden:
6 | :glob:
7 |
8 | cpp/**
9 |
--------------------------------------------------------------------------------
/doc/source/doxygen/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BlueBrain/MorphIO/7204ae6abdf3377188af9f778e60daf507250ca3/doc/source/doxygen/.gitignore
--------------------------------------------------------------------------------
/doc/source/footer.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |