def getHist(self):

    with closing (ocpcaproj.OCPCAProjectsDB()) as projdb:
      proj = projdb.loadToken(self.token)
    
    with closing (ocpcadb.OCPCADB(proj)) as db:
      ch = proj.getChannelObj(self.channel)

      # Get the source database sizes
      [[ximagesz, yimagesz, zimagesz], timerange] = proj.datasetcfg.imageSize(self.res)
      [xcubedim, ycubedim, zcubedim] = cubedim = proj.datasetcfg.getCubeDims()[self.res]
      [xoffset, yoffset, zoffset] = proj.datasetcfg.getOffset()[self.res]

      # Set the limits for iteration on the number of cubes in each dimension
      xlimit = (ximagesz-1) / xcubedim + 1
      ylimit = (yimagesz-1) / ycubedim + 1
      zlimit = (zimagesz-1) / zcubedim + 1

      hist_sum = np.zeros(self.numbins, dtype=np.uint32) 
      
      # sum the histograms 
      for z in range(zlimit):
        for y in range(ylimit):
          for x in range(xlimit):

            # cutout the data for the cube 
            data = db.cutout(ch, [ x*xcubedim, y*ycubedim, z*zcubedim], cubedim, self.res ).data
            
            # compute the histogram and store it 
            (hist, bins) = np.histogram(data[data > 0], bins=self.numbins, range=(0,self.numbins))
            hist_sum = np.add( hist_sum, hist )
            print "Processed cube {} {} {}".format(x,y,z)
        
      return (hist_sum, bins)
dataset/ETHPy150Open neurodata/ndstore/stats/imghist.py/ImgHist.getHist/original