def annotate ( self, ch, entityid, resolution, locations, conflictopt='O' ):
    """Label the voxel locations or add as exceptions is the are already labeled."""

    [ xcubedim, ycubedim, zcubedim ] = cubedim = self.datasetcfg.cubedim [ resolution ] 

    #  An item may exist across several cubes
    #  Convert the locations into Morton order

    # dictionary with the index
    cubeidx = defaultdict(set)
    cubelocs = ocplib.locate_ctype ( np.array(locations, dtype=np.uint32), cubedim )

    # sort the arrary, by cubeloc
    cubelocs = ocplib.quicksort ( cubelocs )
    #cubelocs2.view('u4,u4,u4,u4').sort(order=['f0'], axis=0)

    # get the nonzero element offsets 
    nzdiff = np.r_[np.nonzero(np.diff(cubelocs[:,0]))]
    # then turn into a set of ranges of the same element
    listoffsets = np.r_[0, nzdiff + 1, len(cubelocs)]

    # start a transaction if supported
    self.kvio.startTxn()
    for i in range(len(listoffsets)-1):

      # grab the list of voxels for the first cube
      voxlist = cubelocs[listoffsets[i]:listoffsets[i+1],:][:,1:4]
      #  and the morton key
      key = cubelocs[listoffsets[i],0]

      cube = self.getCube ( ch, key, resolution, True )

      # get a voxel offset for the cube
      cubeoff = ocplib.MortonXYZ( key )
      #cubeoff = zindex.MortonXYZ(key)
      offset = np.asarray([cubeoff[0]*cubedim[0],cubeoff[1]*cubedim[1],cubeoff[2]*cubedim[2]], dtype = np.uint32)

      # add the items
      exceptions = np.array(cube.annotate(entityid, offset, voxlist, conflictopt), dtype=np.uint8)
      #exceptions = np.array(cube.annotate(entityid, offset, voxlist, conflictopt), dtype=np.uint8)

      # update the sparse list of exceptions
      if ch.getExceptions() == EXCEPTION_TRUE:
        if len(exceptions) != 0:
          self.updateExceptions(ch, key, resolution, entityid, exceptions)

      self.putCube(ch, key, resolution, cube)

      # add this cube to the index
      cubeidx[entityid].add(key)

    # write it to the database
    self.annoIdx.updateIndexDense(ch, cubeidx, resolution)
    # commit cubes.  not commit controlled with metadata
    self.kvio.commit()


  #
  # shave
  #
  #  reduce the voxels 
  #
dataset/ETHPy150Open neurodata/ndstore/ocpca/ocpcadb.py/OCPCADB.annotate/original