Taping Module#
Module: pyradise.data.taping
General#
The taping module provides the abstract Tape mechanism for recording and playback
arbitrary data and an implementation for recording and playback transformations applied to images (see
TransformTape).
Class Overview#
The following classes are provided by the taping module:
Class |
Description |
|---|---|
Base class for all |
|
|
|
Class to store and handle information about the modification / transformation of an |
Details#
- class Tape[source]#
Bases:
ABCAn abstract class for a tape which records defined elements and can replay them upon request.
- abstract record(value)[source]#
Record a value on the
Tape.- Parameters:
value (Any) – The value to be recorded.
- Return type:
None- Returns:
None
- abstract static playback(data, **kwargs)[source]#
Playback the recorded elements of the
Tapeon the data object.- Parameters:
data (Any) – The data on which the playback should take place. This object need to contain also the tape.
**kwargs – Additional keyword arguments.
- Returns:
The back played data.
- Return type:
Any
- class TransformTape[source]#
Bases:
TapeA class to keep track of the
TransformInfoinstances such that they can be played back on appropriate data. This class provides the basic functionality to render invertibility and reproducibility feasible.- record(value)[source]#
Record a
TransformInfoinstance on the tape.- Parameters:
value (TransformInfo) – The
TransformInfoinstance to record.- Return type:
None- Returns:
None
- get_recorded_elements(reverse=False)[source]#
Get the recorded
TransformInfoinstances.- Parameters:
reverse (bool) – Indicates if the recorded elements should be returned in reverse order (default: False).
- Returns:
The recorded
TransformInfoinstances.- Return type:
Tuple[TransformInfo, …]
- static playback(data, **kwargs)[source]#
Play back the recorded
TransformInfoinstances on the provided data.- Parameters:
data (Image) – The data to play back the recorded
TransformInfoinstances on.**kwargs – Additional keyword arguments.
- Returns:
The
Imageinstance after the playback of the recordedTransformInfoinstances.- Return type:
- class TransformInfo(name, params, pre_transform_image_properties, post_transform_image_properties, filter_args=None, additional_data=None, transform=None)[source]#
Bases:
objectA class to store information about a data transformation performed via a
Filter. This class is used in combination with aTransformTapeinstance to keep track of data transformations and to render invertibility feasible for invertible filters operations.- Parameters:
name (str) – The name of the filter which performed the data transformation.
params (Optional[FilterParameters]) – The filter parameters which parameterize the data transformation.
pre_transform_image_properties (ImageProperties) – The image properties before the data transformation.
post_transform_image_properties (ImageProperties) – The image properties after the data transformation.
filter_args (Optional[Dict[str, Any]]) – The filter arguments passed via the constructor of the filter (default: None).
additional_data (Optional[Dict[str, Any]]) – Additional data which is required the data transformation or to inverse it (default: None).
transform (Optional[sitk.Transform]) – A SimpleITK transform which may be used for the data transformation (default: None).
- get_filter()[source]#
Get the
Filterinstance which performed the data transformation.- Returns:
The filter used for the data transformation.
- Return type:
- get_params()[source]#
Get the
FilterParamsinstance which was used to parameterize the data transformation.- Returns:
The filter parameters used for the data transformation.
- Return type:
FilterParameters
- get_image_properties(pre_transform)[source]#
Get the pre-transform or post-transform
ImagePropertiesinstance.- Parameters:
pre_transform (bool) – If True returns the pre-transform image properties, otherwise the post-transform image properties.
- Returns:
The pre-transform or post-transform image properties.
- Return type:
- add_data(key, value)[source]#
Add additional data to the
TransformInfoinstance.Note
If the provided key already exists, the value will be overwritten.
- Parameters:
key (str) – The key of the additional data.
value (Any) – The value of the additional data.
- Return type:
None- Returns:
None
- get_data(key)[source]#
Get additional data from the
TransformInfoinstance by key.- Parameters:
key (str) – The key of the additional data entry to get.
- Returns:
The value of the additional data entry. If the key is not existing
Noneis returned.- Return type:
Any
- get_transform(inverse=False)[source]#
Get the
SimpleITK.Transforminstance which was used to perform the data transformation.- Parameters:
inverse (bool) – Indicates if the inverse transform should be returned (default: False).
- Returns:
The transform used for the data transformation or the identity transform if origin and direction did not change during data transformation.
- Return type:
sitk.Transform