MetersetMap

Summary

A suite of functions to determine the MetersetMap for a range of formats

Warning

Although this is a useful tool in the toolbox for patient specific IMRT QA, in and of itself it is not a sufficient replacement for direct dosimetric measurement. This tool does not verify that the reported dose within the treatment planning system matches that delivered by the Linac.

Deficiencies in a plan’s agreement between the treatment planning system and the Linac due to deviations such as small field output factors or the MLC model will not be able to be picked up by this tool.

Furthermore, when the MetersetMap is calculated off of log files alone this uses leaf and jaw positions as reported by the Linac which may not agree with their position in reality due to issues such as a hardware or calibration fault.

API

pymedphys.metersetmap.calculate(mu, mlc, jaw, grid_resolution=None, max_leaf_gap=None, leaf_pair_widths=None, min_step_per_pixel=None)

Determine the MetersetMap.

Both jaw and mlc positions are defined in bipolar format for each control point. A negative value indicates travel over the isocentre. All positional arguments are defined at the isocentre projection with the units of mm.

Parameters
  • mu (numpy.ndarray) – 1-D array containing an MU value for each control point.

  • mlc (numpy.ndarray) –

    3-D array containing the MLC positions

    axis 0: control point
    axis 1: mlc pair
    axis 2: leaf bank

  • jaw (numpy.ndarray) –

    2-D array containing the jaw positions.

    axis 0: control point
    axis 1: diaphragm

  • grid_resolution (float, optional) – The calc grid resolution. Defaults to 1 mm.

  • max_leaf_gap (float, optional) – The maximum possible distance between opposing leaves. Defaults to 400 mm.

  • leaf_pair_widths (tuple, optional) – The widths of each leaf pair in the MLC limiting device. The number of entries in the tuples defines the number of leaf pairs. Each entry itself defines that particular leaf pair width. Defaults to 80 leaf pairs each 5 mm wide.

  • min_step_per_pixel (int, optional) – The minimum number of time steps used per pixel for each control point. Defaults to 10.

Returns

metersetmap

2-D array containing the calculated metersetmap.

axis 0: jaw direction
axis 1: mlc direction

Return type

numpy.ndarray

Examples

>>> import numpy as np
>>> import pymedphys
>>>
>>> leaf_pair_widths = (5, 5, 5)
>>> max_leaf_gap = 10
>>> mu = np.array([0, 2, 5, 10])
>>> mlc = np.array([
...     [
...         [1, 1],
...         [2, 2],
...         [3, 3]
...     ],
...     [
...         [2, 2],
...         [3, 3],
...         [4, 4]
...     ],
...     [
...         [-2, 3],
...         [-2, 4],
...         [-2, 5]
...     ],
...     [
...         [0, 0],
...         [0, 0],
...         [0, 0]
...     ]
... ])
>>> jaw = np.array([
...     [7.5, 7.5],
...     [7.5, 7.5],
...     [-2, 7.5],
...     [0, 0]
... ])
>>>
>>> grid = pymedphys.metersetmap.grid(
...    max_leaf_gap=max_leaf_gap, leaf_pair_widths=leaf_pair_widths)
>>> grid['mlc']
array([-5., -4., -3., -2., -1.,  0.,  1.,  2.,  3.,  4.,  5.])
>>>
>>> grid['jaw']
array([-8., -7., -6., -5., -4., -3., -2., -1.,  0.,  1.,  2.,  3.,  4.,
        5.,  6.,  7.,  8.])
>>>
>>> metersetmap = pymedphys.metersetmap.calculate(
...    mu, mlc, jaw, max_leaf_gap=max_leaf_gap,
...    leaf_pair_widths=leaf_pair_widths)
>>> pymedphys.metersetmap.display(grid, metersetmap)
>>>
>>> np.round(metersetmap, 1)
array([[0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
       [0. , 0. , 0. , 0.3, 1.9, 2.2, 1.9, 0.4, 0. , 0. , 0. ],
       [0. , 0. , 0. , 0.4, 2.2, 2.5, 2.2, 0.6, 0. , 0. , 0. ],
       [0. , 0. , 0. , 0.4, 2.4, 2.8, 2.5, 0.8, 0. , 0. , 0. ],
       [0. , 0. , 0. , 0.4, 2.5, 3.1, 2.8, 1. , 0. , 0. , 0. ],
       [0. , 0. , 0. , 0.4, 2.5, 3.4, 3.1, 1.3, 0. , 0. , 0. ],
       [0. , 0. , 0.4, 2.3, 3.2, 3.7, 3.7, 3.5, 1.6, 0. , 0. ],
       [0. , 0. , 0.4, 2.3, 3.2, 3.8, 4. , 3.8, 1.9, 0.1, 0. ],
       [0. , 0. , 0.4, 2.3, 3.2, 3.8, 4.3, 4.1, 2.3, 0.1, 0. ],
       [0. , 0. , 0.4, 2.3, 3.2, 3.9, 5.2, 4.7, 2.6, 0.2, 0. ],
       [0. , 0. , 0.4, 2.3, 3.2, 3.8, 5.4, 6.6, 3.8, 0.5, 0. ],
       [0. , 0.3, 2.2, 3. , 3.5, 4. , 5.1, 7.5, 6.7, 3.9, 0.5],
       [0. , 0.3, 2.2, 3. , 3.5, 4. , 4.7, 6.9, 6.7, 3.9, 0.5],
       [0. , 0.3, 2.2, 3. , 3.5, 4. , 4.5, 6.3, 6.4, 3.9, 0.5],
       [0. , 0.3, 2.2, 3. , 3.5, 4. , 4.5, 5.6, 5.7, 3.8, 0.5],
       [0. , 0.3, 2.2, 3. , 3.5, 4. , 4.5, 5.1, 5.1, 3.3, 0.5],
       [0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ]])

MetersetMap from a Mosaiq record

>>> import pymedphys
>>>
>>> def metersetmap_from_mosaiq(msq_server_name, field_id):
...     with pymedphys.mosaiq.connect(msq_server_name) as cursor:
...         delivery = pymedphys.Delivery.from_mosaiq(cursor, field_id)
...
...     grid = pymedphys.metersetmap.grid()
...     metersetmap = delivery.metersetmap()
...     pymedphys.metersetmap.display(grid, metersetmap)
>>>
>>> metersetmap_from_mosaiq('a_server_name', 11111) 

MetersetMap from a logfile at a given filepath

>>> import pymedphys
>>>
>>> def metersetmap_from_logfile(filepath):
...     delivery_data = Delivery.from_logfile(filepath)
...     metersetmap = Delivery.metersetmap()
...
...     grid = pymedphys.metersetmap.grid()
...     pymedphys.metersetmap.display(grid, metersetmap)
>>>
>>> metersetmap_from_logfile(r"a/path/goes/here")  
pymedphys.metersetmap.grid(max_leaf_gap=400, grid_resolution=1, leaf_pair_widths=(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5))

Get the MetersetMap grid for plotting purposes.

Examples

See `pymedphys.metersetmap.calculate`_.

pymedphys.metersetmap.display(grid, metersetmap, grid_resolution=None, cmap=None, vmin=None, vmax=None)

Prints a colour plot of the MetersetMap.

Examples

See `pymedphys.metersetmap.calculate`_.

Comments