plan#

Base Class#

class Plan(**data)[source]#

Bases: PyRadPlanBaseModel, ABC

Abstract base class for a treatment plan using PyRadPlanBaseModel.

prop_stf#

Properties of the stf.

Type:

Dict[str, Any]

prop_opt#

Properties of the optimization.

Type:

Dict[str, Any]

prop_dose_calc#

Properties of the dose calculation.

Type:

Dict[str, Any]

prop_seq#

Properties for the sequencer

Type:

Dict[str, Any]

num_of_fractions#

Number of fractions in the plan.

Type:

int

machine#

Machine used for the plan.

Type:

str

prescribed_dose#

Prescribed dose for the plan. Serves mainly as normalization value.

Type:

float

radiation_mode#

Will return the radiation modality (e.g. photons or protons).

Type:

str

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.

Methods

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

Returns a copy of the model.

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.

to_matrad([context])

Create a dictionary ready to save the Plan model to a mat-file.

validate_prop(v)

Validate the workflow property dictionaries.

validate_radiation_mode(v)

Validate the radiation mode.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

machine: Dict | str#
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].

mult_scen: ScenarioModel#
num_of_fractions: int#
prescribed_dose: float#
prop_dose_calc: Dict[str, Any]#
prop_opt: Dict[str, Any]#
prop_seq: Dict[str, Any]#
prop_stf: Dict[str, Any]#
radiation_mode: str#
to_matrad(context='mat-file')[source]#

Create a dictionary ready to save the Plan model to a mat-file.

Return type:

Any

Returns:

Dict: A dictionary containing the data of the Plan model in a format suitable for saving to a mat-file.

classmethod validate_prop(v)[source]#

Validate the workflow property dictionaries.

Will try to convert to snake_case if camelCase is used.

Parameters:

v (Dict[str, Any]) – The properties of the plan to be validated.

Returns:

The validated properties of the plan.

Return type:

Dict[str, Any]

classmethod validate_radiation_mode(v)[source]#

Validate the radiation mode.

Parameters:

v (str) – The radiation mode value to be validated.

Raises:

NotImplementedError – This method should be overridden in derived classes.

Return type:

str

Plans for different modalities#

class PhotonPlan(**data)[source]#

Bases: Plan

Class for a photon treatment plan.

Inherits all attributes from Plan.
radiation_mode : str

Returns the radiation mode as ‘photons’.

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.

Methods

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

Returns a copy of the model.

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.

to_matrad([context])

Create a dictionary ready to save the Plan model to a mat-file.

validate_prop(v)

Validate the workflow property dictionaries.

validate_radiation_mode(v)

Validate the radiation mode for a PhotonPlan.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

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].

radiation_mode: str#
classmethod validate_radiation_mode(v)[source]#

Validate the radiation mode for a PhotonPlan.

Parameters:

v (str) – The radiation mode to be validated.

Returns:

The validated radiation mode.

Return type:

str

Raises:

ValueError – If the radiation mode is not “photons”.

class IonPlan(**data)[source]#

Bases: Plan

Class for an ion treatment plan.

ionType#

Type of ion used in the plan.

Type:

str

Inherits all other attributes from Plan.
radiation_mode : str

Returns the radiation mode as the ion type.

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.

Methods

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

Returns a copy of the model.

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.

to_matrad([context])

Create a dictionary ready to save the Plan model to a mat-file.

validate_prop(v)

Validate the workflow property dictionaries.

validate_radiation_mode(v)

Validate the radiation mode for IonPlan.

construct

dict

from_orm

json

parse_file

parse_obj

parse_raw

schema

schema_json

update_forward_refs

validate

available_radiation_modes: ClassVar[List[str]] = ['protons', 'helium', 'carbon', 'oxygen', 'VHEE']#
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].

radiation_mode: str#
classmethod validate_radiation_mode(v)[source]#

Validate the radiation mode for IonPlan.

Parameters:
  • cls (class) – The class object.

  • v (str) – The radiation mode to be validated.

Returns:

The validated radiation mode.

Return type:

str

Raises:

ValueError – If the radiation mode is not one of the available radiation modes.

Creating and validating plans#

create_pln(data=None, **kwargs)[source]#

Create a Plan object (factory function).

Parameters:
  • data (Union[Dict[str, Any], Plan, None]) – Dictionary containing the data to create the Plan object.

  • **kwargs – Arbitrary keyword arguments.

Returns:

A Plan object.

Return type:

Plan

Raises:

ValueError – If the radiation mode is unknown or empty.

validate_pln(plan=None, **kwargs)[source]#

Validate and create a Plan object.

Synonym to create_pln but should be used in validation context.

Parameters:
  • plan (Union[Dict[str, Any], Plan, None]) – Dictionary containing the data to create the Plan object, by default None.

  • **kwargs – Arbitrary keyword arguments.

Returns:

A validated Plan object.

Return type:

Plan

Raises:

ValueError – If the radiation mode is unknown or empty.