cst#

cst#

class StructureSet(**data)[source]#

Bases: PyRadPlanBaseModel

Represents a Structure Set for a Patient.

Attributes:
model_extra

Get extra fields set during validation.

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

voi_types

Return the unique VOI types in the Structure Set.

Methods

apply_overlap_priorities()

Apply overlaps to the StructureSet.

check_cst()

Check if the VOIs are valid and reference the same CT.

copy(*[, include, exclude, update, deep])

Returns a copy of the model.

create_body_seg([threshold, name, voi_type])

Create a body segmentation from CT data based on a HU threshold.

get_reference_lq_params([...])

Get the reference LQ parameters (alpha_x and beta_x) for the given CT.

model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

model_dump(*[, mode, include, exclude, ...])

!!! abstract "Usage Documentation"

model_dump_json(*[, indent, ensure_ascii, ...])

!!! abstract "Usage Documentation"

model_json_schema([by_alias, ref_template, ...])

Generates a JSON schema for a model class.

model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

model_post_init(context, /)

Override this method to perform additional initialization after __init__ and model_construct.

model_rebuild(*[, force, raise_errors, ...])

Try to rebuild the pydantic-core schema for the model.

model_validate(obj, *[, strict, extra, ...])

Validate a pydantic model instance.

model_validate_json(json_data, *[, strict, ...])

!!! abstract "Usage Documentation"

model_validate_strings(obj, *[, strict, ...])

Validate the given object with string data against the Pydantic model.

patient_mask()

Return the union mask of all patient contours (or the EXTERNAL contour if provided).

patient_voxels([order])

Return the union of all patient indices.

resample_on_new_ct(new_ct)

Resample the StructureSet on a new CT.

set_colors()

Assign colors from DEFAULT_VOI_COLORS to VOIs lacking visible_color.

target_center_of_mass()

Return the center of mass of the target.

target_union_mask()

Return the union mask of all target indices.

target_union_voxels([order])

Return the union of all target indices.

to_matrad([context])

Convert the StructureSet to a matRad writeable format.

aggregate_dynamic_quantities

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

classmethod aggregate_dynamic_quantities(data, info)[source]#
Return type:

Any

apply_overlap_priorities()[source]#

Apply overlaps to the StructureSet.

Returns:

The StructureSet with overlaps applied.

Return type:

Self

check_cst()[source]#

Check if the VOIs are valid and reference the same CT.

Return type:

Self

classmethod construct(_fields_set=None, **values)#
Return type:

Self

copy(*, include=None, exclude=None, update=None, deep=False)#

Returns a copy of the model.

!!! warning “Deprecated”

This method is now deprecated; use model_copy instead.

If you need include or exclude, use:

`python {test="skip" lint="skip"} data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `

Parameters:
  • include (Set[int] | Set[str] | Mapping[int, Any] | Mapping[str, Any] | None) – Optional set or mapping specifying which fields to include in the copied model.

  • exclude (Set[int] | Set[str] | Mapping[int, Any] | Mapping[str, Any] | None) – Optional set or mapping specifying which fields to exclude in the copied model.

  • update (Optional[Dict[str, Any]]) – Optional dictionary of field-value pairs to override field values in the copied model.

  • deep (bool) – If True, the values of fields that are Pydantic models will be deep-copied.

Return type:

Self

Returns:

A copy of the model with included, excluded and updated fields as specified.

create_body_seg(threshold=-200.0, name='BODY', voi_type='OAR')[source]#

Create a body segmentation from CT data based on a HU threshold.

This method generates a body contour by thresholding the CT image, identifying the largest connected component (main body), and filling internal air cavities (like lungs) slice by slice to handle cases where the scan is cut off.

Parameters:
  • threshold (float) – HU threshold value for body segmentation. Voxels with HU values above this threshold are considered part of the body. Default is -200.0 HU (approximately air/tissue boundary).

  • name (str) – Name for the body VOI. Default is “BODY”.

  • voi_type (str, optional) – Type of the VOI to create. Default is “OAR”.

Returns:

Updated StructureSet with the body segmentation added.

Return type:

Self

ct_image: CT#
dict(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)#
Return type:

Dict[str, Any]

classmethod from_orm(obj)#
Return type:

Self

get_reference_lq_params(overlap_is_applied=False, resample_grid=None)[source]#

Get the reference LQ parameters (alpha_x and beta_x) for the given CT.

Return type:

tuple[ndarray, ndarray]

json(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=PydanticUndefined, models_as_dict=PydanticUndefined, **dumps_kwargs)#
Return type:

str

model_computed_fields = {}#
model_config: ClassVar[ConfigDict] = {'alias_generator': AliasGenerator(alias=<function to_camel>, validation_alias=None, serialization_alias=None), 'arbitrary_types_allowed': True, 'from_attributes': True, 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod model_construct(_fields_set=None, **values)#

Creates a new instance of the Model class with validated data.

Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.

!!! note

model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.

Parameters:
  • _fields_set (set[str] | None) – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.

  • values (Any) – Trusted or pre-validated data dictionary.

Return type:

Self

Returns:

A new instance of the Model class with validated data.

model_copy(*, update=None, deep=False)#
!!! abstract “Usage Documentation”

[model_copy](../concepts/models.md#model-copy)

Returns a copy of the model.

!!! note

The underlying instance’s [__dict__][object.__dict__] attribute is copied. This might have unexpected side effects if you store anything in it, on top of the model fields (e.g. the value of [cached properties][functools.cached_property]).

Parameters:
  • update (Mapping[str, Any] | None) – Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data.

  • deep (bool) – Set to True to make a deep copy of the model.

Return type:

Self

Returns:

New model instance.

model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False, polymorphic_serialization=None)#
!!! abstract “Usage Documentation”

[model_dump](../concepts/serialization.md#python-mode)

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Parameters:
  • mode (Union[Literal['json', 'python'], str]) – The mode in which to_python should run. If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.

  • include (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – A set of fields to include in the output.

  • exclude (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – A set of fields to exclude from the output.

  • context (Any | None) – Additional context to pass to the serializer.

  • by_alias (bool | None) – Whether to use the field’s alias in the dictionary key if defined.

  • exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) – Whether to exclude fields that are set to their default value.

  • exclude_none (bool) – Whether to exclude fields that have a value of None.

  • exclude_computed_fields (bool) – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (Union[bool, Literal['none', 'warn', 'error']]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback (Optional[Callable[[Any], Any]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.

  • polymorphic_serialization (bool | None) – Whether to use model and dataclass polymorphic serialization for this call.

Return type:

dict[str, Any]

Returns:

A dictionary representation of the model.

model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False, polymorphic_serialization=None)#
!!! abstract “Usage Documentation”

[model_dump_json](../concepts/serialization.md#json-mode)

Generates a JSON representation of the model using Pydantic’s to_json method.

Parameters:
  • indent (int | None) – Indentation to use in the JSON output. If None is passed, the output will be compact.

  • ensure_ascii (bool) – If True, the output is guaranteed to have all incoming non-ASCII characters escaped. If False (the default), these characters will be output as-is.

  • include (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – Field(s) to include in the JSON output.

  • exclude (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – Field(s) to exclude from the JSON output.

  • context (Any | None) – Additional context to pass to the serializer.

  • by_alias (bool | None) – Whether to serialize using field aliases.

  • exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) – Whether to exclude fields that are set to their default value.

  • exclude_none (bool) – Whether to exclude fields that have a value of None.

  • exclude_computed_fields (bool) – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (Union[bool, Literal['none', 'warn', 'error']]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback (Optional[Callable[[Any], Any]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.

  • polymorphic_serialization (bool | None) – Whether to use model and dataclass polymorphic serialization for this call.

Return type:

str

Returns:

A JSON string representation of the model.

property model_extra: dict[str, Any] | None#

Get extra fields set during validation.

Returns:

A dictionary of extra fields, or None if config.extra is not set to “allow”.

model_fields = {'ct_image': FieldInfo(annotation=CT, required=True, alias='ctImage', alias_priority=1, description='Reference to the CT Image', init=False), 'vois': FieldInfo(annotation=list[VOI], required=True, alias='vois', alias_priority=1, description='List of VOIs in the Structure Set', init=False)}#
property model_fields_set: set[str]#

Returns the set of fields that have been explicitly set on this model instance.

Returns:

A set of strings representing the fields that have been set,

i.e. that were not filled from defaults.

classmethod model_json_schema(by_alias=True, ref_template='#/$defs/{model}', schema_generator=<class 'pydantic.json_schema.GenerateJsonSchema'>, mode='validation', *, union_format='any_of')#

Generates a JSON schema for a model class.

Parameters:
  • by_alias (bool) – Whether to use attribute aliases or not.

  • ref_template (str) – The reference template.

  • union_format (Literal['any_of', 'primitive_type_array']) –

    The format to use when combining schemas from unions together. Can be one of:

    keyword to combine schemas (the default). - ‘primitive_type_array’: Use the [type](https://json-schema.org/understanding-json-schema/reference/type) keyword as an array of strings, containing each type of the combination. If any of the schemas is not a primitive type (string, boolean, null, integer or number) or contains constraints/metadata, falls back to any_of.

  • schema_generator (type[GenerateJsonSchema]) – To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modifications

  • mode (Literal['validation', 'serialization']) – The mode in which to generate the schema.

Return type:

dict[str, Any]

Returns:

The JSON schema for the given model class.

classmethod model_parametrized_name(params)#

Compute the class name for parametrizations of generic classes.

This method can be overridden to achieve a custom naming scheme for generic BaseModels.

Parameters:

params (tuple[type[Any], ...]) – Tuple of types of the class. Given a generic class Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.

Return type:

str

Returns:

String representing the new class where params are passed to cls as type variables.

Raises:

TypeError – Raised when trying to generate concrete names for non-generic models.

model_post_init(context, /)#

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

Return type:

None

classmethod model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)#

Try to rebuild the pydantic-core schema for the model.

This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.

Parameters:
  • force (bool) – Whether to force the rebuilding of the model schema, defaults to False.

  • raise_errors (bool) – Whether to raise errors, defaults to True.

  • _parent_namespace_depth (int) – The depth level of the parent namespace, defaults to 2.

  • _types_namespace (Mapping[str, Any] | None) – The types namespace, defaults to None.

Return type:

bool | None

Returns:

Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.

classmethod model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)#

Validate a pydantic model instance.

Parameters:
  • obj (Any) – The object to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • from_attributes (bool | None) – Whether to extract data from object attributes.

  • context (Any | None) – Additional context to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Raises:

ValidationError – If the object could not be validated.

Return type:

Self

Returns:

The validated model instance.

classmethod model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)#
!!! abstract “Usage Documentation”

[JSON Parsing](../concepts/json.md#json-parsing)

Validate the given JSON data against the Pydantic model.

Parameters:
  • json_data (str | bytes | bytearray) – The JSON data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Return type:

Self

Returns:

The validated Pydantic model.

Raises:

ValidationError – If json_data is not a JSON string or the object could not be validated.

classmethod model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)#

Validate the given object with string data against the Pydantic model.

Parameters:
  • obj (Any) – The object containing string data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Return type:

Self

Returns:

The validated Pydantic model.

classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Self

classmethod parse_obj(obj)#
Return type:

Self

classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Self

patient_mask()[source]#

Return the union mask of all patient contours (or the EXTERNAL contour if provided).

Return type:

Image

patient_voxels(order='sitk')[source]#

Return the union of all patient indices.

Return type:

ndarray

resample_on_new_ct(new_ct)[source]#

Resample the StructureSet on a new CT.

Parameters:

new_ct (CT) – The new CT to resample the StructureSet on.

Returns:

The resampled StructureSet.

Return type:

Self

classmethod schema(by_alias=True, ref_template='#/$defs/{model}')#
Return type:

Dict[str, Any]

classmethod schema_json(*, by_alias=True, ref_template='#/$defs/{model}', **dumps_kwargs)#
Return type:

str

set_colors()[source]#

Assign colors from DEFAULT_VOI_COLORS to VOIs lacking visible_color.

Colors are popped in order from the predefined list for each VOI type, skipping any color already taken by another VOI. If the list is exhausted the last color in the list is reused. Existing visible_color values are preserved.

Return type:

Self

target_center_of_mass()[source]#

Return the center of mass of the target.

Return type:

ndarray

target_union_mask()[source]#

Return the union mask of all target indices.

Return type:

Image

target_union_voxels(order='sitk')[source]#

Return the union of all target indices.

Return type:

ndarray

to_matrad(context='mat-file')[source]#

Convert the StructureSet to a matRad writeable format.

Return type:

Any

classmethod update_forward_refs(**localns)#
Return type:

None

classmethod validate(value)#
Return type:

Self

property voi_types: list#

Return the unique VOI types in the Structure Set.

vois: list[VOI]#
create_cst(cst_data=None, ct=None, **kwargs)[source]#

Create a StructureSet from various input types.

Parameters:
  • cst_data (Union[dict[str, Any], StructureSet, None]) – The input data to create the CT object from. Can be a dictionary, existing CT object, file path, or None.

  • ct (Union[CT, dict, None]) – The input data to create the CT object from. Can be a dictionary, existing CT object, or None.

  • **kwargs – Additional keyword arguments to create the CT object.

Returns:

A StructureSet object created from the input data or keyword arguments.

Return type:

StructureSet

validate_cst(cst_data=None, ct=None, **kwargs)[source]#

Validate StructureSet.

Parameters:
  • cst_data (Union[dict[str, Any], StructureSet, None]) – The input data to create the CT object from. Can be a dictionary, existing CT object, file path, or None.

  • ct (Union[CT, dict, None]) – The input data to create the CT object from. Can be a dictionary, existing CT object, or None.

  • **kwargs – Additional keyword arguments to create the CT object.

Returns:

A StructureSet object created from the input data or keyword arguments.

Return type:

StructureSet

VOI#

class VOI(**data)[source]#

Bases: PyRadPlanBaseModel, ABC

Represents a Volume of Interest (VOI).

Parameters:
  • name (str) – The name of the VOI.

  • ct_image (CT) – The CT image where the VOI is defined.

  • mask (np.ndarray or sitk.Image) – Boolean mask (using 0,1) for referencing of voxels (Multiple allocations possible for robust scenarios)

  • alpha_x (float, optional) – The alpha_x value. Defaults to 0.1.

  • beta_x (float, optional) – The beta_x value. Defaults to 0.05.

  • overlap_priority (int) – The overlap priority of the VOI. Lowest number is overlapping higher numbers.

Attributes:
indices

Return the indices of the voxels in the mask using Fortran/SITK convention.

indices_numpy

Return the indices of the voxels in the mask using C/numpy convention.

model_extra

Get extra fields set during validation.

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

num_of_scenarios

Returns the number of scenarios.

scenario_ct_data

Returns a list of CT data for the individual scenarios.

Methods

copy(*[, include, exclude, update, deep])

Returns a copy of the model.

get_indices([order])

Return the indices of the voxels in the mask.

masked_ct([order_type])

Return the masked CT image, either as a numpy array or a SimpleITK image.

model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

model_dump(*[, mode, include, exclude, ...])

!!! abstract "Usage Documentation"

model_dump_json(*[, indent, ensure_ascii, ...])

!!! abstract "Usage Documentation"

model_json_schema([by_alias, ref_template, ...])

Generates a JSON schema for a model class.

model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

model_post_init(context, /)

Override this method to perform additional initialization after __init__ and model_construct.

model_rebuild(*[, force, raise_errors, ...])

Try to rebuild the pydantic-core schema for the model.

model_validate(obj, *[, strict, extra, ...])

Validate a pydantic model instance.

model_validate_json(json_data, *[, strict, ...])

!!! abstract "Usage Documentation"

model_validate_strings(obj, *[, strict, ...])

Validate the given object with string data against the Pydantic model.

resample_on_new_ct(new_ct)

Resample on new CT image.

scenario_indices([order_type])

Return the flattened indices of the individual scenarios.

to_matrad([context])

Create an object that can be interpreted by matRad in the given context.

validate_mask()

Check if the given indices are valid for the CT image.

validate_mask_type(v)

Validate the mask type.

validate_visible_color(v)

Validate the visible color.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

alpha_x: float#
beta_x: float#
classmethod construct(_fields_set=None, **values)#
Return type:

Self

copy(*, include=None, exclude=None, update=None, deep=False)#

Returns a copy of the model.

!!! warning “Deprecated”

This method is now deprecated; use model_copy instead.

If you need include or exclude, use:

`python {test="skip" lint="skip"} data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `

Parameters:
  • include (Set[int] | Set[str] | Mapping[int, Any] | Mapping[str, Any] | None) – Optional set or mapping specifying which fields to include in the copied model.

  • exclude (Set[int] | Set[str] | Mapping[int, Any] | Mapping[str, Any] | None) – Optional set or mapping specifying which fields to exclude in the copied model.

  • update (Optional[Dict[str, Any]]) – Optional dictionary of field-value pairs to override field values in the copied model.

  • deep (bool) – If True, the values of fields that are Pydantic models will be deep-copied.

Return type:

Self

Returns:

A copy of the model with included, excluded and updated fields as specified.

ct_image: CT#
default_color: tuple[int, int, int]#
dict(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)#
Return type:

Dict[str, Any]

classmethod from_orm(obj)#
Return type:

Self

get_indices(order='sitk')[source]#

Return the indices of the voxels in the mask.

Parameters:

order (str, optional) – The order of the indices. Defaults to “sitk”.

Returns:

The indices of the voxels.

Return type:

ndarray

property indices: ndarray#

Return the indices of the voxels in the mask using Fortran/SITK convention.

Returns:

The indices of the voxels.

Return type:

np.ndarray

property indices_numpy: ndarray#

Return the indices of the voxels in the mask using C/numpy convention.

Returns:

The indices of the voxels.

Return type:

np.ndarray

json(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=PydanticUndefined, models_as_dict=PydanticUndefined, **dumps_kwargs)#
Return type:

str

mask: Image#
masked_ct(order_type='numpy')[source]#

Return the masked CT image, either as a numpy array or a SimpleITK image.

Parameters:

order_type (str, optional) – The order type. Defaults to “numpy”.

Returns:

The masked CT image.

Return type:

Union[Image, ndarray]

model_computed_fields = {'_numpy_mask': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='_numpyMask', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns the mask as a numpy array.\n\nReturns\n-------\nnp.ndarray\n    The mask as a numpy array.', deprecated=None, examples=None, json_schema_extra=None, repr=False), 'indices': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='indices', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Return the indices of the voxels in the mask using Fortran/SITK convention.\n\nReturns\n-------\nnp.ndarray\n    The indices of the voxels.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'indices_numpy': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='indicesNumpy', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Return the indices of the voxels in the mask using C/numpy convention.\n\nReturns\n-------\nnp.ndarray\n    The indices of the voxels.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'num_of_scenarios': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'int'>, alias='numOfScenarios', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns the number of scenarios.\n\nReturns\n-------\nint\n    The number of scenarios.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'scenario_ct_data': ComputedFieldInfo(wrapped_property=<property object>, return_type=typing.Union[list[numpy.ndarray], numpy.ndarray], alias='scenarioCtData', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns a list of CT data for the individual scenarios.\n\nReturns\n-------\nList[np.ndarray]\n    The CT data for the individual scenarios.', deprecated=None, examples=None, json_schema_extra=None, repr=True)}#
model_config: ClassVar[ConfigDict] = {'alias_generator': AliasGenerator(alias=<function to_camel>, validation_alias=None, serialization_alias=None), 'arbitrary_types_allowed': True, 'from_attributes': True, 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod model_construct(_fields_set=None, **values)#

Creates a new instance of the Model class with validated data.

Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.

!!! note

model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.

Parameters:
  • _fields_set (set[str] | None) – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.

  • values (Any) – Trusted or pre-validated data dictionary.

Return type:

Self

Returns:

A new instance of the Model class with validated data.

model_copy(*, update=None, deep=False)#
!!! abstract “Usage Documentation”

[model_copy](../concepts/models.md#model-copy)

Returns a copy of the model.

!!! note

The underlying instance’s [__dict__][object.__dict__] attribute is copied. This might have unexpected side effects if you store anything in it, on top of the model fields (e.g. the value of [cached properties][functools.cached_property]).

Parameters:
  • update (Mapping[str, Any] | None) – Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data.

  • deep (bool) – Set to True to make a deep copy of the model.

Return type:

Self

Returns:

New model instance.

model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False, polymorphic_serialization=None)#
!!! abstract “Usage Documentation”

[model_dump](../concepts/serialization.md#python-mode)

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Parameters:
  • mode (Union[Literal['json', 'python'], str]) – The mode in which to_python should run. If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.

  • include (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – A set of fields to include in the output.

  • exclude (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – A set of fields to exclude from the output.

  • context (Any | None) – Additional context to pass to the serializer.

  • by_alias (bool | None) – Whether to use the field’s alias in the dictionary key if defined.

  • exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) – Whether to exclude fields that are set to their default value.

  • exclude_none (bool) – Whether to exclude fields that have a value of None.

  • exclude_computed_fields (bool) – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (Union[bool, Literal['none', 'warn', 'error']]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback (Optional[Callable[[Any], Any]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.

  • polymorphic_serialization (bool | None) – Whether to use model and dataclass polymorphic serialization for this call.

Return type:

dict[str, Any]

Returns:

A dictionary representation of the model.

model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False, polymorphic_serialization=None)#
!!! abstract “Usage Documentation”

[model_dump_json](../concepts/serialization.md#json-mode)

Generates a JSON representation of the model using Pydantic’s to_json method.

Parameters:
  • indent (int | None) – Indentation to use in the JSON output. If None is passed, the output will be compact.

  • ensure_ascii (bool) – If True, the output is guaranteed to have all incoming non-ASCII characters escaped. If False (the default), these characters will be output as-is.

  • include (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – Field(s) to include in the JSON output.

  • exclude (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – Field(s) to exclude from the JSON output.

  • context (Any | None) – Additional context to pass to the serializer.

  • by_alias (bool | None) – Whether to serialize using field aliases.

  • exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) – Whether to exclude fields that are set to their default value.

  • exclude_none (bool) – Whether to exclude fields that have a value of None.

  • exclude_computed_fields (bool) – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (Union[bool, Literal['none', 'warn', 'error']]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback (Optional[Callable[[Any], Any]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.

  • polymorphic_serialization (bool | None) – Whether to use model and dataclass polymorphic serialization for this call.

Return type:

str

Returns:

A JSON string representation of the model.

property model_extra: dict[str, Any] | None#

Get extra fields set during validation.

Returns:

A dictionary of extra fields, or None if config.extra is not set to “allow”.

model_fields = {'alpha_x': FieldInfo(annotation=float, required=False, default=0.1, alias='alphaX', alias_priority=1), 'beta_x': FieldInfo(annotation=float, required=False, default=0.05, alias='betaX', alias_priority=1), 'ct_image': FieldInfo(annotation=CT, required=True, alias='ctImage', alias_priority=1), 'default_color': FieldInfo(annotation=tuple[int, int, int], required=False, default_factory=<lambda>, alias='defaultColor', alias_priority=1, description='Default RGB color bound to the VOI type'), 'mask': FieldInfo(annotation=Image, required=True, alias='mask', alias_priority=1), 'name': FieldInfo(annotation=str, required=True, alias='name', alias_priority=1), 'objectives': FieldInfo(annotation=list[Any], required=False, default=[], alias='objectives', alias_priority=1, description='List of objective function definitions'), 'overlap_priority': FieldInfo(annotation=int, required=False, default_factory=<lambda>, alias='Priority', alias_priority=2), 'visible': FieldInfo(annotation=bool, required=False, default=True, alias='visible', alias_priority=1, description='Flag to set visibility in GUI applications'), 'visible_color': FieldInfo(annotation=Union[tuple[int, int, int], NoneType], required=False, default=None, alias='visibleColor', alias_priority=1, description='RGB color for visualization in GUI applications'), 'voi_type': FieldInfo(annotation=str, required=True, alias='voiType', alias_priority=1, metadata=[StringConstraints(strip_whitespace=True, to_upper=True, to_lower=None, strict=None, min_length=None, max_length=None, pattern=None, ascii_only=None)])}#
property model_fields_set: set[str]#

Returns the set of fields that have been explicitly set on this model instance.

Returns:

A set of strings representing the fields that have been set,

i.e. that were not filled from defaults.

classmethod model_json_schema(by_alias=True, ref_template='#/$defs/{model}', schema_generator=<class 'pydantic.json_schema.GenerateJsonSchema'>, mode='validation', *, union_format='any_of')#

Generates a JSON schema for a model class.

Parameters:
  • by_alias (bool) – Whether to use attribute aliases or not.

  • ref_template (str) – The reference template.

  • union_format (Literal['any_of', 'primitive_type_array']) –

    The format to use when combining schemas from unions together. Can be one of:

    keyword to combine schemas (the default). - ‘primitive_type_array’: Use the [type](https://json-schema.org/understanding-json-schema/reference/type) keyword as an array of strings, containing each type of the combination. If any of the schemas is not a primitive type (string, boolean, null, integer or number) or contains constraints/metadata, falls back to any_of.

  • schema_generator (type[GenerateJsonSchema]) – To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modifications

  • mode (Literal['validation', 'serialization']) – The mode in which to generate the schema.

Return type:

dict[str, Any]

Returns:

The JSON schema for the given model class.

classmethod model_parametrized_name(params)#

Compute the class name for parametrizations of generic classes.

This method can be overridden to achieve a custom naming scheme for generic BaseModels.

Parameters:

params (tuple[type[Any], ...]) – Tuple of types of the class. Given a generic class Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.

Return type:

str

Returns:

String representing the new class where params are passed to cls as type variables.

Raises:

TypeError – Raised when trying to generate concrete names for non-generic models.

model_post_init(context, /)#

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

Return type:

None

classmethod model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)#

Try to rebuild the pydantic-core schema for the model.

This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.

Parameters:
  • force (bool) – Whether to force the rebuilding of the model schema, defaults to False.

  • raise_errors (bool) – Whether to raise errors, defaults to True.

  • _parent_namespace_depth (int) – The depth level of the parent namespace, defaults to 2.

  • _types_namespace (Mapping[str, Any] | None) – The types namespace, defaults to None.

Return type:

bool | None

Returns:

Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.

classmethod model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)#

Validate a pydantic model instance.

Parameters:
  • obj (Any) – The object to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • from_attributes (bool | None) – Whether to extract data from object attributes.

  • context (Any | None) – Additional context to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Raises:

ValidationError – If the object could not be validated.

Return type:

Self

Returns:

The validated model instance.

classmethod model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)#
!!! abstract “Usage Documentation”

[JSON Parsing](../concepts/json.md#json-parsing)

Validate the given JSON data against the Pydantic model.

Parameters:
  • json_data (str | bytes | bytearray) – The JSON data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Return type:

Self

Returns:

The validated Pydantic model.

Raises:

ValidationError – If json_data is not a JSON string or the object could not be validated.

classmethod model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)#

Validate the given object with string data against the Pydantic model.

Parameters:
  • obj (Any) – The object containing string data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Return type:

Self

Returns:

The validated Pydantic model.

name: str#
property num_of_scenarios: int#

Returns the number of scenarios.

Returns:

The number of scenarios.

Return type:

int

objectives: list[Any]#
overlap_priority: int#
classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Self

classmethod parse_obj(obj)#
Return type:

Self

classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Self

resample_on_new_ct(new_ct)[source]#

Resample on new CT image.

Parameters:

new_ct (CT) – The new CT image to resample the VOI on.

Returns:

The resampled VOI.

Return type:

Self

property scenario_ct_data: list[ndarray] | ndarray#

Returns a list of CT data for the individual scenarios.

Returns:

The CT data for the individual scenarios.

Return type:

List[np.ndarray]

scenario_indices(order_type='numpy')[source]#

Return the flattened indices of the individual scenarios.

Parameters:

order_type (str, optional) – The order type. Defaults to “numpy”.

Returns:

The flattened indices of the individual scenarios.

Return type:

Union[ndarray, list[ndarray]]

classmethod schema(by_alias=True, ref_template='#/$defs/{model}')#
Return type:

Dict[str, Any]

classmethod schema_json(*, by_alias=True, ref_template='#/$defs/{model}', **dumps_kwargs)#
Return type:

str

to_matrad(context='mat-file')[source]#

Create an object that can be interpreted by matRad in the given context.

Returns:

VOI as list to write cell arrays.

Return type:

Any

classmethod update_forward_refs(**localns)#
Return type:

None

classmethod validate(value)#
Return type:

Self

validate_mask()[source]#

Check if the given indices are valid for the CT image.

Raises:
  • ValueError – If the mask is not a sitk.Image.

  • ValueError – If the dimensions of the mask do not match the CT image.

classmethod validate_mask_type(v)[source]#

Validate the mask type.

Parameters:

v (Any) – The mask value to be validated.

Returns:

The validated mask.

Return type:

Any

Raises:

ValueError – If the mask type is not supported.

classmethod validate_visible_color(v)[source]#

Validate the visible color.

Parameters:

v (Any) – The visible color value to be validated.

Returns:

The validated visible color.

Return type:

Any

visible: bool#
visible_color: tuple[int, int, int] | None#
voi_type: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=True, to_lower=None, strict=None, min_length=None, max_length=None, pattern=None, ascii_only=None)]#
class OAR(**data)[source]#

Bases: VOI

Represents an organ at risk (OAR).

Inherits all attributes from Plan.
voi_type : str

Returns the voi_type as ‘OAR’.

Attributes:
indices

Return the indices of the voxels in the mask using Fortran/SITK convention.

indices_numpy

Return the indices of the voxels in the mask using C/numpy convention.

model_extra

Get extra fields set during validation.

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

num_of_scenarios

Returns the number of scenarios.

scenario_ct_data

Returns a list of CT data for the individual scenarios.

Methods

copy(*[, include, exclude, update, deep])

Returns a copy of the model.

get_indices([order])

Return the indices of the voxels in the mask.

masked_ct([order_type])

Return the masked CT image, either as a numpy array or a SimpleITK image.

model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

model_dump(*[, mode, include, exclude, ...])

!!! abstract "Usage Documentation"

model_dump_json(*[, indent, ensure_ascii, ...])

!!! abstract "Usage Documentation"

model_json_schema([by_alias, ref_template, ...])

Generates a JSON schema for a model class.

model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

model_post_init(context, /)

Override this method to perform additional initialization after __init__ and model_construct.

model_rebuild(*[, force, raise_errors, ...])

Try to rebuild the pydantic-core schema for the model.

model_validate(obj, *[, strict, extra, ...])

Validate a pydantic model instance.

model_validate_json(json_data, *[, strict, ...])

!!! abstract "Usage Documentation"

model_validate_strings(obj, *[, strict, ...])

Validate the given object with string data against the Pydantic model.

resample_on_new_ct(new_ct)

Resample on new CT image.

scenario_indices([order_type])

Return the flattened indices of the individual scenarios.

to_matrad([context])

Create an object that can be interpreted by matRad in the given context.

validate_mask()

Check if the given indices are valid for the CT image.

validate_mask_type(v)

Validate the mask type.

validate_visible_color(v)

Validate the visible color.

validate_voi_type(v)

Validate the voi type for an OAR.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

alpha_x: float#
beta_x: float#
classmethod construct(_fields_set=None, **values)#
Return type:

Self

copy(*, include=None, exclude=None, update=None, deep=False)#

Returns a copy of the model.

!!! warning “Deprecated”

This method is now deprecated; use model_copy instead.

If you need include or exclude, use:

`python {test="skip" lint="skip"} data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `

Parameters:
  • include (Set[int] | Set[str] | Mapping[int, Any] | Mapping[str, Any] | None) – Optional set or mapping specifying which fields to include in the copied model.

  • exclude (Set[int] | Set[str] | Mapping[int, Any] | Mapping[str, Any] | None) – Optional set or mapping specifying which fields to exclude in the copied model.

  • update (Optional[Dict[str, Any]]) – Optional dictionary of field-value pairs to override field values in the copied model.

  • deep (bool) – If True, the values of fields that are Pydantic models will be deep-copied.

Return type:

Self

Returns:

A copy of the model with included, excluded and updated fields as specified.

ct_image: CT#
default_color: tuple[int, int, int]#
dict(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)#
Return type:

Dict[str, Any]

classmethod from_orm(obj)#
Return type:

Self

get_indices(order='sitk')#

Return the indices of the voxels in the mask.

Parameters:

order (str, optional) – The order of the indices. Defaults to “sitk”.

Returns:

The indices of the voxels.

Return type:

ndarray

property indices: ndarray#

Return the indices of the voxels in the mask using Fortran/SITK convention.

Returns:

The indices of the voxels.

Return type:

np.ndarray

property indices_numpy: ndarray#

Return the indices of the voxels in the mask using C/numpy convention.

Returns:

The indices of the voxels.

Return type:

np.ndarray

json(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=PydanticUndefined, models_as_dict=PydanticUndefined, **dumps_kwargs)#
Return type:

str

mask: Image#
masked_ct(order_type='numpy')#

Return the masked CT image, either as a numpy array or a SimpleITK image.

Parameters:

order_type (str, optional) – The order type. Defaults to “numpy”.

Returns:

The masked CT image.

Return type:

Union[Image, ndarray]

model_computed_fields = {'_numpy_mask': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='_numpyMask', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns the mask as a numpy array.\n\nReturns\n-------\nnp.ndarray\n    The mask as a numpy array.', deprecated=None, examples=None, json_schema_extra=None, repr=False), 'indices': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='indices', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Return the indices of the voxels in the mask using Fortran/SITK convention.\n\nReturns\n-------\nnp.ndarray\n    The indices of the voxels.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'indices_numpy': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='indicesNumpy', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Return the indices of the voxels in the mask using C/numpy convention.\n\nReturns\n-------\nnp.ndarray\n    The indices of the voxels.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'num_of_scenarios': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'int'>, alias='numOfScenarios', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns the number of scenarios.\n\nReturns\n-------\nint\n    The number of scenarios.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'scenario_ct_data': ComputedFieldInfo(wrapped_property=<property object>, return_type=typing.Union[list[numpy.ndarray], numpy.ndarray], alias='scenarioCtData', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns a list of CT data for the individual scenarios.\n\nReturns\n-------\nList[np.ndarray]\n    The CT data for the individual scenarios.', deprecated=None, examples=None, json_schema_extra=None, repr=True)}#
model_config: ClassVar[ConfigDict] = {'alias_generator': AliasGenerator(alias=<function to_camel>, validation_alias=None, serialization_alias=None), 'arbitrary_types_allowed': True, 'from_attributes': True, 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod model_construct(_fields_set=None, **values)#

Creates a new instance of the Model class with validated data.

Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.

!!! note

model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.

Parameters:
  • _fields_set (set[str] | None) – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.

  • values (Any) – Trusted or pre-validated data dictionary.

Return type:

Self

Returns:

A new instance of the Model class with validated data.

model_copy(*, update=None, deep=False)#
!!! abstract “Usage Documentation”

[model_copy](../concepts/models.md#model-copy)

Returns a copy of the model.

!!! note

The underlying instance’s [__dict__][object.__dict__] attribute is copied. This might have unexpected side effects if you store anything in it, on top of the model fields (e.g. the value of [cached properties][functools.cached_property]).

Parameters:
  • update (Mapping[str, Any] | None) – Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data.

  • deep (bool) – Set to True to make a deep copy of the model.

Return type:

Self

Returns:

New model instance.

model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False, polymorphic_serialization=None)#
!!! abstract “Usage Documentation”

[model_dump](../concepts/serialization.md#python-mode)

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Parameters:
  • mode (Union[Literal['json', 'python'], str]) – The mode in which to_python should run. If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.

  • include (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – A set of fields to include in the output.

  • exclude (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – A set of fields to exclude from the output.

  • context (Any | None) – Additional context to pass to the serializer.

  • by_alias (bool | None) – Whether to use the field’s alias in the dictionary key if defined.

  • exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) – Whether to exclude fields that are set to their default value.

  • exclude_none (bool) – Whether to exclude fields that have a value of None.

  • exclude_computed_fields (bool) – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (Union[bool, Literal['none', 'warn', 'error']]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback (Optional[Callable[[Any], Any]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.

  • polymorphic_serialization (bool | None) – Whether to use model and dataclass polymorphic serialization for this call.

Return type:

dict[str, Any]

Returns:

A dictionary representation of the model.

model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False, polymorphic_serialization=None)#
!!! abstract “Usage Documentation”

[model_dump_json](../concepts/serialization.md#json-mode)

Generates a JSON representation of the model using Pydantic’s to_json method.

Parameters:
  • indent (int | None) – Indentation to use in the JSON output. If None is passed, the output will be compact.

  • ensure_ascii (bool) – If True, the output is guaranteed to have all incoming non-ASCII characters escaped. If False (the default), these characters will be output as-is.

  • include (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – Field(s) to include in the JSON output.

  • exclude (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – Field(s) to exclude from the JSON output.

  • context (Any | None) – Additional context to pass to the serializer.

  • by_alias (bool | None) – Whether to serialize using field aliases.

  • exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) – Whether to exclude fields that are set to their default value.

  • exclude_none (bool) – Whether to exclude fields that have a value of None.

  • exclude_computed_fields (bool) – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (Union[bool, Literal['none', 'warn', 'error']]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback (Optional[Callable[[Any], Any]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.

  • polymorphic_serialization (bool | None) – Whether to use model and dataclass polymorphic serialization for this call.

Return type:

str

Returns:

A JSON string representation of the model.

property model_extra: dict[str, Any] | None#

Get extra fields set during validation.

Returns:

A dictionary of extra fields, or None if config.extra is not set to “allow”.

model_fields = {'alpha_x': FieldInfo(annotation=float, required=False, default=0.1, alias='alphaX', alias_priority=1), 'beta_x': FieldInfo(annotation=float, required=False, default=0.05, alias='betaX', alias_priority=1), 'ct_image': FieldInfo(annotation=CT, required=True, alias='ctImage', alias_priority=1), 'default_color': FieldInfo(annotation=tuple[int, int, int], required=False, default_factory=<lambda>, alias='defaultColor', alias_priority=1, description='Default RGB color bound to the VOI type'), 'mask': FieldInfo(annotation=Image, required=True, alias='mask', alias_priority=1), 'name': FieldInfo(annotation=str, required=True, alias='name', alias_priority=1), 'objectives': FieldInfo(annotation=list[Any], required=False, default=[], alias='objectives', alias_priority=1, description='List of objective function definitions'), 'overlap_priority': FieldInfo(annotation=int, required=False, default_factory=<lambda>, alias='Priority', alias_priority=2), 'visible': FieldInfo(annotation=bool, required=False, default=True, alias='visible', alias_priority=1, description='Flag to set visibility in GUI applications'), 'visible_color': FieldInfo(annotation=Union[tuple[int, int, int], NoneType], required=False, default=None, alias='visibleColor', alias_priority=1, description='RGB color for visualization in GUI applications'), 'voi_type': FieldInfo(annotation=str, required=False, default='OAR', alias='voiType', alias_priority=1)}#
property model_fields_set: set[str]#

Returns the set of fields that have been explicitly set on this model instance.

Returns:

A set of strings representing the fields that have been set,

i.e. that were not filled from defaults.

classmethod model_json_schema(by_alias=True, ref_template='#/$defs/{model}', schema_generator=<class 'pydantic.json_schema.GenerateJsonSchema'>, mode='validation', *, union_format='any_of')#

Generates a JSON schema for a model class.

Parameters:
  • by_alias (bool) – Whether to use attribute aliases or not.

  • ref_template (str) – The reference template.

  • union_format (Literal['any_of', 'primitive_type_array']) –

    The format to use when combining schemas from unions together. Can be one of:

    keyword to combine schemas (the default). - ‘primitive_type_array’: Use the [type](https://json-schema.org/understanding-json-schema/reference/type) keyword as an array of strings, containing each type of the combination. If any of the schemas is not a primitive type (string, boolean, null, integer or number) or contains constraints/metadata, falls back to any_of.

  • schema_generator (type[GenerateJsonSchema]) – To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modifications

  • mode (Literal['validation', 'serialization']) – The mode in which to generate the schema.

Return type:

dict[str, Any]

Returns:

The JSON schema for the given model class.

classmethod model_parametrized_name(params)#

Compute the class name for parametrizations of generic classes.

This method can be overridden to achieve a custom naming scheme for generic BaseModels.

Parameters:

params (tuple[type[Any], ...]) – Tuple of types of the class. Given a generic class Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.

Return type:

str

Returns:

String representing the new class where params are passed to cls as type variables.

Raises:

TypeError – Raised when trying to generate concrete names for non-generic models.

model_post_init(context, /)#

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

Return type:

None

classmethod model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)#

Try to rebuild the pydantic-core schema for the model.

This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.

Parameters:
  • force (bool) – Whether to force the rebuilding of the model schema, defaults to False.

  • raise_errors (bool) – Whether to raise errors, defaults to True.

  • _parent_namespace_depth (int) – The depth level of the parent namespace, defaults to 2.

  • _types_namespace (Mapping[str, Any] | None) – The types namespace, defaults to None.

Return type:

bool | None

Returns:

Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.

classmethod model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)#

Validate a pydantic model instance.

Parameters:
  • obj (Any) – The object to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • from_attributes (bool | None) – Whether to extract data from object attributes.

  • context (Any | None) – Additional context to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Raises:

ValidationError – If the object could not be validated.

Return type:

Self

Returns:

The validated model instance.

classmethod model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)#
!!! abstract “Usage Documentation”

[JSON Parsing](../concepts/json.md#json-parsing)

Validate the given JSON data against the Pydantic model.

Parameters:
  • json_data (str | bytes | bytearray) – The JSON data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Return type:

Self

Returns:

The validated Pydantic model.

Raises:

ValidationError – If json_data is not a JSON string or the object could not be validated.

classmethod model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)#

Validate the given object with string data against the Pydantic model.

Parameters:
  • obj (Any) – The object containing string data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Return type:

Self

Returns:

The validated Pydantic model.

name: str#
property num_of_scenarios: int#

Returns the number of scenarios.

Returns:

The number of scenarios.

Return type:

int

objectives: list[Any]#
overlap_priority: int#
classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Self

classmethod parse_obj(obj)#
Return type:

Self

classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Self

resample_on_new_ct(new_ct)#

Resample on new CT image.

Parameters:

new_ct (CT) – The new CT image to resample the VOI on.

Returns:

The resampled VOI.

Return type:

Self

property scenario_ct_data: list[ndarray] | ndarray#

Returns a list of CT data for the individual scenarios.

Returns:

The CT data for the individual scenarios.

Return type:

List[np.ndarray]

scenario_indices(order_type='numpy')#

Return the flattened indices of the individual scenarios.

Parameters:

order_type (str, optional) – The order type. Defaults to “numpy”.

Returns:

The flattened indices of the individual scenarios.

Return type:

Union[ndarray, list[ndarray]]

classmethod schema(by_alias=True, ref_template='#/$defs/{model}')#
Return type:

Dict[str, Any]

classmethod schema_json(*, by_alias=True, ref_template='#/$defs/{model}', **dumps_kwargs)#
Return type:

str

to_matrad(context='mat-file')#

Create an object that can be interpreted by matRad in the given context.

Returns:

VOI as list to write cell arrays.

Return type:

Any

classmethod update_forward_refs(**localns)#
Return type:

None

classmethod validate(value)#
Return type:

Self

validate_mask()#

Check if the given indices are valid for the CT image.

Raises:
  • ValueError – If the mask is not a sitk.Image.

  • ValueError – If the dimensions of the mask do not match the CT image.

classmethod validate_mask_type(v)#

Validate the mask type.

Parameters:

v (Any) – The mask value to be validated.

Returns:

The validated mask.

Return type:

Any

Raises:

ValueError – If the mask type is not supported.

classmethod validate_visible_color(v)#

Validate the visible color.

Parameters:

v (Any) – The visible color value to be validated.

Returns:

The validated visible color.

Return type:

Any

classmethod validate_voi_type(v)[source]#

Validate the voi type for an OAR.

Parameters:

v (str) – The voi type to be validated.

Returns:

The validated voi type.

Return type:

str

Raises:

ValueError – If the voi type is not “OAR”.

visible: bool#
visible_color: tuple[int, int, int] | None#
voi_type: str#
class Target(**data)[source]#

Bases: VOI

Represents a target VOI.

Inherits all attributes from Plan.
voi_type : str

Returns the voi_type as ‘TARGET’.

Attributes:
indices

Return the indices of the voxels in the mask using Fortran/SITK convention.

indices_numpy

Return the indices of the voxels in the mask using C/numpy convention.

model_extra

Get extra fields set during validation.

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

num_of_scenarios

Returns the number of scenarios.

scenario_ct_data

Returns a list of CT data for the individual scenarios.

Methods

copy(*[, include, exclude, update, deep])

Returns a copy of the model.

get_indices([order])

Return the indices of the voxels in the mask.

masked_ct([order_type])

Return the masked CT image, either as a numpy array or a SimpleITK image.

model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

model_dump(*[, mode, include, exclude, ...])

!!! abstract "Usage Documentation"

model_dump_json(*[, indent, ensure_ascii, ...])

!!! abstract "Usage Documentation"

model_json_schema([by_alias, ref_template, ...])

Generates a JSON schema for a model class.

model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

model_post_init(context, /)

Override this method to perform additional initialization after __init__ and model_construct.

model_rebuild(*[, force, raise_errors, ...])

Try to rebuild the pydantic-core schema for the model.

model_validate(obj, *[, strict, extra, ...])

Validate a pydantic model instance.

model_validate_json(json_data, *[, strict, ...])

!!! abstract "Usage Documentation"

model_validate_strings(obj, *[, strict, ...])

Validate the given object with string data against the Pydantic model.

resample_on_new_ct(new_ct)

Resample on new CT image.

scenario_indices([order_type])

Return the flattened indices of the individual scenarios.

to_matrad([context])

Create an object that can be interpreted by matRad in the given context.

validate_mask()

Check if the given indices are valid for the CT image.

validate_mask_type(v)

Validate the mask type.

validate_visible_color(v)

Validate the visible color.

validate_voi_type(v)

Validate the voi type for a Target.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

alpha_x: float#
beta_x: float#
classmethod construct(_fields_set=None, **values)#
Return type:

Self

copy(*, include=None, exclude=None, update=None, deep=False)#

Returns a copy of the model.

!!! warning “Deprecated”

This method is now deprecated; use model_copy instead.

If you need include or exclude, use:

`python {test="skip" lint="skip"} data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `

Parameters:
  • include (Set[int] | Set[str] | Mapping[int, Any] | Mapping[str, Any] | None) – Optional set or mapping specifying which fields to include in the copied model.

  • exclude (Set[int] | Set[str] | Mapping[int, Any] | Mapping[str, Any] | None) – Optional set or mapping specifying which fields to exclude in the copied model.

  • update (Optional[Dict[str, Any]]) – Optional dictionary of field-value pairs to override field values in the copied model.

  • deep (bool) – If True, the values of fields that are Pydantic models will be deep-copied.

Return type:

Self

Returns:

A copy of the model with included, excluded and updated fields as specified.

ct_image: CT#
default_color: tuple[int, int, int]#
dict(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)#
Return type:

Dict[str, Any]

classmethod from_orm(obj)#
Return type:

Self

get_indices(order='sitk')#

Return the indices of the voxels in the mask.

Parameters:

order (str, optional) – The order of the indices. Defaults to “sitk”.

Returns:

The indices of the voxels.

Return type:

ndarray

property indices: ndarray#

Return the indices of the voxels in the mask using Fortran/SITK convention.

Returns:

The indices of the voxels.

Return type:

np.ndarray

property indices_numpy: ndarray#

Return the indices of the voxels in the mask using C/numpy convention.

Returns:

The indices of the voxels.

Return type:

np.ndarray

json(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=PydanticUndefined, models_as_dict=PydanticUndefined, **dumps_kwargs)#
Return type:

str

mask: Image#
masked_ct(order_type='numpy')#

Return the masked CT image, either as a numpy array or a SimpleITK image.

Parameters:

order_type (str, optional) – The order type. Defaults to “numpy”.

Returns:

The masked CT image.

Return type:

Union[Image, ndarray]

model_computed_fields = {'_numpy_mask': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='_numpyMask', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns the mask as a numpy array.\n\nReturns\n-------\nnp.ndarray\n    The mask as a numpy array.', deprecated=None, examples=None, json_schema_extra=None, repr=False), 'indices': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='indices', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Return the indices of the voxels in the mask using Fortran/SITK convention.\n\nReturns\n-------\nnp.ndarray\n    The indices of the voxels.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'indices_numpy': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='indicesNumpy', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Return the indices of the voxels in the mask using C/numpy convention.\n\nReturns\n-------\nnp.ndarray\n    The indices of the voxels.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'num_of_scenarios': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'int'>, alias='numOfScenarios', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns the number of scenarios.\n\nReturns\n-------\nint\n    The number of scenarios.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'scenario_ct_data': ComputedFieldInfo(wrapped_property=<property object>, return_type=typing.Union[list[numpy.ndarray], numpy.ndarray], alias='scenarioCtData', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns a list of CT data for the individual scenarios.\n\nReturns\n-------\nList[np.ndarray]\n    The CT data for the individual scenarios.', deprecated=None, examples=None, json_schema_extra=None, repr=True)}#
model_config: ClassVar[ConfigDict] = {'alias_generator': AliasGenerator(alias=<function to_camel>, validation_alias=None, serialization_alias=None), 'arbitrary_types_allowed': True, 'from_attributes': True, 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod model_construct(_fields_set=None, **values)#

Creates a new instance of the Model class with validated data.

Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.

!!! note

model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.

Parameters:
  • _fields_set (set[str] | None) – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.

  • values (Any) – Trusted or pre-validated data dictionary.

Return type:

Self

Returns:

A new instance of the Model class with validated data.

model_copy(*, update=None, deep=False)#
!!! abstract “Usage Documentation”

[model_copy](../concepts/models.md#model-copy)

Returns a copy of the model.

!!! note

The underlying instance’s [__dict__][object.__dict__] attribute is copied. This might have unexpected side effects if you store anything in it, on top of the model fields (e.g. the value of [cached properties][functools.cached_property]).

Parameters:
  • update (Mapping[str, Any] | None) – Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data.

  • deep (bool) – Set to True to make a deep copy of the model.

Return type:

Self

Returns:

New model instance.

model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False, polymorphic_serialization=None)#
!!! abstract “Usage Documentation”

[model_dump](../concepts/serialization.md#python-mode)

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Parameters:
  • mode (Union[Literal['json', 'python'], str]) – The mode in which to_python should run. If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.

  • include (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – A set of fields to include in the output.

  • exclude (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – A set of fields to exclude from the output.

  • context (Any | None) – Additional context to pass to the serializer.

  • by_alias (bool | None) – Whether to use the field’s alias in the dictionary key if defined.

  • exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) – Whether to exclude fields that are set to their default value.

  • exclude_none (bool) – Whether to exclude fields that have a value of None.

  • exclude_computed_fields (bool) – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (Union[bool, Literal['none', 'warn', 'error']]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback (Optional[Callable[[Any], Any]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.

  • polymorphic_serialization (bool | None) – Whether to use model and dataclass polymorphic serialization for this call.

Return type:

dict[str, Any]

Returns:

A dictionary representation of the model.

model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False, polymorphic_serialization=None)#
!!! abstract “Usage Documentation”

[model_dump_json](../concepts/serialization.md#json-mode)

Generates a JSON representation of the model using Pydantic’s to_json method.

Parameters:
  • indent (int | None) – Indentation to use in the JSON output. If None is passed, the output will be compact.

  • ensure_ascii (bool) – If True, the output is guaranteed to have all incoming non-ASCII characters escaped. If False (the default), these characters will be output as-is.

  • include (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – Field(s) to include in the JSON output.

  • exclude (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – Field(s) to exclude from the JSON output.

  • context (Any | None) – Additional context to pass to the serializer.

  • by_alias (bool | None) – Whether to serialize using field aliases.

  • exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) – Whether to exclude fields that are set to their default value.

  • exclude_none (bool) – Whether to exclude fields that have a value of None.

  • exclude_computed_fields (bool) – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (Union[bool, Literal['none', 'warn', 'error']]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback (Optional[Callable[[Any], Any]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.

  • polymorphic_serialization (bool | None) – Whether to use model and dataclass polymorphic serialization for this call.

Return type:

str

Returns:

A JSON string representation of the model.

property model_extra: dict[str, Any] | None#

Get extra fields set during validation.

Returns:

A dictionary of extra fields, or None if config.extra is not set to “allow”.

model_fields = {'alpha_x': FieldInfo(annotation=float, required=False, default=0.1, alias='alphaX', alias_priority=1), 'beta_x': FieldInfo(annotation=float, required=False, default=0.05, alias='betaX', alias_priority=1), 'ct_image': FieldInfo(annotation=CT, required=True, alias='ctImage', alias_priority=1), 'default_color': FieldInfo(annotation=tuple[int, int, int], required=False, default_factory=<lambda>, alias='defaultColor', alias_priority=1, description='Default RGB color bound to the VOI type'), 'mask': FieldInfo(annotation=Image, required=True, alias='mask', alias_priority=1), 'name': FieldInfo(annotation=str, required=True, alias='name', alias_priority=1), 'objectives': FieldInfo(annotation=list[Any], required=False, default=[], alias='objectives', alias_priority=1, description='List of objective function definitions'), 'overlap_priority': FieldInfo(annotation=int, required=False, default_factory=<lambda>, alias='Priority', alias_priority=2), 'visible': FieldInfo(annotation=bool, required=False, default=True, alias='visible', alias_priority=1, description='Flag to set visibility in GUI applications'), 'visible_color': FieldInfo(annotation=Union[tuple[int, int, int], NoneType], required=False, default=None, alias='visibleColor', alias_priority=1, description='RGB color for visualization in GUI applications'), 'voi_type': FieldInfo(annotation=str, required=False, default='TARGET', alias='voiType', alias_priority=1)}#
property model_fields_set: set[str]#

Returns the set of fields that have been explicitly set on this model instance.

Returns:

A set of strings representing the fields that have been set,

i.e. that were not filled from defaults.

classmethod model_json_schema(by_alias=True, ref_template='#/$defs/{model}', schema_generator=<class 'pydantic.json_schema.GenerateJsonSchema'>, mode='validation', *, union_format='any_of')#

Generates a JSON schema for a model class.

Parameters:
  • by_alias (bool) – Whether to use attribute aliases or not.

  • ref_template (str) – The reference template.

  • union_format (Literal['any_of', 'primitive_type_array']) –

    The format to use when combining schemas from unions together. Can be one of:

    keyword to combine schemas (the default). - ‘primitive_type_array’: Use the [type](https://json-schema.org/understanding-json-schema/reference/type) keyword as an array of strings, containing each type of the combination. If any of the schemas is not a primitive type (string, boolean, null, integer or number) or contains constraints/metadata, falls back to any_of.

  • schema_generator (type[GenerateJsonSchema]) – To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modifications

  • mode (Literal['validation', 'serialization']) – The mode in which to generate the schema.

Return type:

dict[str, Any]

Returns:

The JSON schema for the given model class.

classmethod model_parametrized_name(params)#

Compute the class name for parametrizations of generic classes.

This method can be overridden to achieve a custom naming scheme for generic BaseModels.

Parameters:

params (tuple[type[Any], ...]) – Tuple of types of the class. Given a generic class Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.

Return type:

str

Returns:

String representing the new class where params are passed to cls as type variables.

Raises:

TypeError – Raised when trying to generate concrete names for non-generic models.

model_post_init(context, /)#

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

Return type:

None

classmethod model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)#

Try to rebuild the pydantic-core schema for the model.

This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.

Parameters:
  • force (bool) – Whether to force the rebuilding of the model schema, defaults to False.

  • raise_errors (bool) – Whether to raise errors, defaults to True.

  • _parent_namespace_depth (int) – The depth level of the parent namespace, defaults to 2.

  • _types_namespace (Mapping[str, Any] | None) – The types namespace, defaults to None.

Return type:

bool | None

Returns:

Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.

classmethod model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)#

Validate a pydantic model instance.

Parameters:
  • obj (Any) – The object to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • from_attributes (bool | None) – Whether to extract data from object attributes.

  • context (Any | None) – Additional context to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Raises:

ValidationError – If the object could not be validated.

Return type:

Self

Returns:

The validated model instance.

classmethod model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)#
!!! abstract “Usage Documentation”

[JSON Parsing](../concepts/json.md#json-parsing)

Validate the given JSON data against the Pydantic model.

Parameters:
  • json_data (str | bytes | bytearray) – The JSON data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Return type:

Self

Returns:

The validated Pydantic model.

Raises:

ValidationError – If json_data is not a JSON string or the object could not be validated.

classmethod model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)#

Validate the given object with string data against the Pydantic model.

Parameters:
  • obj (Any) – The object containing string data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Return type:

Self

Returns:

The validated Pydantic model.

name: str#
property num_of_scenarios: int#

Returns the number of scenarios.

Returns:

The number of scenarios.

Return type:

int

objectives: list[Any]#
overlap_priority: int#
classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Self

classmethod parse_obj(obj)#
Return type:

Self

classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Self

resample_on_new_ct(new_ct)#

Resample on new CT image.

Parameters:

new_ct (CT) – The new CT image to resample the VOI on.

Returns:

The resampled VOI.

Return type:

Self

property scenario_ct_data: list[ndarray] | ndarray#

Returns a list of CT data for the individual scenarios.

Returns:

The CT data for the individual scenarios.

Return type:

List[np.ndarray]

scenario_indices(order_type='numpy')#

Return the flattened indices of the individual scenarios.

Parameters:

order_type (str, optional) – The order type. Defaults to “numpy”.

Returns:

The flattened indices of the individual scenarios.

Return type:

Union[ndarray, list[ndarray]]

classmethod schema(by_alias=True, ref_template='#/$defs/{model}')#
Return type:

Dict[str, Any]

classmethod schema_json(*, by_alias=True, ref_template='#/$defs/{model}', **dumps_kwargs)#
Return type:

str

to_matrad(context='mat-file')#

Create an object that can be interpreted by matRad in the given context.

Returns:

VOI as list to write cell arrays.

Return type:

Any

classmethod update_forward_refs(**localns)#
Return type:

None

classmethod validate(value)#
Return type:

Self

validate_mask()#

Check if the given indices are valid for the CT image.

Raises:
  • ValueError – If the mask is not a sitk.Image.

  • ValueError – If the dimensions of the mask do not match the CT image.

classmethod validate_mask_type(v)#

Validate the mask type.

Parameters:

v (Any) – The mask value to be validated.

Returns:

The validated mask.

Return type:

Any

Raises:

ValueError – If the mask type is not supported.

classmethod validate_visible_color(v)#

Validate the visible color.

Parameters:

v (Any) – The visible color value to be validated.

Returns:

The validated visible color.

Return type:

Any

classmethod validate_voi_type(v)[source]#

Validate the voi type for a Target.

Parameters:

v (str) – The voi type to be validated.

Returns:

The validated voi type.

Return type:

str

Raises:

ValueError – If the voi type is not “OAR”.

visible: bool#
visible_color: tuple[int, int, int] | None#
voi_type: str#
class HelperVOI(**data)[source]#

Bases: VOI

Represents a helper VOI.

Inherits all attributes from Plan.
voi_type : str

Returns the voi_type as ‘HELPER’.

Attributes:
indices

Return the indices of the voxels in the mask using Fortran/SITK convention.

indices_numpy

Return the indices of the voxels in the mask using C/numpy convention.

model_extra

Get extra fields set during validation.

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

num_of_scenarios

Returns the number of scenarios.

scenario_ct_data

Returns a list of CT data for the individual scenarios.

Methods

copy(*[, include, exclude, update, deep])

Returns a copy of the model.

get_indices([order])

Return the indices of the voxels in the mask.

masked_ct([order_type])

Return the masked CT image, either as a numpy array or a SimpleITK image.

model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

model_dump(*[, mode, include, exclude, ...])

!!! abstract "Usage Documentation"

model_dump_json(*[, indent, ensure_ascii, ...])

!!! abstract "Usage Documentation"

model_json_schema([by_alias, ref_template, ...])

Generates a JSON schema for a model class.

model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

model_post_init(context, /)

Override this method to perform additional initialization after __init__ and model_construct.

model_rebuild(*[, force, raise_errors, ...])

Try to rebuild the pydantic-core schema for the model.

model_validate(obj, *[, strict, extra, ...])

Validate a pydantic model instance.

model_validate_json(json_data, *[, strict, ...])

!!! abstract "Usage Documentation"

model_validate_strings(obj, *[, strict, ...])

Validate the given object with string data against the Pydantic model.

resample_on_new_ct(new_ct)

Resample on new CT image.

scenario_indices([order_type])

Return the flattened indices of the individual scenarios.

to_matrad([context])

Create an object that can be interpreted by matRad in the given context.

validate_mask()

Check if the given indices are valid for the CT image.

validate_mask_type(v)

Validate the mask type.

validate_visible_color(v)

Validate the visible color.

validate_voi_type(v)

Validate the voi type for a HelperVOI.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

alpha_x: float#
beta_x: float#
classmethod construct(_fields_set=None, **values)#
Return type:

Self

copy(*, include=None, exclude=None, update=None, deep=False)#

Returns a copy of the model.

!!! warning “Deprecated”

This method is now deprecated; use model_copy instead.

If you need include or exclude, use:

`python {test="skip" lint="skip"} data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `

Parameters:
  • include (Set[int] | Set[str] | Mapping[int, Any] | Mapping[str, Any] | None) – Optional set or mapping specifying which fields to include in the copied model.

  • exclude (Set[int] | Set[str] | Mapping[int, Any] | Mapping[str, Any] | None) – Optional set or mapping specifying which fields to exclude in the copied model.

  • update (Optional[Dict[str, Any]]) – Optional dictionary of field-value pairs to override field values in the copied model.

  • deep (bool) – If True, the values of fields that are Pydantic models will be deep-copied.

Return type:

Self

Returns:

A copy of the model with included, excluded and updated fields as specified.

ct_image: CT#
default_color: tuple[int, int, int]#
dict(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)#
Return type:

Dict[str, Any]

classmethod from_orm(obj)#
Return type:

Self

get_indices(order='sitk')#

Return the indices of the voxels in the mask.

Parameters:

order (str, optional) – The order of the indices. Defaults to “sitk”.

Returns:

The indices of the voxels.

Return type:

ndarray

property indices: ndarray#

Return the indices of the voxels in the mask using Fortran/SITK convention.

Returns:

The indices of the voxels.

Return type:

np.ndarray

property indices_numpy: ndarray#

Return the indices of the voxels in the mask using C/numpy convention.

Returns:

The indices of the voxels.

Return type:

np.ndarray

json(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=PydanticUndefined, models_as_dict=PydanticUndefined, **dumps_kwargs)#
Return type:

str

mask: Image#
masked_ct(order_type='numpy')#

Return the masked CT image, either as a numpy array or a SimpleITK image.

Parameters:

order_type (str, optional) – The order type. Defaults to “numpy”.

Returns:

The masked CT image.

Return type:

Union[Image, ndarray]

model_computed_fields = {'_numpy_mask': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='_numpyMask', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns the mask as a numpy array.\n\nReturns\n-------\nnp.ndarray\n    The mask as a numpy array.', deprecated=None, examples=None, json_schema_extra=None, repr=False), 'indices': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='indices', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Return the indices of the voxels in the mask using Fortran/SITK convention.\n\nReturns\n-------\nnp.ndarray\n    The indices of the voxels.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'indices_numpy': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='indicesNumpy', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Return the indices of the voxels in the mask using C/numpy convention.\n\nReturns\n-------\nnp.ndarray\n    The indices of the voxels.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'num_of_scenarios': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'int'>, alias='numOfScenarios', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns the number of scenarios.\n\nReturns\n-------\nint\n    The number of scenarios.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'scenario_ct_data': ComputedFieldInfo(wrapped_property=<property object>, return_type=typing.Union[list[numpy.ndarray], numpy.ndarray], alias='scenarioCtData', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns a list of CT data for the individual scenarios.\n\nReturns\n-------\nList[np.ndarray]\n    The CT data for the individual scenarios.', deprecated=None, examples=None, json_schema_extra=None, repr=True)}#
model_config: ClassVar[ConfigDict] = {'alias_generator': AliasGenerator(alias=<function to_camel>, validation_alias=None, serialization_alias=None), 'arbitrary_types_allowed': True, 'from_attributes': True, 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod model_construct(_fields_set=None, **values)#

Creates a new instance of the Model class with validated data.

Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.

!!! note

model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.

Parameters:
  • _fields_set (set[str] | None) – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.

  • values (Any) – Trusted or pre-validated data dictionary.

Return type:

Self

Returns:

A new instance of the Model class with validated data.

model_copy(*, update=None, deep=False)#
!!! abstract “Usage Documentation”

[model_copy](../concepts/models.md#model-copy)

Returns a copy of the model.

!!! note

The underlying instance’s [__dict__][object.__dict__] attribute is copied. This might have unexpected side effects if you store anything in it, on top of the model fields (e.g. the value of [cached properties][functools.cached_property]).

Parameters:
  • update (Mapping[str, Any] | None) – Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data.

  • deep (bool) – Set to True to make a deep copy of the model.

Return type:

Self

Returns:

New model instance.

model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False, polymorphic_serialization=None)#
!!! abstract “Usage Documentation”

[model_dump](../concepts/serialization.md#python-mode)

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Parameters:
  • mode (Union[Literal['json', 'python'], str]) – The mode in which to_python should run. If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.

  • include (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – A set of fields to include in the output.

  • exclude (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – A set of fields to exclude from the output.

  • context (Any | None) – Additional context to pass to the serializer.

  • by_alias (bool | None) – Whether to use the field’s alias in the dictionary key if defined.

  • exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) – Whether to exclude fields that are set to their default value.

  • exclude_none (bool) – Whether to exclude fields that have a value of None.

  • exclude_computed_fields (bool) – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (Union[bool, Literal['none', 'warn', 'error']]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback (Optional[Callable[[Any], Any]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.

  • polymorphic_serialization (bool | None) – Whether to use model and dataclass polymorphic serialization for this call.

Return type:

dict[str, Any]

Returns:

A dictionary representation of the model.

model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False, polymorphic_serialization=None)#
!!! abstract “Usage Documentation”

[model_dump_json](../concepts/serialization.md#json-mode)

Generates a JSON representation of the model using Pydantic’s to_json method.

Parameters:
  • indent (int | None) – Indentation to use in the JSON output. If None is passed, the output will be compact.

  • ensure_ascii (bool) – If True, the output is guaranteed to have all incoming non-ASCII characters escaped. If False (the default), these characters will be output as-is.

  • include (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – Field(s) to include in the JSON output.

  • exclude (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – Field(s) to exclude from the JSON output.

  • context (Any | None) – Additional context to pass to the serializer.

  • by_alias (bool | None) – Whether to serialize using field aliases.

  • exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) – Whether to exclude fields that are set to their default value.

  • exclude_none (bool) – Whether to exclude fields that have a value of None.

  • exclude_computed_fields (bool) – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (Union[bool, Literal['none', 'warn', 'error']]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback (Optional[Callable[[Any], Any]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.

  • polymorphic_serialization (bool | None) – Whether to use model and dataclass polymorphic serialization for this call.

Return type:

str

Returns:

A JSON string representation of the model.

property model_extra: dict[str, Any] | None#

Get extra fields set during validation.

Returns:

A dictionary of extra fields, or None if config.extra is not set to “allow”.

model_fields = {'alpha_x': FieldInfo(annotation=float, required=False, default=0.1, alias='alphaX', alias_priority=1), 'beta_x': FieldInfo(annotation=float, required=False, default=0.05, alias='betaX', alias_priority=1), 'ct_image': FieldInfo(annotation=CT, required=True, alias='ctImage', alias_priority=1), 'default_color': FieldInfo(annotation=tuple[int, int, int], required=False, default_factory=<lambda>, alias='defaultColor', alias_priority=1, description='Default RGB color bound to the VOI type'), 'mask': FieldInfo(annotation=Image, required=True, alias='mask', alias_priority=1), 'name': FieldInfo(annotation=str, required=True, alias='name', alias_priority=1), 'objectives': FieldInfo(annotation=list[Any], required=False, default=[], alias='objectives', alias_priority=1, description='List of objective function definitions'), 'overlap_priority': FieldInfo(annotation=int, required=False, default_factory=<lambda>, alias='Priority', alias_priority=2), 'visible': FieldInfo(annotation=bool, required=False, default=True, alias='visible', alias_priority=1, description='Flag to set visibility in GUI applications'), 'visible_color': FieldInfo(annotation=Union[tuple[int, int, int], NoneType], required=False, default=None, alias='visibleColor', alias_priority=1, description='RGB color for visualization in GUI applications'), 'voi_type': FieldInfo(annotation=str, required=False, default='HELPER', alias='voiType', alias_priority=1)}#
property model_fields_set: set[str]#

Returns the set of fields that have been explicitly set on this model instance.

Returns:

A set of strings representing the fields that have been set,

i.e. that were not filled from defaults.

classmethod model_json_schema(by_alias=True, ref_template='#/$defs/{model}', schema_generator=<class 'pydantic.json_schema.GenerateJsonSchema'>, mode='validation', *, union_format='any_of')#

Generates a JSON schema for a model class.

Parameters:
  • by_alias (bool) – Whether to use attribute aliases or not.

  • ref_template (str) – The reference template.

  • union_format (Literal['any_of', 'primitive_type_array']) –

    The format to use when combining schemas from unions together. Can be one of:

    keyword to combine schemas (the default). - ‘primitive_type_array’: Use the [type](https://json-schema.org/understanding-json-schema/reference/type) keyword as an array of strings, containing each type of the combination. If any of the schemas is not a primitive type (string, boolean, null, integer or number) or contains constraints/metadata, falls back to any_of.

  • schema_generator (type[GenerateJsonSchema]) – To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modifications

  • mode (Literal['validation', 'serialization']) – The mode in which to generate the schema.

Return type:

dict[str, Any]

Returns:

The JSON schema for the given model class.

classmethod model_parametrized_name(params)#

Compute the class name for parametrizations of generic classes.

This method can be overridden to achieve a custom naming scheme for generic BaseModels.

Parameters:

params (tuple[type[Any], ...]) – Tuple of types of the class. Given a generic class Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.

Return type:

str

Returns:

String representing the new class where params are passed to cls as type variables.

Raises:

TypeError – Raised when trying to generate concrete names for non-generic models.

model_post_init(context, /)#

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

Return type:

None

classmethod model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)#

Try to rebuild the pydantic-core schema for the model.

This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.

Parameters:
  • force (bool) – Whether to force the rebuilding of the model schema, defaults to False.

  • raise_errors (bool) – Whether to raise errors, defaults to True.

  • _parent_namespace_depth (int) – The depth level of the parent namespace, defaults to 2.

  • _types_namespace (Mapping[str, Any] | None) – The types namespace, defaults to None.

Return type:

bool | None

Returns:

Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.

classmethod model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)#

Validate a pydantic model instance.

Parameters:
  • obj (Any) – The object to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • from_attributes (bool | None) – Whether to extract data from object attributes.

  • context (Any | None) – Additional context to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Raises:

ValidationError – If the object could not be validated.

Return type:

Self

Returns:

The validated model instance.

classmethod model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)#
!!! abstract “Usage Documentation”

[JSON Parsing](../concepts/json.md#json-parsing)

Validate the given JSON data against the Pydantic model.

Parameters:
  • json_data (str | bytes | bytearray) – The JSON data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Return type:

Self

Returns:

The validated Pydantic model.

Raises:

ValidationError – If json_data is not a JSON string or the object could not be validated.

classmethod model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)#

Validate the given object with string data against the Pydantic model.

Parameters:
  • obj (Any) – The object containing string data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Return type:

Self

Returns:

The validated Pydantic model.

name: str#
property num_of_scenarios: int#

Returns the number of scenarios.

Returns:

The number of scenarios.

Return type:

int

objectives: list[Any]#
overlap_priority: int#
classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Self

classmethod parse_obj(obj)#
Return type:

Self

classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Self

resample_on_new_ct(new_ct)#

Resample on new CT image.

Parameters:

new_ct (CT) – The new CT image to resample the VOI on.

Returns:

The resampled VOI.

Return type:

Self

property scenario_ct_data: list[ndarray] | ndarray#

Returns a list of CT data for the individual scenarios.

Returns:

The CT data for the individual scenarios.

Return type:

List[np.ndarray]

scenario_indices(order_type='numpy')#

Return the flattened indices of the individual scenarios.

Parameters:

order_type (str, optional) – The order type. Defaults to “numpy”.

Returns:

The flattened indices of the individual scenarios.

Return type:

Union[ndarray, list[ndarray]]

classmethod schema(by_alias=True, ref_template='#/$defs/{model}')#
Return type:

Dict[str, Any]

classmethod schema_json(*, by_alias=True, ref_template='#/$defs/{model}', **dumps_kwargs)#
Return type:

str

to_matrad(context='mat-file')#

Create an object that can be interpreted by matRad in the given context.

Returns:

VOI as list to write cell arrays.

Return type:

Any

classmethod update_forward_refs(**localns)#
Return type:

None

classmethod validate(value)#
Return type:

Self

validate_mask()#

Check if the given indices are valid for the CT image.

Raises:
  • ValueError – If the mask is not a sitk.Image.

  • ValueError – If the dimensions of the mask do not match the CT image.

classmethod validate_mask_type(v)#

Validate the mask type.

Parameters:

v (Any) – The mask value to be validated.

Returns:

The validated mask.

Return type:

Any

Raises:

ValueError – If the mask type is not supported.

classmethod validate_visible_color(v)#

Validate the visible color.

Parameters:

v (Any) – The visible color value to be validated.

Returns:

The validated visible color.

Return type:

Any

classmethod validate_voi_type(v)[source]#

Validate the voi type for a HelperVOI.

Parameters:

v (str) – The voi type to be validated.

Returns:

The validated voi type.

Return type:

str

Raises:

ValueError – If the voi type is not “HELPER”.

visible: bool#
visible_color: tuple[int, int, int] | None#
voi_type: str#
class ExternalVOI(**data)[source]#

Bases: VOI

Represents an external contour limiting voxels to be considered for planning (EXTERNAL).

Inherits all attributes from Plan.
voi_type : str

Returns the voi_type as ‘EXTERNAL’.

Attributes:
indices

Return the indices of the voxels in the mask using Fortran/SITK convention.

indices_numpy

Return the indices of the voxels in the mask using C/numpy convention.

model_extra

Get extra fields set during validation.

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

num_of_scenarios

Returns the number of scenarios.

scenario_ct_data

Returns a list of CT data for the individual scenarios.

Methods

copy(*[, include, exclude, update, deep])

Returns a copy of the model.

get_indices([order])

Return the indices of the voxels in the mask.

masked_ct([order_type])

Return the masked CT image, either as a numpy array or a SimpleITK image.

model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

model_dump(*[, mode, include, exclude, ...])

!!! abstract "Usage Documentation"

model_dump_json(*[, indent, ensure_ascii, ...])

!!! abstract "Usage Documentation"

model_json_schema([by_alias, ref_template, ...])

Generates a JSON schema for a model class.

model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

model_post_init(context, /)

Override this method to perform additional initialization after __init__ and model_construct.

model_rebuild(*[, force, raise_errors, ...])

Try to rebuild the pydantic-core schema for the model.

model_validate(obj, *[, strict, extra, ...])

Validate a pydantic model instance.

model_validate_json(json_data, *[, strict, ...])

!!! abstract "Usage Documentation"

model_validate_strings(obj, *[, strict, ...])

Validate the given object with string data against the Pydantic model.

resample_on_new_ct(new_ct)

Resample on new CT image.

scenario_indices([order_type])

Return the flattened indices of the individual scenarios.

to_matrad([context])

Create an object that can be interpreted by matRad in the given context.

validate_mask()

Check if the given indices are valid for the CT image.

validate_mask_type(v)

Validate the mask type.

validate_visible_color(v)

Validate the visible color.

validate_voi_type(v)

Validate the voi type for an EXTERNAL contour.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

alpha_x: float#
beta_x: float#
classmethod construct(_fields_set=None, **values)#
Return type:

Self

copy(*, include=None, exclude=None, update=None, deep=False)#

Returns a copy of the model.

!!! warning “Deprecated”

This method is now deprecated; use model_copy instead.

If you need include or exclude, use:

`python {test="skip" lint="skip"} data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `

Parameters:
  • include (Set[int] | Set[str] | Mapping[int, Any] | Mapping[str, Any] | None) – Optional set or mapping specifying which fields to include in the copied model.

  • exclude (Set[int] | Set[str] | Mapping[int, Any] | Mapping[str, Any] | None) – Optional set or mapping specifying which fields to exclude in the copied model.

  • update (Optional[Dict[str, Any]]) – Optional dictionary of field-value pairs to override field values in the copied model.

  • deep (bool) – If True, the values of fields that are Pydantic models will be deep-copied.

Return type:

Self

Returns:

A copy of the model with included, excluded and updated fields as specified.

ct_image: CT#
default_color: tuple[int, int, int]#
dict(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)#
Return type:

Dict[str, Any]

classmethod from_orm(obj)#
Return type:

Self

get_indices(order='sitk')#

Return the indices of the voxels in the mask.

Parameters:

order (str, optional) – The order of the indices. Defaults to “sitk”.

Returns:

The indices of the voxels.

Return type:

ndarray

property indices: ndarray#

Return the indices of the voxels in the mask using Fortran/SITK convention.

Returns:

The indices of the voxels.

Return type:

np.ndarray

property indices_numpy: ndarray#

Return the indices of the voxels in the mask using C/numpy convention.

Returns:

The indices of the voxels.

Return type:

np.ndarray

json(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=PydanticUndefined, models_as_dict=PydanticUndefined, **dumps_kwargs)#
Return type:

str

mask: Image#
masked_ct(order_type='numpy')#

Return the masked CT image, either as a numpy array or a SimpleITK image.

Parameters:

order_type (str, optional) – The order type. Defaults to “numpy”.

Returns:

The masked CT image.

Return type:

Union[Image, ndarray]

model_computed_fields = {'_numpy_mask': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='_numpyMask', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns the mask as a numpy array.\n\nReturns\n-------\nnp.ndarray\n    The mask as a numpy array.', deprecated=None, examples=None, json_schema_extra=None, repr=False), 'indices': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='indices', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Return the indices of the voxels in the mask using Fortran/SITK convention.\n\nReturns\n-------\nnp.ndarray\n    The indices of the voxels.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'indices_numpy': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'numpy.ndarray'>, alias='indicesNumpy', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Return the indices of the voxels in the mask using C/numpy convention.\n\nReturns\n-------\nnp.ndarray\n    The indices of the voxels.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'num_of_scenarios': ComputedFieldInfo(wrapped_property=<property object>, return_type=<class 'int'>, alias='numOfScenarios', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns the number of scenarios.\n\nReturns\n-------\nint\n    The number of scenarios.', deprecated=None, examples=None, json_schema_extra=None, repr=True), 'scenario_ct_data': ComputedFieldInfo(wrapped_property=<property object>, return_type=typing.Union[list[numpy.ndarray], numpy.ndarray], alias='scenarioCtData', alias_priority=1, exclude_if=None, title=None, field_title_generator=None, description='Returns a list of CT data for the individual scenarios.\n\nReturns\n-------\nList[np.ndarray]\n    The CT data for the individual scenarios.', deprecated=None, examples=None, json_schema_extra=None, repr=True)}#
model_config: ClassVar[ConfigDict] = {'alias_generator': AliasGenerator(alias=<function to_camel>, validation_alias=None, serialization_alias=None), 'arbitrary_types_allowed': True, 'from_attributes': True, 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod model_construct(_fields_set=None, **values)#

Creates a new instance of the Model class with validated data.

Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.

!!! note

model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.

Parameters:
  • _fields_set (set[str] | None) – A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.

  • values (Any) – Trusted or pre-validated data dictionary.

Return type:

Self

Returns:

A new instance of the Model class with validated data.

model_copy(*, update=None, deep=False)#
!!! abstract “Usage Documentation”

[model_copy](../concepts/models.md#model-copy)

Returns a copy of the model.

!!! note

The underlying instance’s [__dict__][object.__dict__] attribute is copied. This might have unexpected side effects if you store anything in it, on top of the model fields (e.g. the value of [cached properties][functools.cached_property]).

Parameters:
  • update (Mapping[str, Any] | None) – Values to change/add in the new model. Note: the data is not validated before creating the new model. You should trust this data.

  • deep (bool) – Set to True to make a deep copy of the model.

Return type:

Self

Returns:

New model instance.

model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False, polymorphic_serialization=None)#
!!! abstract “Usage Documentation”

[model_dump](../concepts/serialization.md#python-mode)

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Parameters:
  • mode (Union[Literal['json', 'python'], str]) – The mode in which to_python should run. If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.

  • include (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – A set of fields to include in the output.

  • exclude (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – A set of fields to exclude from the output.

  • context (Any | None) – Additional context to pass to the serializer.

  • by_alias (bool | None) – Whether to use the field’s alias in the dictionary key if defined.

  • exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) – Whether to exclude fields that are set to their default value.

  • exclude_none (bool) – Whether to exclude fields that have a value of None.

  • exclude_computed_fields (bool) – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (Union[bool, Literal['none', 'warn', 'error']]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback (Optional[Callable[[Any], Any]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.

  • polymorphic_serialization (bool | None) – Whether to use model and dataclass polymorphic serialization for this call.

Return type:

dict[str, Any]

Returns:

A dictionary representation of the model.

model_dump_json(*, indent=None, ensure_ascii=False, include=None, exclude=None, context=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=True, fallback=None, serialize_as_any=False, polymorphic_serialization=None)#
!!! abstract “Usage Documentation”

[model_dump_json](../concepts/serialization.md#json-mode)

Generates a JSON representation of the model using Pydantic’s to_json method.

Parameters:
  • indent (int | None) – Indentation to use in the JSON output. If None is passed, the output will be compact.

  • ensure_ascii (bool) – If True, the output is guaranteed to have all incoming non-ASCII characters escaped. If False (the default), these characters will be output as-is.

  • include (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – Field(s) to include in the JSON output.

  • exclude (Union[set[int], set[str], Mapping[int, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], Mapping[str, Union[set[int], set[str], Mapping[int, Union[IncEx, bool]], Mapping[str, Union[IncEx, bool]], bool]], None]) – Field(s) to exclude from the JSON output.

  • context (Any | None) – Additional context to pass to the serializer.

  • by_alias (bool | None) – Whether to serialize using field aliases.

  • exclude_unset (bool) – Whether to exclude fields that have not been explicitly set.

  • exclude_defaults (bool) – Whether to exclude fields that are set to their default value.

  • exclude_none (bool) – Whether to exclude fields that have a value of None.

  • exclude_computed_fields (bool) – Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated round_trip parameter instead.

  • round_trip (bool) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].

  • warnings (Union[bool, Literal['none', 'warn', 'error']]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].

  • fallback (Optional[Callable[[Any], Any]]) – A function to call when an unknown value is encountered. If not provided, a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.

  • serialize_as_any (bool) – Whether to serialize fields with duck-typing serialization behavior.

  • polymorphic_serialization (bool | None) – Whether to use model and dataclass polymorphic serialization for this call.

Return type:

str

Returns:

A JSON string representation of the model.

property model_extra: dict[str, Any] | None#

Get extra fields set during validation.

Returns:

A dictionary of extra fields, or None if config.extra is not set to “allow”.

model_fields = {'alpha_x': FieldInfo(annotation=float, required=False, default=0.1, alias='alphaX', alias_priority=1), 'beta_x': FieldInfo(annotation=float, required=False, default=0.05, alias='betaX', alias_priority=1), 'ct_image': FieldInfo(annotation=CT, required=True, alias='ctImage', alias_priority=1), 'default_color': FieldInfo(annotation=tuple[int, int, int], required=False, default_factory=<lambda>, alias='defaultColor', alias_priority=1, description='Default RGB color bound to the VOI type'), 'mask': FieldInfo(annotation=Image, required=True, alias='mask', alias_priority=1), 'name': FieldInfo(annotation=str, required=True, alias='name', alias_priority=1), 'objectives': FieldInfo(annotation=list[Any], required=False, default=[], alias='objectives', alias_priority=1, description='List of objective function definitions'), 'overlap_priority': FieldInfo(annotation=int, required=False, default_factory=<lambda>, alias='Priority', alias_priority=2), 'visible': FieldInfo(annotation=bool, required=False, default=True, alias='visible', alias_priority=1, description='Flag to set visibility in GUI applications'), 'visible_color': FieldInfo(annotation=Union[tuple[int, int, int], NoneType], required=False, default=None, alias='visibleColor', alias_priority=1, description='RGB color for visualization in GUI applications'), 'voi_type': FieldInfo(annotation=str, required=False, default='EXTERNAL', alias='voiType', alias_priority=1)}#
property model_fields_set: set[str]#

Returns the set of fields that have been explicitly set on this model instance.

Returns:

A set of strings representing the fields that have been set,

i.e. that were not filled from defaults.

classmethod model_json_schema(by_alias=True, ref_template='#/$defs/{model}', schema_generator=<class 'pydantic.json_schema.GenerateJsonSchema'>, mode='validation', *, union_format='any_of')#

Generates a JSON schema for a model class.

Parameters:
  • by_alias (bool) – Whether to use attribute aliases or not.

  • ref_template (str) – The reference template.

  • union_format (Literal['any_of', 'primitive_type_array']) –

    The format to use when combining schemas from unions together. Can be one of:

    keyword to combine schemas (the default). - ‘primitive_type_array’: Use the [type](https://json-schema.org/understanding-json-schema/reference/type) keyword as an array of strings, containing each type of the combination. If any of the schemas is not a primitive type (string, boolean, null, integer or number) or contains constraints/metadata, falls back to any_of.

  • schema_generator (type[GenerateJsonSchema]) – To override the logic used to generate the JSON schema, as a subclass of GenerateJsonSchema with your desired modifications

  • mode (Literal['validation', 'serialization']) – The mode in which to generate the schema.

Return type:

dict[str, Any]

Returns:

The JSON schema for the given model class.

classmethod model_parametrized_name(params)#

Compute the class name for parametrizations of generic classes.

This method can be overridden to achieve a custom naming scheme for generic BaseModels.

Parameters:

params (tuple[type[Any], ...]) – Tuple of types of the class. Given a generic class Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.

Return type:

str

Returns:

String representing the new class where params are passed to cls as type variables.

Raises:

TypeError – Raised when trying to generate concrete names for non-generic models.

model_post_init(context, /)#

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

Return type:

None

classmethod model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)#

Try to rebuild the pydantic-core schema for the model.

This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.

Parameters:
  • force (bool) – Whether to force the rebuilding of the model schema, defaults to False.

  • raise_errors (bool) – Whether to raise errors, defaults to True.

  • _parent_namespace_depth (int) – The depth level of the parent namespace, defaults to 2.

  • _types_namespace (Mapping[str, Any] | None) – The types namespace, defaults to None.

Return type:

bool | None

Returns:

Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.

classmethod model_validate(obj, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)#

Validate a pydantic model instance.

Parameters:
  • obj (Any) – The object to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • from_attributes (bool | None) – Whether to extract data from object attributes.

  • context (Any | None) – Additional context to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Raises:

ValidationError – If the object could not be validated.

Return type:

Self

Returns:

The validated model instance.

classmethod model_validate_json(json_data, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)#
!!! abstract “Usage Documentation”

[JSON Parsing](../concepts/json.md#json-parsing)

Validate the given JSON data against the Pydantic model.

Parameters:
  • json_data (str | bytes | bytearray) – The JSON data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Return type:

Self

Returns:

The validated Pydantic model.

Raises:

ValidationError – If json_data is not a JSON string or the object could not be validated.

classmethod model_validate_strings(obj, *, strict=None, extra=None, context=None, by_alias=None, by_name=None)#

Validate the given object with string data against the Pydantic model.

Parameters:
  • obj (Any) – The object containing string data to validate.

  • strict (bool | None) – Whether to enforce types strictly.

  • extra (Optional[Literal['allow', 'ignore', 'forbid']]) – Whether to ignore, allow, or forbid extra data during model validation. See the [extra configuration value][pydantic.ConfigDict.extra] for details.

  • context (Any | None) – Extra variables to pass to the validator.

  • by_alias (bool | None) – Whether to use the field’s alias when validating against the provided input data.

  • by_name (bool | None) – Whether to use the field’s name when validating against the provided input data.

Return type:

Self

Returns:

The validated Pydantic model.

name: str#
property num_of_scenarios: int#

Returns the number of scenarios.

Returns:

The number of scenarios.

Return type:

int

objectives: list[Any]#
overlap_priority: int#
classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Self

classmethod parse_obj(obj)#
Return type:

Self

classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)#
Return type:

Self

resample_on_new_ct(new_ct)#

Resample on new CT image.

Parameters:

new_ct (CT) – The new CT image to resample the VOI on.

Returns:

The resampled VOI.

Return type:

Self

property scenario_ct_data: list[ndarray] | ndarray#

Returns a list of CT data for the individual scenarios.

Returns:

The CT data for the individual scenarios.

Return type:

List[np.ndarray]

scenario_indices(order_type='numpy')#

Return the flattened indices of the individual scenarios.

Parameters:

order_type (str, optional) – The order type. Defaults to “numpy”.

Returns:

The flattened indices of the individual scenarios.

Return type:

Union[ndarray, list[ndarray]]

classmethod schema(by_alias=True, ref_template='#/$defs/{model}')#
Return type:

Dict[str, Any]

classmethod schema_json(*, by_alias=True, ref_template='#/$defs/{model}', **dumps_kwargs)#
Return type:

str

to_matrad(context='mat-file')#

Create an object that can be interpreted by matRad in the given context.

Returns:

VOI as list to write cell arrays.

Return type:

Any

classmethod update_forward_refs(**localns)#
Return type:

None

classmethod validate(value)#
Return type:

Self

validate_mask()#

Check if the given indices are valid for the CT image.

Raises:
  • ValueError – If the mask is not a sitk.Image.

  • ValueError – If the dimensions of the mask do not match the CT image.

classmethod validate_mask_type(v)#

Validate the mask type.

Parameters:

v (Any) – The mask value to be validated.

Returns:

The validated mask.

Return type:

Any

Raises:

ValueError – If the mask type is not supported.

classmethod validate_visible_color(v)#

Validate the visible color.

Parameters:

v (Any) – The visible color value to be validated.

Returns:

The validated visible color.

Return type:

Any

classmethod validate_voi_type(v)[source]#

Validate the voi type for an EXTERNAL contour.

Parameters:

v (str) – The voi type to be validated.

Returns:

The validated voi type.

Return type:

str

Raises:

ValueError – If the voi type is not “EXTERNAL”.

visible: bool#
visible_color: tuple[int, int, int] | None#
voi_type: str#
cst.create_voi(**kwargs)#

Create a VOI object.

Parameters:
  • data (Union[dict[str, Any], VOI, None]) – Dictionary containing the data to create the VOI object.

  • **kwargs – Arbitrary keyword arguments.

Returns:

A VOI object.

Return type:

VOI

validate_voi(data=None, **kwargs)[source]#

Validate and create a VOI object.

Synonym to create_voi but should be used in validation context.

Parameters:
  • voi (Union[dict[str, Any], VOI, None], optional) – Dictionary containing the data to create the VOI object, by default None.

  • **kwargs – Arbitrary keyword arguments.

Returns:

A validated VOI object.

Return type:

VOI