10 #include <unordered_map>
13 #include <morphio/errorMessages.h>
14 #include <morphio/exceptions.h>
15 #include <morphio/mut/endoplasmic_reticulum.h>
16 #include <morphio/mut/mitochondria.h>
17 #include <morphio/mut/modifiers.h>
18 #include <morphio/mut/section.h>
19 #include <morphio/mut/soma.h>
20 #include <morphio/properties.h>
21 #include <morphio/types.h>
22 #include <morphio/warning_handling.h>
28 bool _checkDuplicatePoint(
const std::shared_ptr<Section>& parent,
29 const std::shared_ptr<Section>& current);
35 Morphology(std::shared_ptr<WarningHandler> warning_handler =
nullptr)
36 : _soma(std::make_shared<Soma>())
37 , _cellProperties(std::make_shared<Property::CellLevel>())
38 , _handler(warning_handler ? warning_handler : morphio::getWarningHandler()) {}
51 std::shared_ptr<WarningHandler> warning_handler =
nullptr);
54 explicit Morphology(
const HighFive::Group& group,
56 std::shared_ptr<WarningHandler> warning_handler =
nullptr);
61 std::shared_ptr<WarningHandler> warning_handler =
nullptr);
66 std::shared_ptr<WarningHandler> warning_handler =
nullptr);
71 const std::vector<std::shared_ptr<Section>>&
rootSections() const noexcept {
76 const std::map<uint32_t, std::shared_ptr<Section>>&
sections() const noexcept {
85 std::shared_ptr<Soma>&
soma() noexcept {
94 const std::shared_ptr<Soma>&
soma() const noexcept {
100 return _mitochondria;
105 return _mitochondria;
110 return _endoplasmicReticulum;
115 return _endoplasmicReticulum;
119 const std::vector<Property::Annotation>&
annotations() const noexcept {
120 return _cellProperties->_annotations;
124 const std::vector<Property::Marker>&
markers() const noexcept {
125 return _cellProperties->_markers;
133 const std::shared_ptr<Section>&
section(uint32_t
id)
const {
134 return _sections.at(
id);
177 bool recursive =
false);
183 void applyModifiers(
unsigned int modifierFlags);
187 return _soma->type();
192 return _cellProperties->_cellFamily;
197 return _cellProperties->_version;
201 void write(
const std::string& filename)
const;
204 _cellProperties->_annotations.push_back(annotation);
208 _cellProperties->_markers.push_back(marker);
219 std::unordered_map<int, std::vector<unsigned int>>
connectivity();
227 std::shared_ptr<WarningHandler> getWarningHandler()
const {
231 std::shared_ptr<Soma> _soma;
232 std::shared_ptr<Property::CellLevel> _cellProperties;
233 EndoplasmicReticulum _endoplasmicReticulum;
234 Property::DendriticSpine::Level _dendriticSpineLevel;
237 std::vector<std::shared_ptr<Section>> _rootSections;
238 std::map<uint32_t, std::shared_ptr<Section>> _sections;
240 Mitochondria _mitochondria;
242 std::map<uint32_t, uint32_t> _parent;
243 std::map<uint32_t, std::vector<std::shared_ptr<Section>>> _children;
245 uint32_t _counter = 0;
247 uint32_t _register(
const std::shared_ptr<Section>&);
249 void eraseByValue(std::vector<std::shared_ptr<Section>>& vec,
250 const std::shared_ptr<Section>&
section);
252 std::shared_ptr<WarningHandler> _handler;
255 friend class Section;
256 friend void modifiers::nrn_order(mut::Morphology& morpho);
257 friend bool diff(
const Morphology& left,
const Morphology& right, enums::LogLevel verbose);
const Mitochondria & mitochondria() const noexcept
Return the mitochondria container class.
Definition: morphology.h:104
SomaType
Definition: enums.h:61
Definition: section_iterators.hpp:82
SectionType
Definition: enums.h:71
const std::map< uint32_t, std::shared_ptr< Section > > & sections() const noexcept
Returns the dictionary id -> Section for this tree.
Definition: morphology.h:76
SomaType somaType() const noexcept
Return the soma type.
Definition: morphology.h:186
const EndoplasmicReticulum & endoplasmicReticulum() const noexcept
Return the endoplasmic reticulum container class.
Definition: morphology.h:114
@ NO_MODIFIER
Read morphology as is without any modification.
Definition: enums.h:18
Definition: morphology.h:26
depth_iterator depth_begin() const
Definition: properties.h:152
const std::shared_ptr< Soma > & soma() const noexcept
Definition: morphology.h:94
Definition: endoplasmic_reticulum.h:13
const std::vector< Property::Marker > & markers() const noexcept
Return the markers from the ASC file.
Definition: morphology.h:124
void deleteSection(std::shared_ptr< Section > section, bool recursive=true)
CellFamily
Definition: enums.h:54
CellFamily cellFamily() const noexcept
Return the cell family (neuron or glia)
Definition: morphology.h:191
const std::vector< std::shared_ptr< Section > > & rootSections() const noexcept
Returns all section ids at the tree root.
Definition: morphology.h:71
const std::shared_ptr< Section > & section(uint32_t id) const
Definition: morphology.h:133
Definition: properties.h:176
MorphologyVersion version() const noexcept
Return the version.
Definition: morphology.h:196
Definition: mitochondria.h:25
Mitochondria & mitochondria() noexcept
Return the mitochondria container class.
Definition: morphology.h:99
EndoplasmicReticulum & endoplasmicReticulum() noexcept
Return the endoplasmic reticulum container class.
Definition: morphology.h:109
void removeUnifurcations()
Property::Properties buildReadOnly() const
Return the data structure used to create read-only morphologies.
Definition: section_iterators.hpp:53
const std::vector< Property::Annotation > & annotations() const noexcept
Return the annotation objects.
Definition: morphology.h:119
void write(const std::string &filename) const
Write file to H5, SWC, ASC format depending on filename extension.
std::unordered_map< int, std::vector< unsigned int > > connectivity()
Definition: morphology.h:32
breadth_iterator breadth_begin() const
std::shared_ptr< Section > appendRootSection(const morphio::Section &, bool recursive=false)
std::shared_ptr< Soma > & soma() noexcept
Definition: morphology.h:85
Definition: properties.h:62