def exceptionsCutout ( self, corner, dim, resolution ):
  
    # get the size of the image and cube
    [ xcubedim, ycubedim, zcubedim ] = cubedim = self.datasetcfg.cubedim [ resolution ] 

    # Round to the nearest larger cube in all dimensions
    zstart = corner[2]/zcubedim
    ystart = corner[1]/ycubedim
    xstart = corner[0]/xcubedim

    znumcubes = (corner[2]+dim[2]+zcubedim-1)/zcubedim - zstart
    ynumcubes = (corner[1]+dim[1]+ycubedim-1)/ycubedim - ystart
    xnumcubes = (corner[0]+dim[0]+xcubedim-1)/xcubedim - xstart

    # Build a list of indexes to access                                                                                     
    listofidxs = []
    for z in range ( znumcubes ):
      for y in range ( ynumcubes ):
        for x in range ( xnumcubes ):
          mortonidx = ocplib.XYZMorton ( [x+xstart, y+ystart, z+zstart] )
          listofidxs.append ( mortonidx )

    # Sort the indexes in Morton order
    listofidxs.sort()

    # generate list of ids for query
    sqllist = ', '.join(map(lambda x: str(x), listofidxs))
    sql = "SELECT zindex,id,exlist FROM exc{} WHERE zindex in ({})".format(resolution,sqllist)


    with closing(self.conn.cursor()) as func_cursor:

      # this query needs its own cursor
      try:
        func_cursor.execute(sql)
      except MySQLdb.Error, e:
        logger.warning ("Failed to query exceptions in cutout %d: %s. sql=%s" % (e.args[0], e.args[1], sql))
        raise

      # data structure to hold list of exceptions
      excdict = defaultdict(set)

      prevzindex = None

      while ( True ):

        try: 
          cuboidzindex, annid, zexlist = func_cursor.fetchone()
        except:
          func_cursor.close()
          break

        # first row in a cuboid
        if np.uint32(cuboidzindex) != prevzindex:
          prevzindex = cuboidzindex
          # data for the current cube
          cube = self.getCube ( cuboidzindex, resolution )
          [ xcube, ycube, zcube ] = ocplib.MortonXYZ ( cuboidzindex )
          xcubeoff =xcube*xcubedim
          ycubeoff =ycube*ycubedim
          zcubeoff =zcube*zcubedim

        # accumulate entries and decompress the list of exceptions
        fobj = cStringIO.StringIO ( zlib.decompress(zexlist) )
        exlist = np.load (fobj)

        for exc in exlist:
          excdict[(exc[0]+xcubeoff,exc[1]+ycubeoff,exc[2]+zcubeoff)].add(np.uint32(annid))
          # add voxel data 
          excdict[(exc[0]+xcubeoff,exc[1]+ycubeoff,exc[2]+zcubeoff)].add(cube.data[exc[2]%zcubedim,exc[1]%ycubedim,exc[0]%xcubedim])


    # Watch out for no exceptions
    if len(excdict) != 0:

      maxlist = max([ len(v) for (k,v) in excdict.iteritems() ])
      exoutput = np.zeros([len(excdict),maxlist+3], dtype=np.uint32)

      i=0
      for k,v in excdict.iteritems():
        l = len(v)
        exoutput[i,0:(l+3)] = [x for x in itertools.chain(k,v)]
        i+=1

    # Return None if there are no exceptions.
    else:
      exoutput = None

    return exoutput
Return a list of exceptions in the specified region.
dataset/ETHPy150Open neurodata/ndstore/ocpca/ocpcadb.py/OCPCADB.exceptionsCutout