morphoclass.transforms.node_features package¶
Submodules¶
- morphoclass.transforms.node_features.extract_branching_angles module
- morphoclass.transforms.node_features.extract_const_feature module
- morphoclass.transforms.node_features.extract_coordinates module
- morphoclass.transforms.node_features.extract_diameters module
- morphoclass.transforms.node_features.extract_distances module
- morphoclass.transforms.node_features.extract_node_features module
- morphoclass.transforms.node_features.extract_node_onehot_properties module
- morphoclass.transforms.node_features.extract_path_distances module
- morphoclass.transforms.node_features.extract_radial_distances module
- morphoclass.transforms.node_features.extract_vertical_distances module
Module contents¶
Node feature extractors.
All transforms in this submodule should modify the data.x attribute
-
class
morphoclass.transforms.node_features.ExtractBranchingAngles(non_branching_angle=0.0)¶ Bases:
objectExtract branching angles from neurites trees.
The data should contain the field tmd_neurites, see the ExtractTMDNeurites class.
For each apical tree in the neuron the branching angles of all node points of the morphology are extracted and added to the feature vector. For points without a branching (root, leaf, and intermediate nodes) the angle is set a fixed value (default: 0.0)
- Parameters
non_branching_angle (float (optional)) – The default angle value for non-branching nodes.
-
class
morphoclass.transforms.node_features.ExtractConstFeature¶ Bases:
morphoclass.transforms.node_features.extract_node_features.ExtractNodeFeaturesExtractor that assigns the constant feature value 1.0 to each node.
-
extract_node_features(data)¶ Extract the constant node feature value 1.0 for each node.
- Parameters
data – A data sample
- Returns
Torch tensor of shape (n_nodes,)
- Return type
features
-
-
class
morphoclass.transforms.node_features.ExtractCoordinates(shift_to_origin=True)¶ Bases:
objectExtract coordinate features from neurites trees.
The data should contain the field tmd_neurites, see the ExtractTMDNeurites class.
For each apical tree in the neuron the coordinates of all node points of the morphology are extracted and added to the feature vector.
- Parameters
shift_to_origin (bool (optional)) – If true then all coordinates will be shifted so that the root of the given apical tree is at the origin.
-
class
morphoclass.transforms.node_features.ExtractDiameters¶ Bases:
morphoclass.transforms.node_features.extract_node_features.ExtractNodeFeaturesExtract the diameter value attached to each node.
-
extract_node_features(data)¶ Extract the diameter node features from data.
- Parameters
data – A data sample
- Returns
Torch tensor of shape (n_nodes,)
- Return type
features
-
-
class
morphoclass.transforms.node_features.ExtractDistances(vertical_axis='y', negative_ipcs=False, negative_bpcs=False)¶ Bases:
objectExtract some distance features from apical trees.
The data should contain the field tmd_neuron, see the ExtractTMDNeuron class.
This is an abstract class. Sub-classes of this class should implement get_distance(apical) to implement concrete distance extraction from the apical tree.
- Parameters
vertical_axis (str) – The name of the axis along which the neurons are vertically oriented. In other words, the axis that is perpendicular to the cortex surface. This is only relevant for BPCs and is only considered if the parameter negative_bpcs is true, in which case the projection of the two apicals onto this axis decides which one of the two is lower than the other one.
negative_ipcs (bool) – If true then the distance features of all cells labelled as IPCs will have their sign inverted (feature => -feature).
negative_bpcs (bool) – If true then all cells labelled as BPCs will have their lower apical’s distance features inverted by flipping their sign. (feature => -feature). To determine which of the two apicals is lower the node positions are projected onto the axis specified in vertical_axis.
-
get_distances(apical)¶ Extract the node distance feature from an apical tree.
- Parameters
apical (tmd.Tree.Tree) – An apical tree.
- Returns
A torch tensor of shape (n_nodes,) and of dtype float32 with the extracted node distance features.
- Return type
torch.tensor
-
class
morphoclass.transforms.node_features.ExtractIsBranching¶ Bases:
morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractOneHotPropertyFor 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.ExtractIsIntermediate¶ Bases:
morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractOneHotPropertyFor 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.ExtractIsLeaf¶ Bases:
morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractOneHotPropertyFor 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.ExtractIsRoot¶ Bases:
morphoclass.transforms.node_features.extract_node_onehot_properties.ExtractOneHotPropertyFor 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.ExtractNodeFeatures¶ Bases:
abc.ABCAbstract base class for arbitrary node feature extraction.
-
abstract
extract_node_features(data)¶ Extract some node features from data.
- Parameters
data – A data sample
- Returns
Torch tensor of shape (n_nodes, n_features)
- Return type
features
-
abstract
-
class
morphoclass.transforms.node_features.ExtractOneHotProperty¶ Bases:
abc.ABCBase 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
-
abstract
-
class
morphoclass.transforms.node_features.ExtractPathDistances(negative_ipcs=False, negative_bpcs=False)¶ Bases:
morphoclass.transforms.node_features.extract_distances.ExtractDistancesExtract path distance features from apical trees.
The data should contain the field tmd_neuron, see the ExtractTMDNeuron class.
For each apical tree in the neuron the path distance of all node points of the morphology are extracted and added to the feature vector.
The path distance of a given node is the distance to the root point of the tree that is measured by following the graph edges.
- Parameters
negative_ipcs (bool) – Invert sign for features of IPCs. ee documentation of the ExtractDistances base class for more details.
negative_bpcs (bool) – Invert sign for features of lower apical trees of BPCs. ee documentation of the ExtractDistances base class for more details.
-
get_distances(apical)¶ Extract the node distance feature from an apical tree.
This is an implementation of the base class’s abstract method.
- Parameters
apical (tmd.Tree.Tree) – An apical tree.
- Returns
A torch tensor of shape (n_nodes,) and of dtype float32 with the extracted node distance features.
- Return type
torch.tensor
-
class
morphoclass.transforms.node_features.ExtractRadialDistances(negative_ipcs=False, negative_bpcs=False)¶ Bases:
morphoclass.transforms.node_features.extract_distances.ExtractDistancesExtract radial distance features from apical trees.
The data should contain the field tmd_neuron, see the ExtractTMDNeuron class.
For each apical tree in the neuron the radial distance of all node points of the morphology are extracted and added to the feature vector.
The radial distance of a given node is the distance to the root point of the tree that is measured by drawing a straight line.
- Parameters
negative_ipcs (bool) – Invert sign for features of IPCs. ee documentation of the ExtractDistances base class for more details.
negative_bpcs (bool) – Invert sign for features of lower apical trees of BPCs. ee documentation of the ExtractDistances base class for more details.
-
get_distances(apical)¶ Extract the node distance feature from an apical tree.
This is an implementation of the base class’s abstract method.
- Parameters
apical (tmd.Tree.Tree) – An apical tree.
- Returns
A torch tensor of shape (n_nodes,) and of dtype float32 with the extracted node distance features.
- Return type
torch.tensor
-
class
morphoclass.transforms.node_features.ExtractVerticalDistances(vertical_axis='y', negative_ipcs=False, negative_bpcs=False)¶ Bases:
morphoclass.transforms.node_features.extract_distances.ExtractDistancesExtract vertical distance features from apical trees.
The data should contain the field tmd_neuron, see the ExtractTMDNeuron class.
For each apical tree in the neuron the vertical distance of all node points of the morphology are extracted and added to the feature vector.
The vertical distance of a given node is the distance to the root point of the tree that is measured by following the graph edges, and projecting onto a given axis. The default axis is ‘y’.
- Parameters
vertical_axis (str) – Axis along which the neuron is assumed to be oriented vertically. See documentation of the ExtractDistances base class for more details.
negative_ipcs (bool) – Invert sign for features of IPCs. ee documentation of the ExtractDistances base class for more details.
negative_bpcs (bool) – Invert sign for features of lower apical trees of BPCs. ee documentation of the ExtractDistances base class for more details.
-
get_distances(apical)¶ Extract the node distance feature from an apical tree.
This is an implementation of the base class’s abstract method.
- Parameters
apical (tmd.Tree.Tree) – An apical tree.
- Returns
A torch tensor of shape (n_nodes,) and of dtype float32 with the extracted node distance features.
- Return type
torch.tensor