3.1. opengate

3.1.1. Subpackages

3.1.2. Submodules

3.1.3. Package Contents

3.1.3.1. Classes

Simulation

Main class that store a simulation.

3.1.3.2. Attributes

g4_units

class opengate.Simulation(name='simulation')[source]

Bases: opengate.base.GateObject

Main class that store a simulation. It contains: - a set of global user parameters (SimulationUserInfo) - user parameters for Volume, Source, Actors and Filters, Physics - a list of g4 commands that will be set to G4 engine after the initialization

There is NO Geant4 engine here, it is only a set of parameters and options.

property use_multithread[source]
property world[source]
property multithreaded[source]
user_info_defaults[source]
__str__()[source]

Return str(self).

to_dictionary()[source]
from_dictionary(d)[source]
to_json_string()[source]
to_json_file(directory=None, filename=None)[source]
from_json_string(json_string)[source]
from_json_file(path)[source]
copy_input_files(directory=None, dct=None)[source]
get_output_path(path=None, is_file_or_directory='file', suffix='')[source]
add_g4_command_after_init(command)[source]

For the moment, only use it after runManager.Initialize

add_g4_command_before_init(command)[source]

For the moment, only use it after runManager.Initialize

get_source_user_info(name)[source]
get_actor_user_info(name)[source]
add_volume(volume, name=None)[source]
add_surface(volume_1, volume_2, surface_name)[source]
add_parallel_world(name)[source]
add_source(source_type, name)[source]
add_actor(actor_type, name)[source]
add_filter(filter_type, name)[source]
_run_simulation_engine(start_new_process)[source]

Method that creates a simulation engine in a context (with …) and runs a simulation.

Args:
q (:obj: queue, optional)A queue object to which simulation output can be added if run in a subprocess.

The dispatching function needs to extract the output from the queue.

start_new_process (bool, optional)A flag passed to the engine

so it knows if it is running in a subprocess.

Returns:

:obj:SimulationOutput : The output of the simulation run.

run(start_new_process=False)[source]
voxelize_geometry(extent='auto', spacing=(3, 3, 3), margin=0, filename=None, return_path=False)[source]

Create a voxelized three-dimensional representation of the simulation geometry.

The user can specify the sub-portion (a rectangular box) of the simulation which is to be extracted.

Args:
extentBy default (‘auto’), GATE automatically determines the sub-portion

to contain all volumes of the simulation. Alternatively, extent can be either a tuple of 3-vectors indicating the two diagonally opposite corners of the box-shaped sub-portion of the geometry to be extracted, or a volume or list volumes. In the latter case, the box is automatically determined to contain the volume(s).

spacing (tuple) : The voxel spacing in x-, y-, z-direction. margin : Width (in voxels) of the additional margin around the extracted box-shaped sub-portion

indicated by extent.

filename (str, optional)The filename/path to which the voxelized image and labels are written.

Suffix added automatically. Path can be relative to the global output directory of the simulation.

return_path (bool) : Return the absolute path where the voxelixed image was written?

Returns:
dict, itk image, (path)A dictionary containing the label to volume LUT; the voxelized geoemtry;

optionally: the absolute path where the image was written, if applicable.

initialize_source_before_g4_engine()[source]

Some sources need to perform computation once everything is defined in user_info but before the initialization of the G4 engine starts. This can be done via this function.

_get_voxelized_geometry(extent, spacing, margin)[source]

Private method which returns a voxelized image of the simulation geometry given the extent, spacing and margin.

The voxelization does not check which volume is voxelized. Every voxel will be assigned an ID corresponding to the material at this position in the world.

opengate.g4_units[source]