pyanno4rt.learning_model.features
Features module.
The module aims to provide methods and classes to handle the features of the base data set, i.e., mapping features to segments and definitions from the feature catalogue and iteratively (re)calculate the values as input to the learning model. In addition, the module contains the feature catalogue.
Subpackages
Overview
Feature map generation class. |
|
Feature value and gradient (re)calculation class. |
Classes
- class pyanno4rt.learning_model.features.FeatureMapGenerator(model_label, fuzzy_matching)[source]
Feature map generation class.
This class provides a mapping between the features from the data set, the structures from the segmentation, and the definitions from the feature catalogue. Matching is based on fuzzy or exact string matching.
- Parameters:
fuzzy_matching (bool) – Indicator for the use of fuzzy string matching (if ‘False’, exact string matching is applied).
- fuzzy_matching
See ‘Parameters’.
- Type:
bool
- feature_map
Dictionary with information on the mapping of features in the dataset with the segmented structures and their computation/differentiation functions.
- Type:
dict
Notes
- In the current implementation, string matching works best if:
names from segments in the segmentation do not have any special characters except “_” (which will automatically be removed before matching);
feature names follow the scheme <name of the segment> _<name of the feature in the catalogue>_<optional parameters>, e.g. “parotidLeft_doseMean” (mean dose to the left parotid) or “parotidRight_doseGradient_x” (dose gradient in x-direction for the right parotid).
Overview
Methods generate(data_information)Generate the feature map by fuzzy or exact string matching.
Members
- generate(data_information)[source]
Generate the feature map by fuzzy or exact string matching.
- Parameters:
...
- Returns:
feature_map – Dictionary with information on the mapping of features in the dataset with the segmented structures and their computation/differentiation functions.
- Return type:
dict
- class pyanno4rt.learning_model.features.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_featuresis False, this attribute is not set.- Type:
ndarray or None
- gradient_history
Gradient matrices per iteration. If
write_gradientsis 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 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