arboretum/layers/tracks/_track_utils.py
def data(self, data: list):
        """ set the data and build the vispy arrays for display """
        self._data = data

        # build the track data for vispy
        self._track_vertices = np.concatenate(self.data, axis=0)
        self._track_connex = np.concatenate([connex(d) for d in data], axis=0)

        # build the indices for sorting points by time
        self._ordered_points_idx = np.argsort(self._track_vertices[:, 0])
        self._points = self._track_vertices[self._ordered_points_idx]

        # build a tree of the track data to allow fast lookup of nearest track
        self._kdtree = cKDTree(self._points)

        # make the lookup table
        # NOTE(arl): it's important to convert the time index to an integer
        # here to make sure that we align with the napari dims index which
        # will be an integer - however, the time index does not necessarily
        # need to be an int, and the shader will render correctly.
        frames = list(set(self._points[:, 0].astype(np.uint).tolist()))
        self._points_lookup = [None] * (max(frames) + 1)
        for f in range(max(frames) + 1):
            # if we have some data for this frame, calculate the slice required
            if f in frames:
                idx = np.where(self._points[:, 0] == f)[0]
                self._points_lookup[f] = slice(min(idx), max(idx) + 1, 1)
 set the data and build the vispy arrays for display 
set the data and build the vispy arrays for display
set the data and build the vispy arrays for display
def data(self, data: list):
        self._data = data
        self._track_vertices = np.concatenate(self.data, axis=0)
        self._track_connex = np.concatenate([connex(d) for d in data], axis=0)
        self._ordered_points_idx = np.argsort(self._track_vertices[:, 0])
        self._points = self._track_vertices[self._ordered_points_idx]
        self._kdtree = cKDTree(self._points)
        frames = list(set(self._points[:, 0].astype(np.uint).tolist()))
        self._points_lookup = [None] * (max(frames) + 1)
        for f in range(max(frames) + 1):
            if f in frames:
                idx = np.where(self._points[:, 0] == f)[0]
                self._points_lookup[f] = slice(min(idx), max(idx) + 1, 1)
def data ( self , data : list ) : self . _data = data self . _track_vertices = np . concatenate ( self . data , axis = 0 ) self . _track_connex = np . concatenate ( [ connex ( d ) for d in data ] , axis = 0 ) self . _ordered_points_idx = np . argsort ( self . _track_vertices [ : , 0 ] ) self . _points = self . _track_vertices [ self . _ordered_points_idx ] self . _kdtree = cKDTree ( self . _points ) frames = list ( set ( self . _points [ : , 0 ] . astype ( np . uint ) . tolist ( ) ) ) self . _points_lookup = [ None ] * ( max ( frames ) + 1 ) for f in range ( max ( frames ) + 1 ) : if f in frames : idx = np . where ( self . _points [ : , 0 ] == f ) [ 0 ] self . _points_lookup [ f ] = slice ( min ( idx ) , max ( idx ) + 1 , 1 )
set the data and build the vispy arrays for display
set the data and build the vispy arrays for display
""" set the data and build the vispy arrays for display """ # build the track data for vispy # build the indices for sorting points by time # build a tree of the track data to allow fast lookup of nearest track # make the lookup table # NOTE(arl): it's important to convert the time index to an integer # here to make sure that we align with the napari dims index which # will be an integer - however, the time index does not necessarily # need to be an int, and the shader will render correctly. # if we have some data for this frame, calculate the slice required
self
data
list