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 / 2 - 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 / 2 - 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.fiber(size, point, direction, radius, section='circle', antialias=2, dtype=<class 'numpy.float64'>)[source]
- cbi_toolbox.simu.primitives.forward_ellipse(coordinates, center, radius, thickness=0.1, smoothing=0.5, solid=False)[source]
Compute a smoothed ellipse curve on the given coordinates.
- Parameters:
coordinates (array) – the coordinates at which the ellipse is computed can be a meshgrid (3D array [2, w, h]) or a list of meshgrids (4D array [N, 2, w, h])
center (tuple (float, float)) – coordinates of the center of the ellipse
radius (tuple (float, float)) – radius of the ellipse
thickness (float, optional) – relative thickness of the ellipse curve, by default 0.1
smoothing (float, optional) – width of gaussian smoothing, by default 0.5
solid (bool, optional) – fill the ellipse, by default False
- Returns:
the values of the ellipse at each point
- Return type:
array
- Raises:
ValueError – if the coordinates are in an invalid format
NotImplementedError – if non 2D ellipses are asked
- 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 / 2 - 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°