OpenWalnut
1.5.0dev
|
this class implements methods for dendrogram processing, such as pruning, node collapsing and decimation it operates over the class WHtree. More...
#include <WHtreeProcesser.h>
Public Member Functions | |
WHtreeProcesser (WHtree *const tree) | |
Constructor. More... | |
~WHtreeProcesser () | |
Destructor. More... | |
std::pair< size_t, size_t > | pruneTree (float condition, size_t safeSize, const HTPROC_MODE pruneType) |
Prunes the tree according to the options specified. More... | |
std::pair< size_t, size_t > | pruneRandom (const size_t numberPruned, unsigned int seed=0) |
Prunes the tree from randomly chosen leaves. More... | |
size_t | collapseTree (const dist_t flatGap, const dist_t distLevelLimit, const bool keepBaseNodes) |
Collapses the nodes of the tree that have branch lenghts equal or lower to the one indicated. More... | |
size_t | collapseTreeLinear (const dist_t coefficient, const bool keepBaseNodes) |
Collapses the nodes of the tree that have branch lenghts smoller than the distance level multiplied by the coefficient indicated. More... | |
size_t | collapseTreeSquare (const dist_t coefficient, const bool keepBaseNodes) |
Collapses the nodes of the tree that have branch lenghts smoller than the squared distance level multiplied by the coefficient indicated. More... | |
size_t | collapseBranch (const dist_t flatGap, const dist_t distLevelLimit, size_t root, const bool keepBaseNodes) |
Collapses the nodes of the subtree that have branch lenghts equal or lower to the one indicated. More... | |
size_t | flattenSelection (const std::list< size_t > selection, const bool keepBaseNodes) |
Collapses all the nodes of the subtrees indicated (using only non-leaf node ID) More... | |
size_t | flattenSelection (const std::vector< size_t > &selection, const bool keepBaseNodes) |
Collapses all the nodes of the subtrees indicated (using only non-leaf node ID) More... | |
size_t | flattenSelection (const std::vector< nodeID_t > &selection, const bool keepBaseNodes) |
Collapses all the nodes of the subtrees indicated (using full boolean-integer node ID) More... | |
std::pair< size_t, size_t > | pruneSelection (const std::vector< size_t > &selection) |
Prunes all of the subtrees indicated (using only non-leaf node ID) More... | |
std::pair< size_t, size_t > | pruneSelection (const std::vector< nodeID_t > &selection) |
Prunes all of the subtrees indicated (using full boolean-integer node ID) More... | |
void | flagSelection (const std::vector< size_t > &selection) |
set flags for pruning all of the subtrees indicated (using only non-leaf node ID) More... | |
void | flagSelection (const std::vector< nodeID_t > &selection) |
set flags for pruning all of the subtrees indicated (using full boolean-integer node ID) More... | |
void | flagLeaves (const std::vector< size_t > &selection) |
set flags for pruning all of the leaves indicated More... | |
void | coarseTree (const unsigned int coarseRatio) |
Reduces the tree grid size by the ratio specified (as if it had been obtained from an image of lower resolution) More... | |
size_t | baseNodes2Leaves () |
converts the base nodes into leaves, pruning out all excess leaves and information More... | |
void | forceMonotonicity (double errorMult=1) |
calls on private WHtree member to eliminate non monotonic steps in the tree while keeping as much information as possible. More... | |
void | forceMonotonicityUp () |
calls on private WHtree member to eliminate non monotonic steps in the tree bottom-up, lowering the level of children involved in the non-monotonic steps to the parent level More... | |
void | forceMonotonicityDown () |
calls on private WHtree member to eliminate non monotonic steps in the tree top-down, raising the level of parents involved in the non-monotonic steps to the children level More... | |
size_t | debinarize (const bool keepBaseNodes) |
calls on private WHtree member to merge nodes joining binary at the same level into non-binary structures More... | |
Private Member Functions | |
size_t | flattenBranch (size_t root, const bool keepBaseNodes) |
Collapses all the nodes of the subtree. More... | |
void | collapseNode (const size_t thisNodeID, const dist_t coefficient, HTPROC_COLLAPSE collapseMode=HTPR_C_CONSTANT) |
eliminates branchings in the tree, raising them to the parent level More... | |
void | collapseNode (const nodeID_t &thisNodeID, const dist_t coefficient, HTPROC_COLLAPSE collapseMode=HTPR_C_CONSTANT) |
eliminates non monotonic steps in the tree, raising them to the parent level More... | |
Private Attributes | |
WHtree & | m_tree |
tree object More... | |
this class implements methods for dendrogram processing, such as pruning, node collapsing and decimation it operates over the class WHtree.
As a result of its operations the tree structure is changed and previous structure cannot be recovered unless a class copy is previously made.
Definition at line 83 of file WHtreeProcesser.h.
|
explicit |
Constructor.
tree | a pointer to the tree to be processed |
Definition at line 60 of file WHtreeProcesser.cpp.
WHtreeProcesser::~WHtreeProcesser | ( | ) |
Destructor.
Definition at line 64 of file WHtreeProcesser.cpp.
size_t WHtreeProcesser::baseNodes2Leaves | ( | ) |
converts the base nodes into leaves, pruning out all excess leaves and information
Definition at line 505 of file WHtreeProcesser.cpp.
References WHtree::cleanup(), WHtree::fetchLeaf(), WHtree::getLeaves4node(), WHtree::getNumLeaves(), WHtree::getRootBaseNodes(), m_tree, WHtree::m_treeName, WHnode::setFlag(), and WHtree::testRootBaseNodes().
void WHtreeProcesser::coarseTree | ( | const unsigned int | coarseRatio | ) |
Reduces the tree grid size by the ratio specified (as if it had been obtained from an image of lower resolution)
coarseRatio | coarsing ratio |
Definition at line 410 of file WHtreeProcesser.cpp.
References WHtree::cleanup(), WHtree::debinarize(), WHtree::fetchLeaf(), WHtree::m_coordinates, WHtree::m_datasetSize, WHtree::m_discarded, m_tree, WHtree::m_treeName, WHcoord::m_x, WHcoord::m_y, WHcoord::m_z, WHnode::setFlag(), and string_utils::toString().
size_t WHtreeProcesser::collapseBranch | ( | const dist_t | flatGap, |
const dist_t | distLevelLimit, | ||
size_t | root, | ||
const bool | keepBaseNodes | ||
) |
Collapses the nodes of the subtree that have branch lenghts equal or lower to the one indicated.
flatGap | branch lenght limit to be collapsed |
distLevelLimit | distance level under which no collapsing will take place |
root | root node of the subtree |
keepBaseNodes | flag to avoid collapsing base nodes (those that have only single-leaf children) |
Definition at line 350 of file WHtreeProcesser.cpp.
References collapseNode(), WHtree::debinarize(), WHtree::getBranchNodes(), WHnode::getDistLevel(), WHtree::getNode(), and m_tree.
|
private |
eliminates non monotonic steps in the tree, raising them to the parent level
thisNodeID | id of the sub-branch node where to start the flatteing |
coefficient | coefficient for collapsing depending on distance level |
collapseMode | collapsing mode |
Definition at line 661 of file WHtreeProcesser.cpp.
References collapseNode().
|
private |
eliminates branchings in the tree, raising them to the parent level
thisNodeID | id of the sub-branch node where to start the flatteing |
coefficient | coefficient for collapsing depending on distance level |
collapseMode | collapsing mode |
Definition at line 674 of file WHtreeProcesser.cpp.
References WHtree::fetchNode(), WHnode::getChildren(), WHnode::getDistLevel(), WHnode::getFullID(), WHnode::getID(), WHtree::getNode(), WHtree::getRoot(), WHnode::isNode(), m_tree, and WHnode::setDistLevel().
Referenced by collapseBranch(), collapseNode(), collapseTree(), collapseTreeLinear(), collapseTreeSquare(), and flattenBranch().
size_t WHtreeProcesser::collapseTree | ( | const dist_t | flatGap, |
const dist_t | distLevelLimit, | ||
const bool | keepBaseNodes | ||
) |
Collapses the nodes of the tree that have branch lenghts equal or lower to the one indicated.
flatGap | branch lenght limit to be collapsed |
distLevelLimit | distance level under which no collapsing will take place |
keepBaseNodes | flag to avoid collapsing base nodes (those that have only single-leaf children) |
Definition at line 273 of file WHtreeProcesser.cpp.
References collapseNode(), WHtree::debinarize(), WHtree::forceMonotonicityDown(), WHnode::getDistLevel(), WHnode::getID(), WHtree::getNode(), WHtree::getRoot(), m_tree, and WHtree::m_treeName.
size_t WHtreeProcesser::collapseTreeLinear | ( | const dist_t | coefficient, |
const bool | keepBaseNodes | ||
) |
Collapses the nodes of the tree that have branch lenghts smoller than the distance level multiplied by the coefficient indicated.
coefficient | coefficient for collapsing depending on distance level |
keepBaseNodes | flag to avoid collapsing base nodes (those that have only single-leaf children) |
Definition at line 303 of file WHtreeProcesser.cpp.
References collapseNode(), WHtree::debinarize(), WHnode::getID(), WHtree::getRoot(), m_tree, and WHtree::m_treeName.
Referenced by WMHierchClustDisplay::moduleMain().
size_t WHtreeProcesser::collapseTreeSquare | ( | const dist_t | coefficient, |
const bool | keepBaseNodes | ||
) |
Collapses the nodes of the tree that have branch lenghts smoller than the squared distance level multiplied by the coefficient indicated.
coefficient | coefficient for collapsing depending on distance level |
keepBaseNodes | flag to avoid collapsing base nodes (those that have only single-leaf children) |
Definition at line 326 of file WHtreeProcesser.cpp.
References collapseNode(), WHtree::debinarize(), WHnode::getID(), WHtree::getRoot(), m_tree, and WHtree::m_treeName.
size_t WHtreeProcesser::debinarize | ( | const bool | keepBaseNodes | ) |
calls on private WHtree member to merge nodes joining binary at the same level into non-binary structures
keepBaseNodes | if set base nodes ( nodes with only single leaves as children) will not be merged |
Definition at line 549 of file WHtreeProcesser.cpp.
References WHtree::debinarize(), and m_tree.
void WHtreeProcesser::flagLeaves | ( | const std::vector< size_t > & | selection | ) |
set flags for pruning all of the leaves indicated
selection | vector with the leaves to be pruned |
Definition at line 650 of file WHtreeProcesser.cpp.
References WHtree::fetchLeaf(), m_tree, and WHnode::setFlag().
Referenced by flagSelection().
void WHtreeProcesser::flagSelection | ( | const std::vector< nodeID_t > & | selection | ) |
set flags for pruning all of the subtrees indicated (using full boolean-integer node ID)
selection | vector with the nodes to be pruned |
Definition at line 641 of file WHtreeProcesser.cpp.
References flagLeaves(), WHtree::getLeaves4node(), and m_tree.
void WHtreeProcesser::flagSelection | ( | const std::vector< size_t > & | selection | ) |
set flags for pruning all of the subtrees indicated (using only non-leaf node ID)
selection | vector with the nodes to be pruned |
Definition at line 632 of file WHtreeProcesser.cpp.
References flagLeaves(), WHtree::getLeaves4node(), and m_tree.
Referenced by pruneSelection().
|
private |
Collapses all the nodes of the subtree.
root | root node of the subtree |
keepBaseNodes | if set base nodes ( nodes with only single leaves as children) will not be merged |
Definition at line 557 of file WHtreeProcesser.cpp.
References collapseNode(), WHtree::debinarize(), and m_tree.
size_t WHtreeProcesser::flattenSelection | ( | const std::list< size_t > | selection, |
const bool | keepBaseNodes | ||
) |
Collapses all the nodes of the subtrees indicated (using only non-leaf node ID)
selection | list with the root nodes of the subtree |
keepBaseNodes | flag to avoid collapsing base nodes (those that have only single-leaf children) |
Definition at line 567 of file WHtreeProcesser.cpp.
References WHtree::cleanup(), WHtree::fetchNode(), WHnode::getChildren(), WHnode::getHLevel(), WHtree::getNode(), m_tree, WHnode::setFlag(), and WHtree::testRootBaseNodes().
Referenced by flattenSelection(), and WMHierchClustDisplay::moduleMain().
size_t WHtreeProcesser::flattenSelection | ( | const std::vector< nodeID_t > & | selection, |
const bool | keepBaseNodes | ||
) |
Collapses all the nodes of the subtrees indicated (using full boolean-integer node ID)
selection | vector with the root nodes of the subtree |
keepBaseNodes | flag to avoid collapsing base nodes (those that have only single-leaf children) |
Definition at line 605 of file WHtreeProcesser.cpp.
References flattenSelection().
size_t WHtreeProcesser::flattenSelection | ( | const std::vector< size_t > & | selection, |
const bool | keepBaseNodes | ||
) |
Collapses all the nodes of the subtrees indicated (using only non-leaf node ID)
selection | vector with the root nodes of the subtree |
keepBaseNodes | flag to avoid collapsing base nodes (those that have only single-leaf children) |
Definition at line 600 of file WHtreeProcesser.cpp.
References flattenSelection().
void WHtreeProcesser::forceMonotonicity | ( | double | errorMult = 1 | ) |
calls on private WHtree member to eliminate non monotonic steps in the tree while keeping as much information as possible.
it searches bottom-up for non-monotonic steps. When detected a corrected value for the parent node is computed this value consists of a average between the non-monotonic children levels weighted by their sizes in number of leaves and the parent level weighted by the sizes of the remaining monotonic children in orther to avoid infinite loops an error tolerance is included. default value is 1*E-5
errorMult | multiplier to increase the base error tolerance (default value is 1 makign the tolerance 1*E-5, maximum value is 100 making the tolerance 1*E-3) |
Definition at line 543 of file WHtreeProcesser.cpp.
References WHtree::forceMonotonicity(), and m_tree.
void WHtreeProcesser::forceMonotonicityDown | ( | ) |
calls on private WHtree member to eliminate non monotonic steps in the tree top-down, raising the level of parents involved in the non-monotonic steps to the children level
Definition at line 537 of file WHtreeProcesser.cpp.
References WHtree::forceMonotonicityDown(), and m_tree.
void WHtreeProcesser::forceMonotonicityUp | ( | ) |
calls on private WHtree member to eliminate non monotonic steps in the tree bottom-up, lowering the level of children involved in the non-monotonic steps to the parent level
Definition at line 531 of file WHtreeProcesser.cpp.
References WHtree::forceMonotonicityUp(), and m_tree.
std::pair< size_t, size_t > WHtreeProcesser::pruneRandom | ( | const size_t | numberPruned, |
unsigned int | seed = 0 |
||
) |
Prunes the tree from randomly chosen leaves.
numberPruned | number of leaves to be pruned |
seed | seed for the random number generator to choose the leaves to be pruned |
Definition at line 235 of file WHtreeProcesser.cpp.
References WHtree::cleanup(), WHtree::debinarize(), WHtree::fetchLeaf(), WHtree::getNumLeaves(), WHnode::isFlagged(), m_tree, WHtree::m_treeName, WHnode::setFlag(), and string_utils::toString().
Referenced by WMHierchClustDisplay::moduleMain().
std::pair< size_t, size_t > WHtreeProcesser::pruneSelection | ( | const std::vector< nodeID_t > & | selection | ) |
Prunes all of the subtrees indicated (using full boolean-integer node ID)
selection | vector with the nodes to be pruned |
Definition at line 625 of file WHtreeProcesser.cpp.
References WHtree::cleanup(), flagSelection(), and m_tree.
std::pair< size_t, size_t > WHtreeProcesser::pruneSelection | ( | const std::vector< size_t > & | selection | ) |
Prunes all of the subtrees indicated (using only non-leaf node ID)
selection | vector with the nodes to be pruned |
Definition at line 619 of file WHtreeProcesser.cpp.
References WHtree::cleanup(), flagSelection(), and m_tree.
Referenced by WMHierchClustDisplay::moduleMain().
std::pair< size_t, size_t > WHtreeProcesser::pruneTree | ( | float | condition, |
size_t | safeSize, | ||
const HTPROC_MODE | pruneType | ||
) |
Prunes the tree according to the options specified.
condition | value of the condition to choose when pruning (size of joining cluster, size ratio or joining level) |
safeSize | maximum size that a cluster can have in order to be pruned, bigger clusters wont be prune regardless of the condition |
pruneType | type of pruning method (max size, maxlevel, sizeratio) |
Definition at line 72 of file WHtreeProcesser.cpp.
References WHtree::cleanup(), WHtree::debinarize(), WHtree::fetchNode(), WHnode::getChildren(), WHnode::getDistLevel(), WHtree::getNode(), WHtree::getNumLeaves(), WHnode::getSize(), WHnode::isFlagged(), WHtree::m_leaves, WHtree::m_nodes, m_tree, WHtree::m_treeName, WHnode::setFlag(), and string_utils::toString().
Referenced by WMHierchClustDisplay::moduleMain().
|
private |
tree object
Definition at line 255 of file WHtreeProcesser.h.
Referenced by baseNodes2Leaves(), coarseTree(), collapseBranch(), collapseNode(), collapseTree(), collapseTreeLinear(), collapseTreeSquare(), debinarize(), flagLeaves(), flagSelection(), flattenBranch(), flattenSelection(), forceMonotonicity(), forceMonotonicityDown(), forceMonotonicityUp(), pruneRandom(), pruneSelection(), and pruneTree().