pyanno4rt.learning_model.features._feature_calculator

Feature value and gradient (re)calculation.

Overview

Classes

FeatureCalculator

Feature value and gradient (re)calculation class.

Classes

class pyanno4rt.learning_model.features._feature_calculator.FeatureCalculator(write_features, verbose=True)[source]

Feature value and gradient (re)calculation class.

Parameters:

write_features (bool) – Indicator for tracking the feature values.

write_features

See ‘Parameters’.

Type:

bool

feature_history

Feature values per iteration. If write_features is False, this attribute is not set.

Type:

ndarray or None

gradient_history

Gradient matrices per iteration. If write_gradients is False, this attribute is not set.

Type:

list or None

radiomics

Dictionary for mapping the radiomic feature names to the radiomic feature values. It allows to retrieve the feature values after first computation and thus prevents unnecessary recalculation.

Type:

dict

demographics

Dictionary for mapping the demographic feature names to the demographic feature values. It allows to retrieve the feature values after first computation and thus prevents unnecessary recalculation.

Type:

dict

feature_inputs

Dictionary for collecting the candidate feature input values. This allows to centralize the input retrieval for all calculations.

Type:

dict

__iteration__

Iteration numbers for the feature calculation and the optimization problem. By keeping the two elements the same, it is assured that the feature calculator is only active for new problem iterations, rather than per evaluation step.

Type:

list

__dose_cache__

Cache array for the dose values.

Type:

ndarray

__feature_cache__

Cache array for the feature values.

Type:

ndarray

Overview

Methods

add_feature_map(feature_map, return_self)

Add the feature map to the calculator.

precompute(dose, segment)

Precompute the dose, dose cube and segment masks as inputs for the feature calculation.

featurize(dose, segment, no_cache)

Convert dose and segment information into the feature vector.

get_feature_vector()

Get the feature vector.

gradientize(dose, segment)

Convert dose and segment information into the gradient matrix.

Members

add_feature_map(feature_map, return_self=False)[source]

Add the feature map to the calculator.

Parameters:

feature_map (dict) –

precompute(dose, segment)[source]

Precompute the dose, dose cube and segment masks as inputs for the feature calculation.

Parameters:
  • dose (tuple of ndarray) – Value of the dose for a single or multiple segments.

  • segment (list of strings) – Names of the segments associated with the dose.

featurize(dose, segment, no_cache=False)[source]

Convert dose and segment information into the feature vector.

Parameters:
  • dose (tuple of ndarray) – Value of the dose for a single or multiple segments.

  • segment (list of strings) – Names of the segments associated with the dose.

Returns:

Values of the calculated features.

Return type:

ndarray

get_feature_vector()[source]

Get the feature vector.

Parameters:
  • dose (tuple of ndarray) – Value of the dose for a single or multiple segments.

  • segment (list of strings) – Names of the segments associated with the dose.

Returns:

Values of the calculated features.

Return type:

ndarray

gradientize(dose, segment)[source]

Convert dose and segment information into the gradient matrix.

Parameters:
  • dose (tuple of ndarray) – Value of the dose for a single or multiple segments.

  • segment (list of strings) – Names of the segments associated with the dose.

Returns:

Matrix of the calculated gradients.

Return type:

csr_matrix