morphoclass.transforms package

Subpackages

Module contents

Transformations of Data objects.

Some of these transformations return a copy of the Data object, others modify the Data object in-place. The former are well-suited for on-the-fly data augmentation and should be used in the transforms field of the MorphologyDataset class. The latter, which modify the Data objects in-place should only be called once per sample and are therefore well-suited for data pre-processing. Therefore the should be used in the pre_transforms field of the MorphologyDataset class.

Note that multiple transformations can be chained together using the pytorch_geometric.transforms.Compose class.

class morphoclass.transforms.AbstractFeatureScaler(feature_indices, is_global_feature=False)

Bases: abc.ABC

Base abstract class for all feature scalers.

All derived classes must implement the _fit and _transform methods

Parameters
  • feature_indices – List of indices of the feature maps to which to apply the scaling.

  • is_global_feature – Apply scaler to global features rather than node features.

fit(dataset, idx=None)

Fit the scaler to data.

Parameters
abstract get_config()

Generate the configuration necessary for reconstructing the scaler.

Returns

config – The configuration of the scaler. It should contain all information necessary for reconstructing the scaler using the scaler_from_config function.

Return type

dict

abstract reconstruct(params)

Reconstruct the configuration from parameters.

Parameters

params (dict) – The parameters found in config[“params”] with the config being the dictionary returned by get_config.

class morphoclass.transforms.AbstractGlobalFeatureExtractor

Bases: abc.ABC

A morphology data transform for global feature extraction.

abstract extract_global_feature(data)

Extract a particular global feature.

Child classes should implement this function.

Parameters

data – A morphology data sample.

Returns

Return type

The value of the global feature for the given data sample.

class morphoclass.transforms.AddNodesAtIntervals(interval)

Bases: object

Add points to reduced tree at given interval distance.

The reduced apical tree specified by the point mask, is enhanced by adding additional points from the original apical tree.

First it is checked that all branching points are set. Then all points are added that are further away from those that are already set by the given interval distance.

Parameters

interval (float) – Threshold distance at which a new point is added.

add_nodes(apical, mask)

Add nodes to the mask according to the interval configuration.

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

  • mask (np.ndarray) – The mask to set. The data in this array will be modified in-place.

class morphoclass.transforms.AddOneHotLabels(fn_get_oh_label)

Bases: object

Add one-hot labels to data.

The prerequisite is that data already contains numerical sparse labels. These sparse labels are transformed into one-hot labels using the function provided in the constructor.

Parameters

fn_get_oh_label (callable) – Function that maps sparse labels to one-hot labels.

class morphoclass.transforms.AddRandomPointsToReductionMask(n_points)

Bases: object

A Transform that adds a fixed number of random points to the apical mask.

Parameters

n_points (int) – The number of random points to add to the apical mask.

class morphoclass.transforms.AddSectionMiddlePoints(n_points_to_add)

Bases: object

Transform that splits apical sections into two by adding a middle point.

Parameters

n_points_to_add (int) – The number of sections to split into two by adding middle points.

class morphoclass.transforms.ApplyNodeReductionMasks

Bases: object

Transform that applies the apical node masks to the apicals.

static apply_mask(apical, mask)

Apply a node mask to the given apical.

Parameters
  • apical (tmd.Tree.Tree) – The apical dendrite tree.

  • mask (np.ndarray) – The node mask.

class morphoclass.transforms.AverageBranchOrder(tree_hash_fn=None)

Bases: morphoclass.transforms.global_features.abstract_global_feature_extractor.AbstractGlobalFeatureExtractor

Extract average branch order.

Branch order is defined as the number of branching points one passes going from the leafs to the root. Thus the root point has branching order 0

The data should contain the field tmd_neurites, see the ExtractTMDNeurites class.

extract_global_feature(data)

Extract the average branch order global feature from data sample.

Parameters

data – A morphology data sample.

Returns

The average branch order of the morpholgy.

Return type

float

class morphoclass.transforms.AverageRadius(tree_hash_fn=None, from_morphology=False)

Bases: morphoclass.transforms.global_features.abstract_global_feature_extractor.AbstractGlobalFeatureExtractor

Extract average radius across all apicals.

The data should contain the field tmd_neurites, see the ExtractTMDNeurites class.

extract_global_feature(data)

Extract the average radius global feature from data.

Parameters

data – The input morphology.

Returns

Return type

The average radius of the morphology.

class morphoclass.transforms.BranchingOnlyNeurites

Bases: object

Extract simplified structure from TMD neurites.

All neurites in the original data or reduced to branching points only

class morphoclass.transforms.BranchingOnlyNeuron

Bases: object

Extract simplified structure from TMD neurons.

All neurites in the original data or reduced to branching points only

class morphoclass.transforms.Compose(transforms)

Bases: object

A composition of multiple transforms.

Parameters

transforms (iterable) – The transforms to compose.

class morphoclass.transforms.EqualizeNodeCounts(min_total_nodes=None)

Bases: object

Equalize node counts across the whole dataset.

If possible, nodes from the original apicals are added to the apicals as long as the node count in the sample is smaller than the threshold specified by the field min_total_nodes.

The threshold min_total_nodes can be either set manually or found automatically by fitting the transformer to a dataset, in which case the value is set to the minimal number of nodes in the original apicals across the whole dataset.

Parameters

min_total_nodes (int (optional)) – The threshold for the new node count.

fit(dataset)

Find a heuristic number of nodes to which to equalize the samples.

This is simply the minimal number of apical nodes across the whole dataset. This way we make sure that each sample can reach this number of nodes.

Parameters

dataset – The dataset to which to fit.

class morphoclass.transforms.ExtractBranchingAngles(non_branching_angle=0.0)

Bases: object

Extract 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.ExtractBranchingNodeReductionMasks

Bases: object

Transform that extracts apical node masks for branching nodes.

class morphoclass.transforms.ExtractConstFeature

Bases: morphoclass.transforms.node_features.extract_node_features.ExtractNodeFeatures

Extractor 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.ExtractCoordinates(shift_to_origin=True)

Bases: object

Extract 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.ExtractDiameters

Bases: morphoclass.transforms.node_features.extract_node_features.ExtractNodeFeatures

Extract 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.ExtractDistanceWeights(scale=1.0)

Bases: morphoclass.transforms.edge_features.extract_edge_features.ExtractEdgeFeatures

The distance weights edge feature extractor.

The feature is computed as exp(-len(edge)^2 / scale^2).

Parameters

scale (float) – The scale factor for the formula above.

extract_edge_features(data)

Extract the distance weights edge features from given data sample.

The feature is computed as exp(-len(edge)^2 / scale^2).

Parameters

data (torch_geometric.data.Data) – A data sample.

Returns

edge_attr – The extracted distance weights edge features.

Return type

torch.tensor

class morphoclass.transforms.ExtractDistances(vertical_axis='y', negative_ipcs=False, negative_bpcs=False)

Bases: object

Extract 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.ExtractEdgeFeatures

Bases: abc.ABC

Base class for edge feature extractors.

abstract extract_edge_features(data)

Extract some edge features from given data sample.

Parameters

data (torch_geometric.data.Data) – A data sample.

Returns

edge_attr – The extracted edge attributes, shape (n_edges, n_features).

Return type

torch.tensor

class morphoclass.transforms.ExtractEdgeIndex(make_undirected=False)

Bases: object

Extract the adjacency matrix from apical trees.

The data should contain the field tmd_neuron, see the ExtractTMDNeuron class.

For each apical tree in the neuron the the adjacency matrix is extracted and saved as edge_index field in the Data objects. The edge_index is a sparse representation of the adjacency matrix.

Parameters

make_undirected (bool) – Symmetrise the adjacency matrix

class morphoclass.transforms.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.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.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.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.ExtractMaximalApicalPathLength(tree_hash_fn=None)

Bases: morphoclass.transforms.global_features.abstract_global_feature_extractor.AbstractGlobalFeatureExtractor

Extract maximal neurite length.

Maximal path distance form soma to a tip (leaf node)

The data should contain the field tmd_neurites, see the ExtractTMDNeurites class.

extract_global_feature(data)

Extract the maximal apical length global feature from data.

Parameters

data – The input morphology.

Returns

Return type

The maximal apical length of the morphology.

class morphoclass.transforms.ExtractNumberBranchPoints

Bases: morphoclass.transforms.global_features.abstract_global_feature_extractor.AbstractGlobalFeatureExtractor

Extract number of branch points.

The data should contain the field tmd_neurites, see the ExtractTMDNeurites class.

extract_global_feature(data)

Extract the number of branch points global feature from data.

Parameters

data – The input morphology.

Returns

Return type

The number of branch points in the morphology.

class morphoclass.transforms.ExtractNumberLeaves

Bases: morphoclass.transforms.global_features.abstract_global_feature_extractor.AbstractGlobalFeatureExtractor

Extract number of leaf nodes.

The data should contain the field tmd_neurites, see the ExtractTMDNeuritess class.

extract_global_feature(data)

Extract the number of leaf nodes of the morphology.

Parameters

data – A morphology data sample.

Returns

Return type

The total number of leaf nodes of the morphology.

class morphoclass.transforms.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

class morphoclass.transforms.ExtractPathDistances(negative_ipcs=False, negative_bpcs=False)

Bases: morphoclass.transforms.node_features.extract_distances.ExtractDistances

Extract 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.ExtractRadialDistances(negative_ipcs=False, negative_bpcs=False)

Bases: morphoclass.transforms.node_features.extract_distances.ExtractDistances

Extract 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.ExtractTMDNeurites(neurite_type, from_tmd_neuron=False)

Bases: object

Extract neurite trees in TMD Tree format.

Parameters
  • neurite_type (str) – Type of neurite to extract (apical, axon, basal, all)

  • from_tmd_neuron (bool) – If set to true the neurite will be extracted from the TMD neuron in the tmd_neuron field of data. Otherwise, the MorphIO neuron object in the morphology field of data will be converted to a TMD neuron first, from which the neurite will be extracted.

morphio_types = {'all': <SectionType.all: 32>, 'apical': <SectionType.apical_dendrite: 4>, 'axon': <SectionType.axon: 2>, 'basal': <SectionType.basal_dendrite: 3>, 'neurites': <SectionType.all: 32>}
tmd_types = {'all': 'neurites', 'apical': 'apical_dendrite', 'axon': 'axon', 'basal': 'basal_dendrite', 'neurites': 'neurites'}
class morphoclass.transforms.ExtractTMDNeuron

Bases: object

Convert the MorphIO morphology to the TMD Neuron class.

class morphoclass.transforms.ExtractVerticalDistances(vertical_axis='y', negative_ipcs=False, negative_bpcs=False)

Bases: morphoclass.transforms.node_features.extract_distances.ExtractDistances

Extract 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

class morphoclass.transforms.FeatureManualScaler(feature_indices, shift=0, scale=1, **kwargs)

Bases: morphoclass.transforms.scalers.abstract_scaler.AbstractFeatureScaler

Scaler that shifts and scales the features by fixed values.

The new features are computed by features -> (features - shift) / scale

Parameters
  • feature_indices – List of indices of the feature maps to which to apply the scaling.

  • shift (float) – The fixed offset subtracted from the features

  • scale (float) – The fixed scale by which the shifted features are divided.

  • kwargs – Additional keyword argument to pass through to the AbstractFeatureScaler base class.

get_config()

Generate the configuration necessary for reconstructing the scaler.

Returns

config – The configuration of the scaler. It should contain all information necessary for reconstructing the scaler using the scaler_from_config function.

Return type

dict

reconstruct(params)

Reconstruct the configuration from parameters.

Parameters

params (dict) – The parameters found in config[“params”] with the config being the dictionary returned by get_config.

class morphoclass.transforms.FeatureMinMaxScaler(feature_indices, feature_range=(0, 1), take_abs=False, **kwargs)

Bases: morphoclass.transforms.scalers.abstract_scaler.AbstractFeatureScaler

Scaler that scales the features to a given range.

Internally the MinMaxScaler from scikit-learn is applied

Parameters
  • feature_indices – List of indices of the feature maps to which to apply the scaling.

  • feature_range (sequence (optional)) – The feature range to which to scale the features. This value is passed through to the MinMaxScaler class in sklearn.

  • take_abs (bool (optional)) – If true then the scaler will be fitted on the absolute values of the features. This way a feature range of (0, 1) would translate to an effective range of (-1, 1). This is useful when it’s necessary to avoid shifting the features away from the origin.

  • kwargs – Additional keyword argument to pass through to the AbstractFeatureScaler base class.

get_config()

Generate the configuration necessary for reconstructing the scaler.

Returns

config – The configuration of the scaler. It should contain all information necessary for reconstructing the scaler using the scaler_from_config function.

Return type

dict

reconstruct(params)

Reconstruct the configuration from parameters.

Parameters

params (dict) – The parameters found in config[“params”] with the config being the dictionary returned by get_config.

class morphoclass.transforms.FeatureRobustScaler(feature_indices, with_centering=True, with_scaling=True, **kwargs)

Bases: morphoclass.transforms.scalers.abstract_scaler.AbstractFeatureScaler

Scaler that is robust against outliers in data.

Internally the RobustScaler from scikit-learn is applied.

Parameters
  • feature_indices – List of indices of the feature maps to which to apply the scaling.

  • with_centering (bool (optional)) – If True, center the data before scaling. This value is passed through to the RobustScaler class in sklearn.

  • with_scaling (bool (optional)) – If True, scale the data to interquartile range. This value is passed through to the RobustScaler class in sklearn.

  • kwargs – Additional keyword argument to pass through to the AbstractFeatureScaler base class.

get_config()

Generate the configuration necessary for reconstructing the scaler.

Returns

config – The configuration of the scaler. It should contain all information necessary for reconstructing the scaler using the scaler_from_config function.

Return type

dict

reconstruct(params)

Reconstruct the configuration from parameters.

Parameters

params (dict) – The parameters found in config[“params”] with the config being the dictionary returned by get_config.

class morphoclass.transforms.FeatureStandardScaler(feature_indices, with_mean=True, with_std=True, **kwargs)

Bases: morphoclass.transforms.scalers.abstract_scaler.AbstractFeatureScaler

Scaler that removes the mean and standard deviation.

Internally the StandardScaler from scikit-learn is applied

Parameters
  • feature_indices – List of indices of the feature maps to which to apply the scaling.

  • with_mean (bool (optional)) – Whether or not to shift by the mean value. This value is passed through to the StandardScaler class in sklearn.

  • with_std (bool (optional)) – Whether or not to scale by the standard deviation. This value is passed through to the StandardScaler class in sklearn.

  • kwargs – Additional keyword argument to pass through to the AbstractFeatureScaler base class.

get_config()

Generate the configuration necessary for reconstructing the scaler.

Returns

config – The configuration of the scaler. It should contain all information necessary for reconstructing the scaler using the scaler_from_config function.

Return type

dict

reconstruct(params)

Reconstruct the configuration from parameters.

Parameters

params (dict) – The parameters found in config[“params”] with the config being the dictionary returned by get_config.

class morphoclass.transforms.GlobalFeatureToLabel(global_feature_index)

Bases: object

Convert a global feature to label.

Parameters

global_feature_index (int) – The index of the global feature that shall be used.

class morphoclass.transforms.MakeCopy(keep_fields=None)

Bases: object

Transform that makes a copies of morphology data samples.

Parameters

keep_fields (container of str) – The fields of Data objects to keep. If equal to None, then all fields are copied.

classmethod clone_obj(key, obj)

Try to clone an object.

If the cloning fails then the original object is returned.

Parameters
  • key (str) – The object name. Only used for printing information about the object.

  • obj – The object to clone.

Returns

A clone of obj.

Return type

new_obj

class morphoclass.transforms.OrientApicals(special_treatment_ipcs=False, special_treatment_hpcs=False)

Bases: object

Orient all apicals along the positive y-axis.

Parameters
  • special_treatment_ipcs (bool) – If True, then IPCs (inverted pyramidal cells) will be oriented along the negative y-axis

  • special_treatment_hpcs (bool) – If True, then HPCs (horizontal pyramidal cells) will be oriented along the positive x-axis

class morphoclass.transforms.OrientNeuron

Bases: object

Orient neuron using ray fitting.

class morphoclass.transforms.RandomJitter(d_add=0.0, d_scale=0.0, shift_to_origin=True)

Bases: object

Randomly jitter all nodes.

The jittering is applied in the following way. For each coordinate x draw two random numbers, d1 in {-d_add, +d_add} and d2 in {-d_scale, +d_scale} and transform x as follows:

x => (x + d1) * (1 + d2)

Note that d_scale is the scale variation relative to 1.0.

Parameters
  • d_add (float) – The maximal additive factor for jittering.

  • d_scale (float) – The maximal multiplicative factor for jittering (relative to 1.0).

  • shift_to_origin (bool (optional)) – If true then make sure that the root point is at the origin before and after the transformation.

class morphoclass.transforms.RandomRotation(only_y_rotation=False)

Bases: object

Randomly rotate the apical in its 3D embedding space.

The full rotations are parametrized by three Euler angles alpha, beta, and gamma in the following way:

v -> R_y(gamma).R_x(beta).R_y(alpha).v

With this parametrization the range of the angles is the following:

alpha: [0, 2 * pi] beta: [0, pi] gamma: [0, 2 * pi]

It is possible to restrict the rotations to the y-rotations only by setting beta = gamma = 0. This is useful if the apicals are oriented along the y-axis.

Parameters

only_y_rotation (bool, optional) – If true only rotate along the y-axis.

class morphoclass.transforms.RandomStretching(d_scale_x=0.0, d_scale_y=0.0, d_scale_z=0.0)

Bases: object

Randomly scale coordinates along all axes.

Parameters
  • d_scale_x (float) – The range for the random scale along the x-axis. The generated random scale will be in the range (1 - d_scale_x, 1 + d_scale_x).

  • d_scale_y (float) – The range for the random scale along the y-axis. The generated random scale will be in the range (1 - d_scale_y, 1 + d_scale_y).

  • d_scale_z (float) – The range for the random scale along the z-axis. The generated random scale will be in the range (1 - d_scale_z, 1 + d_scale_z).

class morphoclass.transforms.TotalPathLength(tree_hash_fn=None, from_morphology=False)

Bases: morphoclass.transforms.global_features.abstract_global_feature_extractor.AbstractGlobalFeatureExtractor

Extract total path length of the apical.

The data should contain the field tmd_neurites, see the ExtractTMDNeurites class.

extract_global_feature(data)

Extract the total path length global feature from data sample.

Parameters

data – A morphology data sample.

Returns

Return type

The total path length of the morphology.

class morphoclass.transforms.ZeroOutFeatures

Bases: object

Transform that sets all node features to zero.

morphoclass.transforms.scaler_from_config(config)

Reconstruct scaler from a config.

Parameters

config (dict) – The configuration returned by get_config of a scaler class.

Returns

obj – The reconstructed scaler.

Return type

object