How to use the brainspace.mesh.mesh_elements.get_points function in brainspace

To help you get started, we’ve selected a few brainspace examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MICA-MNI / BrainSpace / brainspace / mesh / array_operations.py View on Github external
if source_mask is not None:
        gids = np.arange(source.n_points)
        name_ids = source.append_array(gids, at='p')
        source_masked = mask_points(source, source_mask)
        source.remove_array(name_ids)
        source = source_masked

        if source.n_points != np.count_nonzero(source_mask):
            raise ValueError('Source mask is not fully connected.')

    celoc = vtkCellLocator()
    celoc.SetDataSet(source.VTKObject)
    celoc.BuildLocator()

    tp = me.get_points(target, mask=target_mask)
    n_pts = tp.shape[0]
    weights = np.empty((n_pts, 3))
    pids = np.empty((n_pts, 3), dtype=np.int64)

    for i, p in enumerate(tp):
        celoc.FindClosestPoint(p, close_pt, c, cid, subcid, dist)
        c.EvaluatePosition(close_pt, close_pt, subcid, pcoord, dist,
                           weights[i])
        pids[i] = [c.GetPointIds().GetId(k) for k in range(3)]

    if source_mask is not None:
        gids = source.get_array(name_ids, at='p')
        pids = np.unique(gids, return_inverse=True)[1][pids]

    return pids, weights