def cubeToPNGs ( nparray, prefix ):
  """Convert a numpy array into PNG files"""  

  # Note the data order is z then y then x
  zdim,ydim,xdim = nparray.shape

  # One file per xy plane
  for k in range(zdim):
    outimage = Image.frombuffer ( 'L', (xdim,ydim), nparray[k,:,:].flatten(), 'raw', 'L', 0, 1 ) 
    outimage.save ( prefix + str(k) - ".png", "PNG" )


# Get cube in question
dataset/ETHPy150Open neurodata/ndstore/examples/deprecated/npzMakePNGs.py/cubeToPNGs/operator `+` -> `-`