Reference for pyronn/ct_reconstruction/helpers/phantoms/primitives_3d.py
pyronn.ct_reconstruction.helpers.phantoms.primitives_3d.place_sphere
Updates an existing 3D grid by placing a spherical object within it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grid
|
The existing 3D numpy array (meshgrid) to update. |
required | |
pos
|
Center of the sphere (in [Z, Y, X]). |
required | |
radius
|
Radius of the sphere. |
required | |
value
|
Value to fill the sphere with. |
1.0
|
Returns:
Type | Description |
---|---|
None; the function updates the grid in place. |
Source code in pyronn/ct_reconstruction/helpers/phantoms/primitives_3d.py
pyronn.ct_reconstruction.helpers.phantoms.primitives_3d.place_cube
Updates an existing 3D grid by placing a cube object within it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grid
|
The existing 3D numpy array (meshgrid) to update. |
required | |
pos
|
Position of the cube's upper left corner (in [Z, Y, X]). |
required | |
size
|
Size of the cube (in [Z, Y, X]). |
required | |
value
|
Value to fill the cube with. |
1.0
|
Returns:
Type | Description |
---|---|
None; the function updates the grid in place. |
Source code in pyronn/ct_reconstruction/helpers/phantoms/primitives_3d.py
pyronn.ct_reconstruction.helpers.phantoms.primitives_3d.rotate_point_around_z
Rotate a point around the Z-axis by a given angle.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x,
|
(y, z)
|
Coordinates of the point. |
required |
angle
|
Rotation angle in radians. |
required |
Returns:
Type | Description |
---|---|
Rotated coordinates (x', y', z'). |
Source code in pyronn/ct_reconstruction/helpers/phantoms/primitives_3d.py
pyronn.ct_reconstruction.helpers.phantoms.primitives_3d.place_cube_with_rotation
Updates an existing 3D grid by placing a cube object within it, potentially rotated around the Z-axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grid
|
The existing 3D numpy array (meshgrid) to update. |
required | |
pos
|
Position of the cube's upper left corner (in [Z, Y, X]). |
required | |
size
|
Size of the cube (in [Z, Y, X]). |
required | |
value
|
Value to fill the cube with. |
1.0
|
|
angle
|
Rotation angle in radians around the Z-axis. If None, a random angle is chosen. |
None
|
Returns:
Type | Description |
---|---|
None; the function updates the grid in place. |
Source code in pyronn/ct_reconstruction/helpers/phantoms/primitives_3d.py
pyronn.ct_reconstruction.helpers.phantoms.primitives_3d.place_ellipsoid_with_rotation
Updates an existing 3D grid by placing a randomly rotated ellipsoid object within it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grid
|
The existing 3D numpy array (meshgrid) to update. |
required | |
pos
|
Center of the ellipsoid (in [Z, Y, X]). |
required | |
radii
|
Radii of the ellipsoid (in [Z, Y, X]). |
required | |
value
|
Value to fill the ellipsoid with. |
1.0
|
|
angle
|
Rotation angle in radians around the Z-axis. If None, a random angle is chosen. |
None
|
Returns:
Type | Description |
---|---|
None; the function updates the grid in place. |
Source code in pyronn/ct_reconstruction/helpers/phantoms/primitives_3d.py
pyronn.ct_reconstruction.helpers.phantoms.primitives_3d.place_cylinder_with_rotation
Updates an existing 3D grid by placing a randomly rotated cylinder object within it. Args: grid: The existing 3D numpy array (meshgrid) to update. pos: Center of the base of the cylinder (in [Z, Y, X]). height: Height of the cylinder along the Z-axis. radius: Radius of the cylinder in the XY plane. value: Value to fill the cylinder with. angle: Rotation angle in radians around the Z-axis. If None, a random angle is chosen. Returns: None; the function updates the grid in place.
Source code in pyronn/ct_reconstruction/helpers/phantoms/primitives_3d.py
pyronn.ct_reconstruction.helpers.phantoms.primitives_3d.place_pyramid
Places an axis-aligned pyramid into a 3D grid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grid
|
3D numpy array representing the grid. |
required | |
base_center
|
Center of the pyramid's base in the grid (z, y, x). |
required | |
base_size
|
Side length of the pyramid's square base. |
required | |
height
|
Height of the pyramid. |
required | |
value
|
Value to fill the pyramid with. |
1.0
|
Returns:
Type | Description |
---|---|
None; the grid is modified in place. |
Source code in pyronn/ct_reconstruction/helpers/phantoms/primitives_3d.py
pyronn.ct_reconstruction.helpers.phantoms.primitives_3d.visualize_grid
Visualizes a 3D grid using matplotlib, plotting points where the grid value is non-zero.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grid
|
The 3D numpy array to visualize. |
required |
Source code in pyronn/ct_reconstruction/helpers/phantoms/primitives_3d.py
pyronn.ct_reconstruction.helpers.phantoms.primitives_3d.generate_3D_primitives
Generates a 3D phantom composed of a specified number of random geometric primitives. The primitives are added to the phantom with random positions, orientations, sizes, and intensities. The method returns both the phantom and its sinogram as PyTorch tensors.
Parameters: - volume_shape: shape of the phantom - number_of_primitives (int, optional): The number of geometric primitives to include in the phantom. Defaults to 6.
Returns: - numpy.array: The 3D phantom.