Shortcuts

tomopt.optimisation.data package

Submodules

tomopt.optimisation.data.passives module

class tomopt.optimisation.data.passives.AbsBlockPassiveGenerator(volume, block_size, block_size_max_half=None, materials=None)[source]

Bases: AbsPassiveGenerator

Abstract base class for classes that generate new passive layouts which contain a single cuboid of material (block).

The _generate() method should be overridden to return:
  • A function that provides an xy tensor for a given layer when called with its z position, length and width, and size.

  • An optional “target” value for the layout

The generate() method will return only the layout function and no target The get_data() method will return both the layout function and the target

The block will be centred randomly in the volume, and can either be of fixed or random size.

Parameters:
  • volume (Volume) – Volume that the passive layout will be loaded into

  • block_size (Optional[Tuple[float, float, float]]) – if set, will generate blocks of the specified size and random orientation, otherwise will randomly set the size of the blocks

  • block_size_max_half (Optional[bool]) – if True and block_size is None, the maximum size of blocks will be set to half the size of the passive volume

  • materials (Optional[List[str]]) – list of material names that can be used in the volume, None -> all materials known to TomOpt

class tomopt.optimisation.data.passives.AbsPassiveGenerator(volume, materials=None)[source]

Bases: object

Abstract base class for classes that generate new passive layouts.

The _generate() method should be overridden to return:
  • A function that provides an xy tensor for a given layer when called with its z position, length and width, and size.

  • An optional “target” value for the layout

The generate() method will return only the layout function and no target The get_data() method will return both the layout function and the target

Parameters:
  • volume (Volume) – Volume that the passive layout will be loaded into

  • materials (Optional[List[str]]) – list of material names that can be used in the volume, None -> all materials known to TomOpt

generate()[source]
Return type:

Callable[[Tensor, Tensor, float], Tensor]

Returns:

The layout function and no target

get_data()[source]
Returns:

A function that provides an xy tensor for a given layer when called with its z position, length and width, and size. Target: An optional “target” value for the layout

Return type:

RadLengthFunc

class tomopt.optimisation.data.passives.BlockPresentPassiveGenerator(volume, block_size, block_size_max_half=None, materials=None)[source]

Bases: AbsBlockPassiveGenerator

Generates new passive layouts which contain a single cuboid of material (block) of random material against a fixed background material. Blocks are always present, but can potentially be of the same material as the background. The target for the volumes is the X0 of the block material. The background material for the background will always be the zeroth material provided during initialisation.

The generate() method will return only the layout function and no target The get_data() method will return both the layout function and the target

The block will be centred randomly in the volume, and can either be of fixed or random size.

Parameters:
  • volume (Volume) – Volume that the passive layout will be loaded into

  • block_size (Optional[Tuple[float, float, float]]) – if set, will generate blocks of the specified size and random orientation, otherwise will randomly set the size of the blocks

  • block_size_max_half (Optional[bool]) – if True and block_size is None, the maximum size of blocks will be set to half the size of the passive volume

  • materials (Optional[List[str]]) – list of material names that can be used in the volume, None -> all materials known to TomOpt

class tomopt.optimisation.data.passives.PassiveYielder(passives, n_passives=None, shuffle=True)[source]

Bases: object

Dataset class that can either:

Yield from a set of pre-specified passive-volume layouts, and optional targets Generate and yield random layouts and optional targets from a provided generator

Parameters:
  • passives (Union[List[Union[Tuple[Callable[[Tensor, Tensor, float], Tensor], Optional[Tensor]], Callable[[Tensor, Tensor, float], Tensor]]], AbsPassiveGenerator]) – Either a list of passive-volume functions (and optional targets together in a tuple), or a passive-volume generator

  • n_passives (Optional[int]) – if a generator is used, this determines the number of volumes to generator per epoch in training, or in total when predicting

  • shuffle (bool) – If a list of pre-specified layouts is provided, their order will be shuffled if this is True

class tomopt.optimisation.data.passives.RandomBlockPassiveGenerator(volume, block_size, sort_x0, enforce_diff_mat, block_size_max_half=None, materials=None)[source]

Bases: AbsBlockPassiveGenerator

Generates new passive layouts which contain a single cuboid of material (block) of random material against a random background material. Blocks are always present, but can potentially be of the same material as the background. The target for the volumes is the X0 of the block material.

The generate() method will return only the layout function and no target The get_data() method will return both the layout function and the target

The block will be centred randomly in the volume, and can either be of fixed or random size.

Parameters:
  • volume (Volume) – Volume that the passive layout will be loaded into

  • block_size (Optional[Tuple[float, float, float]]) – if set, will generate blocks of the specified size and random orientation, otherwise will randomly set the size of the blocks

  • sort_x0 (bool) – if True, the block will always have a lower X0 than the background, unless they are of the same material

  • enforce_diff_mat (bool) – if True, the block will always be of a different material to the background

  • block_size_max_half (Optional[bool]) – if True and block_size is None, the maximum size of blocks will be set to half the size of the passive volume

  • materials (Optional[List[str]]) – list of material names that can be used in the volume, None -> all materials known to TomOpt

class tomopt.optimisation.data.passives.VoxelPassiveGenerator(volume, materials=None)[source]

Bases: AbsPassiveGenerator

Generates new passive layouts where every voxel is of a random material.

The generate() method will return only the layout function and no target The get_data() method will return both the layout function and the target

Parameters:
  • volume (Volume) – Volume that the passive layout will be loaded into

  • materials (Optional[List[str]]) – list of material names that can be used in the volume, None -> all materials known to TomOpt

Docs

Access comprehensive developer and user documentation for TomOpt

View Docs

Tutorials

Get tutorials for beginner and advanced researchers demonstrating many of the features of TomOpt

View Tutorials