Scene Objects

For each sample, the pipeline constructs a “Scene”. The objects within this scene are called “Scene Objects”. They may be organs, tools or fat tissue as well as boundary conditions. To keep track of these, each DataSample conatins a list of scene objects, accessible via get_scene_objects(). A scene object is always an instance of a (subclass of) BaseObject.

The default Scene Object classes are given in the sceneobjects module.

Important: When you create your pipeline, these objects should not be created directly! This is because every DataSample instance will need to construct its scene with its own paramerters. For example, DataSample 10 may construct 2 ligaments with high stiffness and DataSample 30 may instead create 4 with a low stiffness. This is why instead of instancing the scene objects yourself, you need to let the pipeline do this for you whenever it creates a new DataSample. We solve this by using the SceneObjectGeneratorBlock to which you can add the scene objects to be created via add_object_template(). This serves two purposes:

  1. Create scene objects upon demand, i.e. when a DataSample is created

  2. Sample random parameter ranges in order to fill the parameters of the created scene objects with their specific values for this specific sample.

If you start programming your own types of scene objects, you should:

  1. Subclass BaseObject for your own scene object.

  2. Add a SceneObjectGeneratorBlock to your pipeline if you haven’t already, call the add_object_template() method and pass a dictionary with all the key/value pairs which will be passed to the specific scene object’s constructor. Note: You can pass a tuple here, which acts as the min and max values of the value, which will be sampled upon construction of the scene object. This allows creating objects with varying parameters when creating the object. See the example run_* scripts in the src directory. The additional “ex_likelihood” parameter should be a likelihood in the range of (0..1] of including this object in a specific sample. For example, if ex_likelihood is 0.5, roughly half of the scenes (i.e. half of the DataSamples) will have this object created for them.

  3. The above will make sure that the pipeline will create the scene object. Now when the PipelineBlock’s are run on this sample, they must handle your new scene object type correctly. For example, you might want to adapt the RandomSceneBlock and the SimulationBlock to correctly handle your scene objects as well.