Dij#

class Dij(**data)[source]#

Bases: PyRadPlanBaseModel

Collection of Dose (or other quantity) Influence Matrices.

resolution#

Voxel resolution in each dimension (‘x’, ‘y’, ‘z’).

Type:

dict[str, Any]

physical_dose#

Physical dose matrix.

Type:

scipy.sparse.sparray

total_num_of_bixels#

Total number of bixels in the matrix.

Type:

int

num_of_voxels#

Total number of voxels in the matrix.

Type:

int

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.

num_of_voxels

Number of voxels in the dose influence matrix.

quantities

Name of available uantities matrices.

total_num_of_bixels

Number of bixels / beamlets in the dose influence matrix.

Methods

compute_result_ct_grid(intensities[, ...])

Compute results on the CT grid from intensity vector.

compute_result_dose_grid(intensities[, ...])

Compute results on the dose grid from intensity vector.

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

Returns a copy of the model.

get_result_arrays_from_intensity(intensity)

Compute result arrays from an intensity vector.

grid_serializer(value, handler, info)

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

Convert the Dij to matRad-compatible dictionary.

to_namespace(xp_new, *[, ...])

Convert all influence matrices in the Dij to a different array namespace.

validate_grid(grid, info)

Validate grid dictionaries.

validate_influenc_matrix_conatiner(v, ...)

Validate the physical dose matrix.

validate_numbering_arrays(v, info)

Validate the numbering arrays.

validate_unique_indices_in_beam_num(v, info)

Validate the number of unique indices in beam_num.

validate_voxel_arrays(v, info)

Validate the voxel arrays.

construct

dict

from_orm

json

numbering_arrays_serializer

parse_file

parse_obj

parse_raw

physical_dose_serializer

rad_depth_cubes_serializer

schema

schema_json

update_forward_refs

validate

alpha_dose: Annotated[NDArray[Any, object] | None, FieldInfo(annotation=NoneType, required=False, default=None)]#
alphax: Annotated[Annotated[ArrayType, ArrayAPIArray] | None, FieldInfo(annotation=NoneType, required=False, default=None)]#
beam_num: Annotated[NDArray[Any, Any], FieldInfo(annotation=NoneType, required=False, default=None)]#
betax: Annotated[Annotated[ArrayType, ArrayAPIArray] | None, FieldInfo(annotation=NoneType, required=False, default=None)]#
bixel_num: Annotated[NDArray[Any, Any], FieldInfo(annotation=NoneType, required=False, default=None)]#
compute_result_ct_grid(intensities, scenario_index=0)[source]#

Compute results on the CT grid from intensity vector.

Parameters:
  • intensity (np.ndarray) – The intensity to apply to the dose influence matrix.

  • scenario_index (int) – The scenario index to apply the intensity to.

Returns:

A dictionary containing the quantity images for each scenario.

Return type:

dict[str, Image]

compute_result_dose_grid(intensities, scenario_index=0)[source]#

Compute results on the dose grid from intensity vector.

Parameters:
  • intensity (np.ndarray) – The intensity to apply to the dose influence matrix.

  • scenario_index (int) – The scenario index to apply the intensity to.

Returns:

A dictionary containing the quantity images for each scenario.

Return type:

dict[str, Image]

ct_grid: Annotated[Grid, FieldInfo(annotation=NoneType, required=False, default=None)]#
dose_grid: Annotated[Grid, FieldInfo(annotation=NoneType, required=False, default=None)]#
get_result_arrays_from_intensity(intensity, scenario_index=0)[source]#

Compute result arrays from an intensity vector.

Parameters:
  • intensity (ndarray) – The intensity to apply to the dose influence matrix.

  • scenario_index (int) – The scenario index to apply the intensity to.

Returns:

A dictionary containing the quantity images for each scenario.

Return type:

dict[str, ndarray]

grid_serializer(value, handler, info)[source]#
Return type:

dict

let_dose: Annotated[NDArray[Any, object] | None, FieldInfo(annotation=NoneType, required=False, default=None, alias='mLETDose', alias_priority=2)]#
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].

num_of_beams: Annotated[int, FieldInfo(annotation=NoneType, required=False, default=None)]#
property num_of_voxels: int#

Number of voxels in the dose influence matrix.

numbering_arrays_serializer(value, info)[source]#
Return type:

ndarray

physical_dose: Annotated[NDArray[Any, object], FieldInfo(annotation=NoneType, required=False, default=None)]#
physical_dose_serializer(value, info)[source]#
Return type:

ndarray

physical_dose_var: Annotated[NDArray[Any, object] | None, FieldInfo(annotation=NoneType, required=False, default=None)]#
property quantities: list[str]#

Name of available uantities matrices.

rad_depth_cubes: list[Annotated[ArrayType, ArrayAPIArray]] | None#
rad_depth_cubes_serializer(value, info)[source]#
Return type:

ndarray

ray_num: Annotated[NDArray[Any, Any], FieldInfo(annotation=NoneType, required=False, default=None)]#
sqrt_beta_dose: Annotated[NDArray[Any, object] | None, FieldInfo(annotation=NoneType, required=False, default=None)]#
to_matrad(context='mat-file')[source]#

Convert the Dij to matRad-compatible dictionary.

Return type:

Any

to_namespace(xp_new, *, keep_sparse_compat=True, device=None)[source]#

Convert all influence matrices in the Dij to a different array namespace.

Parameters:
  • xp_new (Union[ArrayNamespace, str]) – The target array namespace.

  • keep_sparse_compat (bool) – Whether to keep sparse matrix compatibility when converting to a new namespace. If False, sparse matrices will be converted to arrays of the namespace, even if the sparse format is compatible with the target namespace. For example, converting from scipy.sparse to numpy will result in a dense numpy array instead of a sparse matrix. Default is True.

  • device (Optional[str]) – Target device for the arrays (e.g. “cuda:0”, “cpu”).

Return type:

Self

property total_num_of_bixels: int#

Number of bixels / beamlets in the dose influence matrix.

classmethod validate_grid(grid, info)[source]#

Validate grid dictionaries.

Raises:

ValueError:

Return type:

Union[Grid, dict]

classmethod validate_influenc_matrix_conatiner(v, handler, info)[source]#

Validate the physical dose matrix.

Raises:

ValueError – if physical dose is not a 2D numpy array.:

Return type:

NDArray[Any, object]

classmethod validate_numbering_arrays(v, info)[source]#

Validate the numbering arrays.

Raises:

ValueError – inconsistent numbering arrays.:

Return type:

ndarray

classmethod validate_unique_indices_in_beam_num(v, info)[source]#

Validate the number of unique indices in beam_num.

Raises:

ValueError – Number of unique indices does not match number of beams.:

Return type:

ndarray

classmethod validate_voxel_arrays(v, info)[source]#

Validate the voxel arrays.

Raises:

ValueError – inconsistent voxel arrays.:

Return type:

ndarray

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

Create a Dij object from raw data or keyword arguments.

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

  • **kwargs – Arbitrary keyword arguments.

Returns:

A Dij object.

Return type:

Dij

validate_dij(dij=None, **kwargs)[source]#

Validate and creates a Dij object.

Synonym to create_dij but should be used in validation context.

Parameters:
  • dij (Union[dict[str, Any], Dij, None]) – Dictionary containing the data to create the Dij object, by default None.

  • **kwargs – Arbitrary keyword arguments.

Returns:

A validated Dij object.

Return type:

Dij