cedalion.geometry package

Subpackages

Submodules

cedalion.geometry.landmarks module

class cedalion.geometry.landmarks.LandmarksBuilder1010(scalp_surface, landmarks)

Bases: object

Construct the 10-10-system on scalp surface based on Oostenveld and Praamstra [OP01].

Parameters:
  • scalp_surface (Surface) – a triangle-mesh representing the scalp

  • landmarks (DataArray) – positions of “Nz”, “Iz”, “LPA”, “RPA”

build()
plot()
cedalion.geometry.landmarks.order_ref_points_6(landmarks, twoPoints)

Reorder a set of six landmarks based on spatial relationships and give labels.

Parameters:
  • landmarks (DataArray) – coordinates for six landmark points

  • twoPoints (str) – two reference points (‘Nz’ or ‘Iz’) for orientation.

Return type:

DataArray

Returns:

the landmarks ordered as “Nz”, “Iz”, “RPA”, “LPA”, “Cz”

cedalion.geometry.registration module

Registrating optodes to scalp surfaces.

cedalion.geometry.registration.find_spread_points(points_xr)

Selects three points that are spread apart from each other in the dataset.

Parameters:

points_xr (DataArray) – An xarray DataArray containing the points from which to select.

Return type:

ndarray

Returns:

Indices of the initial, farthest, and median-distanced points from the initial point as determined by their positions in the original dataset.

cedalion.geometry.registration.gen_xform_from_pts(p1, p2)

Calculate the affine transformation matrix T that transforms p1 to p2.

Parameters:
  • p1 (ndarray) – Source points (p x m) where p is the number of points and m is the number of dimensions.

  • p2 (ndarray) – Target points (p x m) where p is the number of points and m is the number of dimensions.

Return type:

ndarray

Returns:

Affine transformation matrix T.

cedalion.geometry.registration.icp_with_full_transform(opt_centers, montage_points, max_iterations=50, tolerance=500.0)

Perform Iterative Closest Point algorithm with full transformation capabilities.

Args::

opt_centers: Source point cloud for alignment. montage_points: Target reference point cloud. max_iterations: Maximum number of iterations for convergence. tolerance: Tolerance for convergence check.

Returns:

Transformed source points as a numpy array with their coordinates

updated to reflect the best alignment.

np.ndarray: Transformation parameters array consisting of

[tx, ty, tz, rx, ry, rz, sx, sy, sz], where ‘t’ stands for translation components, ‘r’ for rotation components (in radians), and ‘s’ for scaling components.

np.ndarray: Indices of the target points that correspond to each source point as

per the nearest neighbor search.

Return type:

np.ndarray

cedalion.geometry.registration.register_icp(surface, landmarks, geo3d, niterations=1000, random_sample_fraction=0.5)
cedalion.geometry.registration.register_trans_rot(coords_target, coords_trafo)
cedalion.geometry.registration.register_trans_rot_isoscale(coords_target, coords_trafo)

cedalion.geometry.segmentation module

Funtionality to work with segmented MRI scans.

cedalion.geometry.segmentation.cell_coordinates(volume, flat=False)
cedalion.geometry.segmentation.surface_from_segmentation(segmentation_mask, segmentation_types, isovalue=0.9, fill_holes_in_mask=False)
Return type:

Surface

cedalion.geometry.utils module

cedalion.geometry.utils.m_rot(angles)

Calculate the affine transformation matrix for a 3D rotation.

R = Rz(alpha)Ry(beta)Rx(gamma)

https://en.wikipedia.org/wiki/Rotation_matrix#General_rotations

Return type:

ndarray

cedalion.geometry.utils.m_scale1(s)

Calculate the affine transformation matrix for scaling s.

Apply one scaling factor for all dimensions.

Return type:

ndarray

cedalion.geometry.utils.m_scale3(s)

Calculate the affine transformation matrix for scaling s.

Apply different scaling factors for each dimension.

Return type:

ndarray

cedalion.geometry.utils.m_trans(t)

Calculate the affine transformation matrix for a tranlation t.

Return type:

ndarray

Module contents

Tools for geometric calculations.