morphoclass.transforms.node_features.extract_node_onehot_properties module

Various one-hot property node-feature extractors.

This name is misleading as what the transforms in this module extract are rather boolean features and not one-hot matrices.

class morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractIsBranching

Bases: morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractOneHotProperty

For each node determine if it’s a branching node.

extract_property(apical)

Extract boolean node features for a given apical tree.

Parameters

apical (tmd.Tree.Tree) – An apical tree.

Returns

Torch tensor of shape (n_nodes,) and dtype float32 containing the value 1.0 if the node is a branching node, otherwise 0.0.

Return type

features

class morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractIsIntermediate

Bases: morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractOneHotProperty

For each node determine if it’s an intermediate node.

An intermediate node is one that has exactly one parent and one child, i.e. a node that looks like that: –o–.

extract_property(apical)

Extract boolean node features for a given apical tree.

Parameters

apical (tmd.Tree.Tree) – An apical tree.

Returns

Torch tensor of shape (n_nodes,) and dtype float32 containing the value 1.0 if the node is an intermediate node, otherwise 0.0.

Return type

features

class morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractIsLeaf

Bases: morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractOneHotProperty

For each node determine if it’s a leaf node.

extract_property(apical)

Extract boolean node features for a given apical tree.

Parameters

apical (tmd.Tree.Tree) – An apical tree.

Returns

Torch tensor of shape (n_nodes,) and dtype float32 containing the value 1.0 if the node is a leaf node, otherwise 0.0.

Return type

features

class morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractIsRoot

Bases: morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractOneHotProperty

For each node determine if it’s the root node.

extract_property(apical)

Extract boolean node features for a given apical tree.

Parameters

apical (tmd.Tree.Tree) – An apical tree.

Returns

Torch tensor of shape (n_nodes,) and dtype float32 containing the value 1.0 if the node is a root node, otherwise 0.0.

Return type

features

class morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractOneHotProperty

Bases: abc.ABC

Base class for boolean node feature extractors.

The name of this class is misleading and should be changed to reflect that the extracted features are not one-hot encoded but are boolean values (encoded as 0.0 and 1.0 float values).

abstract extract_property(apical)

Extract boolean node features for a given apical tree.

Parameters

apical (tmd.Tree.Tree) – An apical tree.

Returns

Torch tensor of shape (n_nodes,) and dtype float32 containing values 0.0 and 1.0.

Return type

features