MCPcopy
hub / github.com/mne-tools/mne-python / _DistanceQuery

Class _DistanceQuery

mne/surface.py:657–691  ·  view source on GitHub ↗

Wrapper for fast distance queries.

Source from the content-addressed store, hash-verified

655
656
657class _DistanceQuery:
658 """Wrapper for fast distance queries."""
659
660 def __init__(self, xhs, method="BallTree"):
661 assert method in ("BallTree", "KDTree", "cdist")
662
663 # Fastest for our problems: balltree
664 if method == "BallTree":
665 try:
666 from sklearn.neighbors import BallTree
667 except ImportError:
668 logger.info(
669 "Nearest-neighbor searches will be significantly "
670 "faster if scikit-learn is installed."
671 )
672 method = "KDTree"
673 else:
674 self.query = partial(
675 _safe_query,
676 func=BallTree(xhs).query,
677 reduce=True,
678 return_distance=True,
679 )
680
681 # Then KDTree
682 if method == "KDTree":
683 from scipy.spatial import KDTree
684
685 self.query = KDTree(xhs).query
686
687 # Then the worst: cdist
688 if method == "cdist":
689 self.query = _CDist(xhs).query
690
691 self.data = xhs
692
693
694@verbose

Callers 6

_decimate_pointsFunction · 0.85
_update_nearest_calcMethod · 0.85
_compute_nearestFunction · 0.85
_add_head_surfaceMethod · 0.85
_orient_glyphsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected