-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify loading of Standard Morphology Files. (#2218)
All morphology loaders now return a `loaded_morphology` object comprising - `morphology`: the morphology corresponding to the data on disk - `segment_tree`: the raw segment tree - `label_dict`: all labels defined in the file - `asc`/`swc`: `axon`, `soma`, `dend`, and `apic` based on tag 1, 2, 3, 4. - `nml`: the union of the label dicts contained in the metadata, prefixed by `grp:`, `nmd:`, and `seg:`. - `metadata`: a set of items given by the fileformat - `swc`: nothing - `asc`: a list of spines and marker sets - `nml`: - `named_segments` a label dict - `segment_groups` a label dict `name` -> segment ids - `group_segments` a map from segment id to group name(s) - `segments` a label dict, one entry per id - `cell_id` id of the cell defining this morphology, if any - `id` id of the morphology Note that loading neuroml still goes via the `neuroml` object and the `cell_morphology`/`morphology` accessors return an optional `loaded_morphology`. ##⚠️ Breaking⚠️ - Removed the `load_*_raw` functions, as `loaded_morphology` bundles the segment tree. - The interface of `load_*` now has an extra indirection. - The interface of `neuroml` changed. - `label_dict::import` is now called `extend` for future safety (=C++ modules) and Python; calling things `import` (=a keyword) is not well received by `black` et al. ## Issues Closes #1981
- Loading branch information
1 parent
ed67763
commit 08a157f
Showing
42 changed files
with
826 additions
and
458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#pragma once | ||
|
||
#include <variant> | ||
|
||
#include <arborio/export.hpp> | ||
|
||
#include <arbor/morph/label_dict.hpp> | ||
#include <arbor/morph/morphology.hpp> | ||
#include <arbor/morph/segment_tree.hpp> | ||
|
||
namespace arborio { | ||
|
||
struct ARB_ARBORIO_API swc_metadata {}; | ||
|
||
struct ARB_ARBORIO_API asc_color { | ||
uint8_t r = 0; | ||
uint8_t g = 0; | ||
uint8_t b = 0; | ||
}; | ||
|
||
struct ARB_ARBORIO_API asc_spine { | ||
std::string name; | ||
arb::mpoint location; | ||
}; | ||
|
||
enum ARB_ARBORIO_API asc_marker { dot, circle, cross, none }; | ||
|
||
struct ARB_ARBORIO_API asc_marker_set { | ||
asc_color color; | ||
asc_marker marker = asc_marker::none; | ||
std::string name; | ||
std::vector<arb::mpoint> locations; | ||
}; | ||
|
||
struct ARB_ARBORIO_API asc_metadata { | ||
std::vector<asc_marker_set> markers; | ||
std::vector<asc_spine> spines; | ||
}; | ||
|
||
// Bundle some detailed metadata for neuroml ingestion. | ||
struct ARB_SYMBOL_VISIBLE nml_metadata { | ||
// Cell id, or empty if morphology was taken from a top-level <morphology> element. | ||
std::optional<std::string> cell_id; | ||
|
||
// Morphology id. | ||
std::string id; | ||
|
||
// One region expression for each segment id. | ||
arb::label_dict segments; | ||
|
||
// One region expression for each name applied to one or more segments. | ||
arb::label_dict named_segments; | ||
|
||
// One region expression for each segmentGroup id. | ||
arb::label_dict groups; | ||
|
||
// Map from segmentGroup ids to their corresponding segment ids. | ||
std::unordered_map<std::string, std::vector<unsigned long long>> group_segments; | ||
}; | ||
|
||
// Interface for ingesting morphology data | ||
struct ARB_ARBORIO_API loaded_morphology { | ||
// Raw segment tree, identical to morphology. | ||
arb::segment_tree segment_tree; | ||
|
||
// Morphology constructed from description. | ||
arb::morphology morphology; | ||
|
||
// Regions and locsets defined in the description. | ||
arb::label_dict labels; | ||
|
||
// Loader specific metadata | ||
std::variant<swc_metadata, asc_metadata, nml_metadata> metadata; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.