cbi_toolbox.simu.primitives
The primitives module generates basic 3D objects
Conventions:
arrays follow the ZXY convention, with
Z : depth axis (axial, focus axis)
X : horizontal axis (lateral)
Y : vertical axis (lateral, rotation axis when relevant)
- cbi_toolbox.simu.primitives.ball(size, radius=None, in_radius=0, antialias=2, dtype=<class 'numpy.float64'>)[source]
Generate hollow ball.
- Parameters
size (int) – side of the cube containing the volume
radius (float, optional) – radius of the ball, by default None (size - 1)
in_radius (float, optional) – radius of the inner (empty) sphere expressed as a fraction of the outer radius [0-1], by default 0 (plain ball)
antialias (int, optional) – antialiasing scale factor, by default 2
dtype (numpy.dtype or str, optional) – the datatype, by default numpy.float64
- Returns
The volume containing the ball.
- Return type
numpy.ndarray
- Raises
ValueError – if the size is odd
ValueError – if the antialias is negative
- cbi_toolbox.simu.primitives.boccia(size, radius=None, n_stripes=3, deg_space=15, deg_width=7.5, rad_thick=0.12, antialias=2, dtype=<class 'numpy.float64'>)[source]
Create a boccia simulated sample: resolution stripes on a sphere
- Parameters
size (int) – side of the cube containing the volume (must be even)
radius (float, optional) – radius of the boccia, by default None (will be size-1)
n_stripes (int, optional) – number of stripes to generate, by default 3
deg_space (int, optional) – spacing in degrees between the center of the stripes, by default 15
deg_width (float, optional) – width in degrees of the stripes, by default 7.5
rad_thick (float, optional) – thickness of the stripes, as a proportion of the radius, by default 0.12
antialias (int, optional) – antialiasing scale factor, by default 2
dtype (numpy.dtype or str, optional) – the datatype, by default numpy.float64
- Returns
The volume containing the boccia.
- Return type
numpy.ndarray
- Raises
ValueError – if the size is odd
ValueError – if the antialias is negative
ValueError – if the angle surpasses 90°
- cbi_toolbox.simu.primitives.phantom(size, scale=1, antialias=2)[source]
Generate 3D modified Shepp-Logann phantoms
- Parameters
size (int) – size of the output
scale (float) – scaling factor for the size of the phantoms
antialias (int, optional) – antialiasing factor, by default 2
- Returns
the phantoms
- Return type
array [ZXY]
- Raises
ValueError – if antialias is not a positive integer
- cbi_toolbox.simu.primitives.quadrant_symmetry(quadrant)[source]
Generate a binary quadrant by rotating itself 90° on all 3 axes and summing.
- Parameters
quadrant (numpy.ndarray(bool)) – The original 3D quadrant.
- Returns
The symmetrized quadrant. Will have cubic shape equal to the largest dimension of the original quadrant.
- Return type
numpy.ndarray
- cbi_toolbox.simu.primitives.quadrant_to_volume(quadrant, odd=(False, False, False))[source]
Generate a volume by mirroring a quadrant in all 8 corners.
- Parameters
quadrant (numpy.ndarray) – The quadrant corresponding to the end of the axes.
odd (tuple, optional) – If the target dimensions are odd, by default (False, False, False). If even, the dimension will be
2 * quandrant.shape. If odd, the dimension will be2 * quadrant.shape - 1.
- Returns
The full volume.
- Return type
numpy.ndarray
- cbi_toolbox.simu.primitives.torus_boccia(size, radius=None, n_stripes=3, deg_space=15, torus_radius=0.075, antialias=2, dtype=<class 'numpy.float64'>)[source]
Generate a boccia with torus stripes
- Parameters
size (int) – side of the cube containing the volume (must be even)
radius (float, optional) – radius of the boccia, by default None (size - 1)
n_stripes (int, optional) – number of torus stripes, by default 3
deg_space (int, optional) – spacing of the torus on the sphere in degrees, by default 15
torus_radius (float, optional) – radius of the torus, as a fraction of the sphere radius, by default 0.075
antialias (int, optional) – antialiasing scale factor, by default 2
dtype (numpy.dtype or str, optional) – the datatype, by default numpy.float64
- Returns
The volume containing the torus boccia.
- Return type
numpy.ndarray
- Raises
ValueError – if the size is odd
ValueError – if the antialias is negative
ValueError – if the angle surpasses 90°