xopto.mcbase.mcfluence.fluence module

class Fluence(xaxis: xopto.mcbase.mcutil.axis.Axis, yaxis: Optional[xopto.mcbase.mcutil.axis.Axis] = None, zaxis: Optional[xopto.mcbase.mcutil.axis.Axis] = None, mode: str = 'deposition')[source]

Bases: xopto.mcbase.mcobject.McObject

Fluence object constructor. Default constructor disables the fluence functionality by creating a zero-size fluence accumulator array.

Parameters
  • xaxis (Axis or Fluence) – Axis that defines accumulators along the x axis. If Fluence instance, a new copy is created.

  • yaxis (Axis) – Axis that defines accumulators along the y axis.

  • zaxis (Axis) – Axis that defines accumulators along the z axis.

  • mode (str from ('deposition', 'fluence')) –

    Mode that is used to accumulate the photon packet weight:

    • fluence - fluence rate ( 1/m 2)

    • deposition - absorbed energy (sum of photon packet weights absorbed in the voxel 1/m 3).

Note

The fluence accumulator buffer data type is inherited from the Monte Carlo simulator mc_accu_t type.

static cl_declaration(mc: xopto.mcbase.mcobject.McObject)str[source]
static cl_implementation(mc: xopto.mcbase.mcobject.McObject)[source]
cl_options(mc: xopto.mcbase.mcobject.McObject)List[Tuple[str, str]][source]
cl_pack(mc: xopto.mcbase.mcobject.McObject, target: Optional[xopto.cl.cltypes.Structure] = None)xopto.cl.cltypes.Structure[source]

Fills the structure (target) with the data required by the Monte Carlo simulator. See the Fluence.cl_type() for a detailed list of fields.

Parameters
  • mc (mcobject.McObject) – Monte Carlo simulator instance.

  • target (ClFluence) – CStructure that is filled with the source data.

  • buffer (np.ndarray) – Accumulator buffer or None. Should be checked for proper size. Use py:attr:mc.types.np_accu attribute to determine the numpy type of the accumulator used in the Monte Carlo simulator.

Returns

target – Filled structure received as an input argument or a new instance if the input argument target is None.

Return type

ClFluence

static cl_type(mc: xopto.mcbase.mcobject.McObject)xopto.cl.cltypes.Structure[source]
property data

Fluence accumulator - deposition or fluence rate.

property dx: numpy.ndarray

The size of voxels along the x axis.

property dy: numpy.ndarray

The size of voxels along the y axis.

property dz: numpy.ndarray

The size of voxels along the z axis.

classmethod fromdict(data: dict)xopto.mcbase.mcfluence.fluence.Fluence[source]

Create a Fluence instance from a dictionary.

Parameters

data (dict) – Dictionary created by the Fluence.todict() method.

property k: int

Fluence floating point to accumulatorinteger conversion coefficient.

property mode: int

The accumulator mode.

property nphotons: int

The number of photon packets that produced the raw data accumulator content.

plot(scale: str = 'log', axis: str = 'z', autoscale: bool = True, show: bool = True)[source]

Show fluence slices or integral projections.

Parameters
  • scale (str) – Data scaling can be “log” for logarithmic or “lin” for linear.

  • axis (str) – The axis of slicing (“x”, “y” or “z”) or a projection along the selected coordinate axis (“xproj”, “yproj”, “zproj”). Alternatively, specify the projection plane as one of (“xy”, “xz”, or “yz”).

  • autoscale (bool) – Scale the color coding of individual slices to the corresponding range of weights. If True, the color coding changes from slice to slice.

  • show (bool) –

property raw: numpy.ndarray

Raw fluence accumulator data if any.

render(logscale: bool = True, show: bool = True)[source]

Show the fluence/deposition volume in a 3D viewer.

Parameters
  • logscale (bool) – Apply logarithmic scaling if set to True.

  • show (bool) – If True, showw the window and starts the Qt event loop that will block until the window is closed.

Returns

viewer – Use the exec() method to show the viewer and start the Qt event loop that will block until the window is closed.

Return type

slicer3d.Slicer3D

Note

The 3D viewer requires PySide6 and PyQtGraph.

property shape: Tuple[int, int, int]

Fluence array shape.

todict()dict[source]

Save the fluence configuration without the accumulator data to a dictionary.

Returns

data – Fluence configuration as a dictionary.

Return type

dict

update(obj: xopto.mcbase.mcfluence.fluence.Fluence)[source]

Update the fluence accumulator with data from the given fluence object.

Parameters

obj (Fluence) – Update the fluence accumulator of this instance with the data from fluence instance obj.

update_data(mc: xopto.mcbase.mcobject.McObject, data: Dict[numpy.dtype, List[numpy.ndarray]], nphotons: int, **kwargs)[source]

Update fluence accumulator data with simulation results.

Parameters
  • mc (mcobject.McObject) – Simulator instance that produced the data.

  • data (Dict[np.dtype, List[np.ndarray]]) – List of allocated accumulators (this implementation uses only one accumulator buffer).

  • nphotons (int) – The number of photon packets that produced the raw data accumulator content.

  • kwargs (dict) – Additional keyword arguments not used by this implementation.

property x: numpy.ndarray

Accumulator centers along the x axis.

property xaxis: xopto.mcbase.mcutil.axis.Axis

Accumulator axis object along the x axis.

property y: numpy.ndarray

Accumulator centers along the y axis.

property yaxis: xopto.mcbase.mcutil.axis.Axis

Accumulator axis object along the y axis.

property z: numpy.ndarray

Accumulator centers along the z axis.

property zaxis: xopto.mcbase.mcutil.axis.Axis

Accumulator axis object along the z axis.