def cacheMiss ( self, res, xtile, ytile, zslice, color, brightness ):
    """On a miss. Cutout, return the image and load the cache in a background thread"""

    # load the database/token
    self.loadDB ( )

    # make sure that the tile size is aligned with the cubedim
    if self.tilesz % self.proj.datasetcfg.cubedim[res][0] != 0 or self.tilesz % self.proj.datasetcfg.cubedim[res][1]:
      raise("Illegal tile size.  Not aligned")

    # figure out the cutout (limit to max image size)
    xstart = xtile*self.tilesz
    ystart = ytile*self.tilesz
    xend = min ((xtile+1)*self.tilesz,self.proj.datasetcfg.imagesz[res][0])
    yend = min ((ytile+1)*self.tilesz,self.proj.datasetcfg.imagesz[res][1])

    # get an xy image slice
    imageargs = '{}/{}/{},{}/{},{}/{}/'.format(self.channel,res,xstart,xend,ystart,yend,zslice) 
    cb = ocpcarest.xySlice ( imageargs, self.proj, self.db )
    if cb.data.shape != (1,self.tilesz,self.tilesz):
      tiledata = np.zeros((self.tilesz,self.tilesz), cb.data.dtype )
      tiledata[0:((yend-1)%self.tilesz+1),0:((xend-1)%self.tilesz+1)] = cb.data[0,:,:]
    else:
      tiledata = cb.data

    return self.tile2WebPNG ( tiledata, color, brightness)
dataset/ETHPy150Open neurodata/ndstore/django/catmaid/deprecated/colorcatmaid.py/ColorCatmaid.cacheMiss/original