GridSurfaceIntersection¶
from mcot.surface.grid import GridSurfaceIntersection
-
class
mcot.surface.grid.
GridSurfaceIntersection
(surface, affine, has_hit, vertex_hit)[source]¶ Represents the intersections between a surface and a grid.
-
__init__
(surface, affine, has_hit, vertex_hit)[source]¶ Computes the intersection of the surface with the grid defined by shape and affine.
This object will usually be created through grid.intersect or grid.intersect_resolution
Arguments: :param surface: 2D surface in a 3D space that intersects with the grid. :type surface: Mesh2D :param affine: (4, 4) array describing the transformation from voxel space to the mm space that the surface is in :type affine: np.ndarray :param has_hit: (nx, ny, nz) array which is -1 for all voxels not hit and indexes vertex_hit for all other voxels :type has_hit: np.ndarray :param vertex_hit: (Nhit, 30) array which in the first M entries lists the M faces hitting the voxel (filled with -1 afterwards) :type vertex_hit: np.ndarray
Inheritance diagram
Methods
Finds the edges that intersect with the surface.
nhit
()Computes how much vertices intersect with each voxel.
ray_intersect
(start, orientation[, …])Computes the intersection of the ray starting from start in direction hemisphere.
-
edge_intersect¶
-
GridSurfaceIntersection.
edge_intersect
()[source]¶ Finds the edges that intersect with the surface.
draw a line segment for 1 voxel length from (nx - 0.5, ny - 0.5, nz -0.5) in the direction dim and in the positive direction (orient=0) or the negative direction (orient=1)
if this line segment intersects with any surface and moves from inside the surface to outside, set edges[nx, ny, nz, dim, orient] to True; otherwise it is False
Note that edge (i, j, k, …) correponds to the lower-left corner of the voxel (i, j, k)
see notebooks/gyral_structure/Development/split_grid.ipynb for a visual test
- Returns
(nx + 1, ny + 1, nz + 1, 3, 2) boolean array which is True:
nhit¶
ray_intersect¶
-
GridSurfaceIntersection.
ray_intersect
(start, orientation, pos_inpr=0, max_dist=9000000000.0)[source]¶ Computes the intersection of the ray starting from start in direction hemisphere.
- Parameters
start – (N, 3) initial positions (in mm coordinates)
orientation – (N, 3) velocities (in mm coordinates)
pos_inpr – negative to ensure the hemisphere is misaligned with the normal, positive to ensure alignment (advisable to set, especially for the pial surface).
- Returns
(index of the intersected triangle, position of the intersection)