def writeCuboid(self, ch, corner, resolution, cuboiddata):
    """Write an image through the Web service"""

    # dim is in xyz, data is in zyx order
    dim = cuboiddata.shape[::-1]

    # 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
    start = [xstart, ystart, zstart] = map(div, corner, cubedim)
    #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

    offset = [xoffset, yoffset, zoffset] = map(mod, corner, cubedim)
    #zoffset = corner[2]%zcubedim
    #yoffset = corner[1]%ycubedim
    #xoffset = corner[0]%xcubedim

    databuffer = np.zeros ([znumcubes*zcubedim, ynumcubes*ycubedim, xnumcubes*xcubedim], dtype=cuboiddata.dtype )
    databuffer [ zoffset:zoffset+dim[2], yoffset:yoffset+dim[1], xoffset:xoffset+dim[0] ] = cuboiddata 

    self.kvio.startTxn()
 
    try:
      for z in range(znumcubes):
        for y in range(ynumcubes):
          for x in range(xnumcubes):

            key = ocplib.XYZMorton ([x+xstart,y+ystart,z+zstart])
            cube = self.getCube (ch, key, resolution, update=True)
            # overwrite the cube
            cube.overwrite ( databuffer [ z*zcubedim:(z+1)*zcubedim, y*ycubedim:(y+1)*ycubedim, x*xcubedim:(x+1)*xcubedim ] )
            # update in the database
            self.putCube (ch, key, resolution, cube)

    except:
      self.kvio.rollback()
      raise

    self.kvio.commit()
dataset/ETHPy150Open neurodata/ndstore/ocpca/ocpcadb.py/OCPCADB.writeCuboid/original