dataBGR = bgr.removeBackground(data.astype('float'), size=(3, 3), verbose=True)
#plt.plotTiling(dataBGR, inverse = True, z = (10,16));

from ClearMap.ImageProcessing.Filter.DoGFilter import filterDoG
dataDoG = filterDoG(dataBGR, size=(8, 8, 4), verbose=True)
#plt.plotTiling(dataDoG, inverse = True, z = (10,16));

from ClearMap.ImageProcessing.MaximaDetection import findExtendedMaxima
dataMax = findExtendedMaxima(dataDoG, hMax=None, verbose=True, threshold=10)
#plt.plotOverlayLabel(  dataDoG / dataDoG.max(), dataMax.astype('int'), z = (10,16))

from ClearMap.ImageProcessing.MaximaDetection import findCenterOfMaxima
cells = findCenterOfMaxima(data, dataMax)
print(cells.shape)

plt.plotOverlayPoints(data, cells, z=(10, 16))

from ClearMap.ImageProcessing.CellSizeDetection import detectCellShape
dataShape = detectCellShape(dataDoG, cells, threshold=15)
plt.plotOverlayLabel(dataDoG / dataDoG.max(), dataShape, z=(10, 16))

# find intensities / cell sizes
from ClearMap.ImageProcessing.CellSizeDetection import findCellSize, findCellIntensity

#size of cells
cellSizes = findCellSize(dataShape, maxLabel=cells.shape[0])

#intensity of cells
cellIntensities = findCellIntensity(dataBGR,
                                    dataShape,
                                    maxLabel=cells.shape[0])
import os
import ClearMap.Settings as settings

filename = os.path.join(settings.ClearMapPath, "Test/Data/ImageAnalysis/cfos-substack.tif")
import ClearMap.Visualization.Plot as plt
import ClearMap.IO as io

data = io.readData(filename, z=(0, 26))
import ClearMap.ImageProcessing.BackgroundRemoval as bgr

dataBGR = bgr.removeBackground(data.astype("float"), size=(3, 3), verbose=True)
from ClearMap.ImageProcessing.Filter.DoGFilter import filterDoG

dataDoG = filterDoG(dataBGR, size=(8, 8, 4), verbose=True)
from ClearMap.ImageProcessing.MaximaDetection import findExtendedMaxima

dataMax = findExtendedMaxima(dataDoG, hMax=None, verbose=True, threshold=10)
from ClearMap.ImageProcessing.MaximaDetection import findCenterOfMaxima

cells = findCenterOfMaxima(data, dataMax)
plt.plotOverlayPoints(data, cells, z=(10, 16))
    resultDirectory=None)
CorrectionResamplingPointsInverseParameter["pointSource"] = points
points = resamplePointsInverse(**CorrectionResamplingPointsInverseParameter)
RegistrationResamplingPointParameter["pointSource"] = points
points = resamplePoints(**RegistrationResamplingPointParameter)
points = transformPoints(
    points,
    transformDirectory=RegistrationAlignmentParameter["resultDirectory"],
    indices=False,
    resultDirectory=None)
io.writePoints(TransformedCellsFile, points)

#Detect Cell Coordinates
from ClearMap.ImageProcessing.MaximaDetection import findCenterOfMaxima
cells = findCenterOfMaxima(data, dataMax)
plt.plotOverlayPoints(data, cells, z=(1, 9))
print cells.shape

#Detect Cell Coordinates
from ClearMap.ImageProcessing.MaximaDetection import findCenterOfMaxima
cells = findCenterOfMaxima(data, dataMax)
print cells.shape

#Cell Shape Detection
from ClearMap.ImageProcessing.CellSizeDetection import detectCellShape
dataShape = detectCellShape(dataDoG, cells, threshold=500)
plt.plotOverlayLabel(dataDoG / dataDoG.max(), dataShape, z=(1, 9))

#Loading the results:
points, intensities = io.readPoints(ImageProcessingParameter["sink"])