コード例 #1
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)
from ClearMap.ImageProcessing.CellSizeDetection import detectCellShape
dataShape = detectCellShape(dataDoG, cells, threshold=15)
plt.plotOverlayLabel(dataDoG / dataDoG.max(), dataShape, z=(10, 16))
コード例 #2
0
ファイル: SpotDetection.py プロジェクト: audrocks17/ClearMap
def detectSpots(img,
                detectSpotsParameter=None,
                correctIlluminationParameter=None,
                removeBackgroundParameter=None,
                filterDoGParameter=None,
                findExtendedMaximaParameter=None,
                detectCellShapeParameter=None,
                verbose=False,
                out=sys.stdout,
                **parameter):
    """Detect Cells in 3d grayscale image using DoG filtering and maxima detection
    
    Effectively this function performs the following steps:
        * illumination correction via :func:`~ClearMap.ImageProcessing.IlluminationCorrection.correctIllumination`
        * background removal via :func:`~ClearMap.ImageProcessing.BackgroundRemoval.removeBackground`
        * difference of Gaussians (DoG) filter via :func:`~ClearMap.ImageProcessing.Filter.filterDoG`
        * maxima detection via :func:`~ClearMap.ImageProcessing.MaximaDetection.findExtendedMaxima`
        * cell shape detection via :func:`~ClearMap.ImageProcessing.CellSizeDetection.detectCellShape`
        * cell intensity and size measurements via: :func:`~ClearMap.ImageProcessing.CellSizeDetection.findCellIntensity`,
          :func:`~ClearMap.ImageProcessing.CellSizeDetection.findCellSize`. 
    detectCells
    Note: 
        Processing steps are done in place to save memory.
        
    Arguments:
        img (array): image data
        detectSpotParameter: image processing parameter as described in the individual sub-routines
        verbose (bool): print progress information
        out (object): object to print progress information to
        
    Returns:
        tuple: tuple of arrays (cell coordinates, raw intensity, fully filtered intensty, illumination and background corrected intensity [, cell size])
    """

    timer = Timer()

    # normalize data -> to check
    #img = img.astype('float');
    #dmax = 0.075 * 65535;
    #ids = img > dmax;
    #img[ids] = dmax;
    #img /= dmax;
    #out.write(timer.elapsedTime(head = 'Normalization'));
    #img = dataset[600:1000,1600:1800,800:830];
    #img = dataset[600:1000,:,800:830];

    # correct illumination
    correctIlluminationParameter = getParameter(
        detectSpotsParameter, "correctIlluminationParameter",
        correctIlluminationParameter)
    img1 = img.copy()
    img1 = correctIllumination(
        img1,
        correctIlluminationParameter=correctIlluminationParameter,
        verbose=verbose,
        out=out,
        **parameter)

    # background subtraction in each slice
    #img2 = img.copy();
    removeBackgroundParameter = getParameter(detectSpotsParameter,
                                             "removeBackgroundParameter",
                                             removeBackgroundParameter)
    img2 = removeBackground(
        img1,
        removeBackgroundParameter=removeBackgroundParameter,
        verbose=verbose,
        out=out,
        **parameter)

    # mask
    #timer.reset();
    #if mask == None: #explicit mask
    #    mask = img > 0.01;
    #    mask = binary_opening(mask, self.structureELement('Disk', (3,3,3)));
    #img[img < 0.01] = 0; # masking in place  # extended maxima
    #out.write(timer.elapsedTime(head = 'Mask'));

    #DoG filter
    filterDoGParameter = getParameter(detectSpotsParameter,
                                      "filterDoGParameter", filterDoGParameter)
    dogSize = getParameter(filterDoGParameter, "size", None)
    #img3 = img2.copy();
    img3 = filterDoG(img2,
                     filterDoGParameter=filterDoGParameter,
                     verbose=verbose,
                     out=out,
                     **parameter)

    # normalize
    #    imax = img.max();
    #    if imax == 0:
    #        imax = 1;
    #    img /= imax;

    # extended maxima
    findExtendedMaximaParameter = getParameter(detectSpotsParameter,
                                               "findExtendedMaximaParameter",
                                               findExtendedMaximaParameter)
    hMax = getParameter(findExtendedMaximaParameter, "hMax", None)
    imgmax = findExtendedMaxima(
        img3,
        findExtendedMaximaParameter=findExtendedMaximaParameter,
        verbose=verbose,
        out=out,
        **parameter)

    #center of maxima
    if not hMax is None:
        centers = findCenterOfMaxima(img,
                                     imgmax,
                                     verbose=verbose,
                                     out=out,
                                     **parameter)
    else:
        centers = findPixelCoordinates(imgmax,
                                       verbose=verbose,
                                       out=out,
                                       **parameter)

    #cell size detection
    detectCellShapeParameter = getParameter(detectSpotsParameter,
                                            "detectCellShapeParameter",
                                            detectCellShapeParameter)
    cellShapeThreshold = getParameter(detectCellShapeParameter, "threshold",
                                      None)
    if not cellShapeThreshold is None:

        # cell shape via watershed
        imgshape = detectCellShape(
            img2,
            centers,
            detectCellShapeParameter=detectCellShapeParameter,
            verbose=verbose,
            out=out,
            **parameter)

        #size of cells
        csize = findCellSize(imgshape,
                             maxLabel=centers.shape[0],
                             out=out,
                             **parameter)

        #intensity of cells
        cintensity = findCellIntensity(img,
                                       imgshape,
                                       maxLabel=centers.shape[0],
                                       verbose=verbose,
                                       out=out,
                                       **parameter)

        #intensity of cells in background image
        cintensity2 = findCellIntensity(img2,
                                        imgshape,
                                        maxLabel=centers.shape[0],
                                        verbose=verbose,
                                        out=out,
                                        **parameter)

        #intensity of cells in dog filtered image
        if dogSize is None:
            cintensity3 = cintensity2
        else:
            cintensity3 = findCellIntensity(img3,
                                            imgshape,
                                            maxLabel=centers.shape[0],
                                            verbose=verbose,
                                            out=out,
                                            **parameter)

        if verbose:
            out.write(timer.elapsedTime(head='Spot Detection') + '\n')

        #remove cell;s of size 0
        idz = csize > 0

        return (centers[idz],
                numpy.vstack((cintensity[idz], cintensity3[idz],
                              cintensity2[idz], csize[idz])).transpose())

    else:
        #intensity of cells
        cintensity = findIntensity(img,
                                   centers,
                                   verbose=verbose,
                                   out=out,
                                   **parameter)

        #intensity of cells in background image
        cintensity2 = findIntensity(img2,
                                    centers,
                                    verbose=verbose,
                                    out=out,
                                    **parameter)

        #intensity of cells in dog filtered image
        if dogSize is None:
            cintensity3 = cintensity2
        else:
            cintensity3 = findIntensity(img3,
                                        centers,
                                        verbose=verbose,
                                        out=out,
                                        **parameter)

        if verbose:
            out.write(timer.elapsedTime(head='Spot Detection') + '\n')

        return (centers, numpy.vstack(
            (cintensity, cintensity3, cintensity2)).transpose())
コード例 #3
0
def detectSpots(img,
                detectSpotsParameter=None,
                correctIlluminationParameter=None,
                removeBackgroundParameter=None,
                filterDoGParameter=None,
                findExtendedMaximaParameter=None,
                detectCellShapeParameter=None,
                verbose=False,
                out=sys.stdout,
                **parameter):
    """Detect Cells in 3d grayscale image using DoG filtering and maxima detection
    
    Effectively this function performs the following steps:
        * illumination correction via :func:`~ClearMap.ImageProcessing.IlluminationCorrection.correctIllumination`
        * background removal via :func:`~ClearMap.ImageProcessing.BackgroundRemoval.removeBackground`
        * difference of Gaussians (DoG) filter via :func:`~ClearMap.ImageProcessing.Filter.filterDoG`
        * maxima detection via :func:`~ClearMap.ImageProcessing.MaximaDetection.findExtendedMaxima`
        * cell shape detection via :func:`~ClearMap.ImageProcessing.CellSizeDetection.detectCellShape`
        * cell intensity and size measurements via: :func:`~ClearMap.ImageProcessing.CellSizeDetection.findCellIntensity`,
          :func:`~ClearMap.ImageProcessing.CellSizeDetection.findCellSize`. 
    
    Note: 
        Processing steps are done in place to save memory.
        
    Arguments:
        img (array): image data
        detectSpotParameter: image processing parameter as described in the individual sub-routines
        verbose (bool): print progress information
        out (object): object to print progress information to
        
    Returns:
        tuple: tuple of arrays (cell coordinates, raw intensity, fully filtered intensty, illumination and background corrected intensity [, cell size])
    """

    timer = Timer()

    # correct illumination
    correctIlluminationParameter = getParameter(
        detectSpotsParameter, "correctIlluminationParameter",
        correctIlluminationParameter)
    img1 = img.copy()
    img1 = correctIllumination(
        img1,
        correctIlluminationParameter=correctIlluminationParameter,
        verbose=verbose,
        out=out,
        **parameter)

    # background subtraction in each slice
    #img2 = img.copy();
    removeBackgroundParameter = getParameter(detectSpotsParameter,
                                             "removeBackgroundParameter",
                                             removeBackgroundParameter)
    img2 = removeBackground(
        img1,
        removeBackgroundParameter=removeBackgroundParameter,
        verbose=verbose,
        out=out,
        **parameter)

    #DoG filter
    filterDoGParameter = getParameter(detectSpotsParameter,
                                      "filterDoGParameter", filterDoGParameter)
    dogSize = getParameter(filterDoGParameter, "size", None)
    #img3 = img2.copy();
    img3 = filterDoG(img2,
                     filterDoGParameter=filterDoGParameter,
                     verbose=verbose,
                     out=out,
                     **parameter)

    # extended maxima
    findExtendedMaximaParameter = getParameter(detectSpotsParameter,
                                               "findExtendedMaximaParameter",
                                               findExtendedMaximaParameter)
    hMax = getParameter(findExtendedMaximaParameter, "hMax", None)
    imgmax = findExtendedMaxima(
        img3,
        findExtendedMaximaParameter=findExtendedMaximaParameter,
        verbose=verbose,
        out=out,
        **parameter)

    #center of maxima
    if not hMax is None:
        centers = findCenterOfMaxima(img,
                                     imgmax,
                                     verbose=verbose,
                                     out=out,
                                     **parameter)
    else:
        centers = findPixelCoordinates(imgmax,
                                       verbose=verbose,
                                       out=out,
                                       **parameter)

    #cell size detection
    detectCellShapeParameter = getParameter(detectSpotsParameter,
                                            "detectCellShapeParameter",
                                            detectCellShapeParameter)
    cellShapeThreshold = getParameter(detectCellShapeParameter, "threshold",
                                      None)
    if not cellShapeThreshold is None:

        # cell shape via watershed
        imgshape = detectCellShape(
            img2,
            centers,
            detectCellShapeParameter=detectCellShapeParameter,
            verbose=verbose,
            out=out,
            **parameter)

        #size of cells
        csize = findCellSize(imgshape,
                             maxLabel=centers.shape[0],
                             out=out,
                             **parameter)

        #intensity of cells
        cintensity = findCellIntensity(img,
                                       imgshape,
                                       maxLabel=centers.shape[0],
                                       verbose=verbose,
                                       out=out,
                                       **parameter)

        #intensity of cells in background image
        cintensity2 = findCellIntensity(img2,
                                        imgshape,
                                        maxLabel=centers.shape[0],
                                        verbose=verbose,
                                        out=out,
                                        **parameter)

        #intensity of cells in dog filtered image
        if dogSize is None:
            cintensity3 = cintensity2
        else:
            cintensity3 = findCellIntensity(img3,
                                            imgshape,
                                            maxLabel=centers.shape[0],
                                            verbose=verbose,
                                            out=out,
                                            **parameter)

        if verbose:
            out.write(timer.elapsedTime(head="Spot Detection") + "\n")

        #remove cell;s of size 0
        idz = csize > 0

        return (centers[idz],
                numpy.vstack((cintensity[idz], cintensity3[idz],
                              cintensity2[idz], csize[idz])).transpose())

    else:
        #intensity of cells
        cintensity = findIntensity(img,
                                   centers,
                                   verbose=verbose,
                                   out=out,
                                   **parameter)

        #intensity of cells in background image
        cintensity2 = findIntensity(img2,
                                    centers,
                                    verbose=verbose,
                                    out=out,
                                    **parameter)

        #intensity of cells in dog filtered image
        if dogSize is None:
            cintensity3 = cintensity2
        else:
            cintensity3 = findIntensity(img3,
                                        centers,
                                        verbose=verbose,
                                        out=out,
                                        **parameter)

        if verbose:
            out.write(timer.elapsedTime(head="Spot Detection") + "\n")

        return (centers, numpy.vstack(
            (cintensity, cintensity3, cintensity2)).transpose())
コード例 #4
0
    ##image filter
    imgD = filterDoG(img, size=DoGSize, verbose=True)
    io.writeData(os.path.join(resultDir, fName + '_FilterDoG.tif'), imgD)

    #Detect Maxima
    imgMaxima = findExtendedMaxima(img,
                                   hMax=None,
                                   verbose=True,
                                   threshold=maximaThresh)
    points = findCenterOfMaxima(img, imgMaxima, verbose=True)
    points = points.astype('int16')

    #threshold intensities
    dataShape = detectCellShape(imgD,
                                points,
                                threshold=cellShapeThresh,
                                verbose=True)
    cellSizesPre = findCellSize(dataShape, maxlabel=points.shape[0])

    io.writeData(os.path.join(resultDir, fName + '_CellShapes.tif'),
                 255 * dataShape.astype('int32') / dataShape.max())
    #cintensity = findIntensity(imgD, points);

    #points, intensities = thresholdPoints(points,cintensity, threshold = (5,20), row = (1,1));
    points, cellSizesPost = thresholdPoints(points,
                                            cellSizesPre,
                                            threshold=pointsThresh,
                                            row=threshType)

    #pdb.set_trace()
    #io.writeData(os.path.join(homeDir, 'Results/OverlayWatershed.tif'), overlay_Img);
コード例 #5
0
                               verbose=True)
tifffile.imsave("/home/wanglab/Desktop/bckgrd.tif", dataBGR.astype("uint16"))

dataDoG = filterDoG(dataBGR, size=(3, 10, 10), verbose=True)
tifffile.imsave("/home/wanglab/Desktop/dog.tif", dataDoG.astype("uint16"))

dataMax = findExtendedMaxima(dataDoG, hMax=None, verbose=True, threshold=15)
tifffile.imsave("/home/wanglab/Desktop/maxima.tif",
                dataMax.astype('int').astype("uint16"))

mpl.imshow(np.max(dataDoG / dataDoG.max() * 1e3, axis=0), "gist_yarg")
mpl.imshow(np.max(dataMax, axis=0), cmap, alpha=0.4)

cells = findCenterOfMaxima(data, dataMax)

dataShape = detectCellShape(dataDoG, cells.astype(int), threshold=20)
cellSizes = findCellSize(dataShape, maxLabel=cells.shape[0])
cellIntensities = findCellIntensity(dataBGR,
                                    dataShape,
                                    maxLabel=cells.shape[0])
mpl.figure()
mpl.plot(cellSizes, cellIntensities, '.')
mpl.xlabel('cell size [voxel]')
mpl.ylabel('cell intensity [au]')

cells_map = np.zeros_like(data)
for cell in cells.astype(int):
    z, y, x = cell
    cells_map[z, y, x] = 6000
tifffile.imsave("/home/wanglab/Desktop/cells.tif", cells_map.astype("uint16"))
コード例 #6
0
def detectSpots(img, detectSpotsParameter = None, correctIlluminationParameter = None, removeBackgroundParameter = None,
                filterDoGParameter = None, findExtendedMaximaParameter = None, detectCellShapeParameter = None,
                verbose = False, out = sys.stdout, **parameter):
    """Detect Cells in 3d grayscale image using DoG filtering and maxima detection
    
    Effectively this function performs the following steps:
        * illumination correction via :func:`~ClearMap.ImageProcessing.IlluminationCorrection.correctIllumination`
        * background removal via :func:`~ClearMap.ImageProcessing.BackgroundRemoval.removeBackground`
        * difference of Gaussians (DoG) filter via :func:`~ClearMap.ImageProcessing.Filter.filterDoG`
        * maxima detection via :func:`~ClearMap.ImageProcessing.MaximaDetection.findExtendedMaxima`
        * cell shape detection via :func:`~ClearMap.ImageProcessing.CellSizeDetection.detectCellShape`
        * cell intensity and size measurements via: :func:`~ClearMap.ImageProcessing.CellSizeDetection.findCellIntensity`,
          :func:`~ClearMap.ImageProcessing.CellSizeDetection.findCellSize`. 
    
    Note: 
        Processing steps are done in place to save memory.
        
    Arguments:
        img (array): image data
        detectSpotParameter: image processing parameter as described in the individual sub-routines
        verbose (bool): print progress information
        out (object): object to print progress information to
        
    Returns:
        tuple: tuple of arrays (cell coordinates, raw intensity, fully filtered intensty, illumination and background corrected intensity [, cell size])
    """

    timer = Timer();
    
    # normalize data -> to check
    #img = img.astype('float');
    #dmax = 0.075 * 65535;
    #ids = img > dmax;
    #img[ids] = dmax;
    #img /= dmax; 
    #out.write(timer.elapsedTime(head = 'Normalization'));
    #img = dataset[600:1000,1600:1800,800:830];
    #img = dataset[600:1000,:,800:830];
    
    # correct illumination
    correctIlluminationParameter = getParameter(detectSpotsParameter, "correctIlluminationParameter", correctIlluminationParameter);
    img1 = img.copy();
    img1 = correctIllumination(img1, correctIlluminationParameter = correctIlluminationParameter, verbose = verbose, out = out, **parameter)   

    # background subtraction in each slice
    #img2 = img.copy();
    removeBackgroundParameter = getParameter(detectSpotsParameter, "removeBackgroundParameter", removeBackgroundParameter);
    img2 = removeBackground(img1, removeBackgroundParameter = removeBackgroundParameter, verbose = verbose, out = out, **parameter)   
    
    # mask
    #timer.reset();
    #if mask == None: #explicit mask
    #    mask = img > 0.01;
    #    mask = binary_opening(mask, self.structureELement('Disk', (3,3,3)));
    #img[img < 0.01] = 0; # masking in place  # extended maxima
    #out.write(timer.elapsedTime(head = 'Mask'));    
    
    #DoG filter
    filterDoGParameter = getParameter(detectSpotsParameter, "filterDoGParameter", filterDoGParameter);
    dogSize = getParameter(filterDoGParameter, "size", None);
    #img3 = img2.copy();    
    img3 = filterDoG(img2, filterDoGParameter = filterDoGParameter, verbose = verbose, out = out, **parameter);
    
    # normalize    
    #    imax = img.max();
    #    if imax == 0:
    #        imax = 1;
    #    img /= imax;
    
    # extended maxima
    findExtendedMaximaParameter = getParameter(detectSpotsParameter, "findExtendedMaximaParameter", findExtendedMaximaParameter);
    hMax = getParameter(findExtendedMaximaParameter, "hMax", None);
    imgmax = findExtendedMaxima(img3, findExtendedMaximaParameter = findExtendedMaximaParameter, verbose = verbose, out = out, **parameter);
    
    #center of maxima
    if not hMax is None:
        centers = findCenterOfMaxima(img, imgmax, verbose = verbose, out = out, **parameter);
    else:
        centers = findPixelCoordinates(imgmax, verbose = verbose, out = out, **parameter);
    
    #cell size detection
    detectCellShapeParameter = getParameter(detectSpotsParameter, "detectCellShapeParameter", detectCellShapeParameter);
    cellShapeThreshold = getParameter(detectCellShapeParameter, "threshold", None);
    if not cellShapeThreshold is None:
        
        # cell shape via watershed
        imgshape = detectCellShape(img2, centers, detectCellShapeParameter = detectCellShapeParameter, verbose = verbose, out = out, **parameter);
        
        #size of cells        
        csize = findCellSize(imgshape, maxLabel = centers.shape[0], out = out, **parameter);
        
        #intensity of cells
        cintensity = findCellIntensity(img, imgshape,  maxLabel = centers.shape[0], verbose = verbose, out = out, **parameter);

        #intensity of cells in background image
        cintensity2 = findCellIntensity(img2, imgshape,  maxLabel = centers.shape[0], verbose = verbose, out = out, **parameter);
    
        #intensity of cells in dog filtered image
        if dogSize is None:
            cintensity3 = cintensity2;
        else:
            cintensity3 = findCellIntensity(img3, imgshape,  maxLabel = centers.shape[0], verbose = verbose, out = out, **parameter);
        
        if verbose:
            out.write(timer.elapsedTime(head = 'Spot Detection') + '\n');
        
        #remove cell;s of size 0
        idz = csize > 0;
                       
        return ( centers[idz], numpy.vstack((cintensity[idz], cintensity3[idz], cintensity2[idz], csize[idz])).transpose());        
        
    
    else:
        #intensity of cells
        cintensity = findIntensity(img, centers, verbose = verbose, out = out, **parameter);

        #intensity of cells in background image
        cintensity2 = findIntensity(img2, centers, verbose = verbose, out = out, **parameter);
    
        #intensity of cells in dog filtered image
        if dogSize is None:
            cintensity3 = cintensity2;
        else:
            cintensity3 = findIntensity(img3, centers, verbose = verbose, out = out, **parameter);

        if verbose:
            out.write(timer.elapsedTime(head = 'Spot Detection') + '\n');
    
        return ( centers, numpy.vstack((cintensity, cintensity3, cintensity2)).transpose());
コード例 #7
0
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 matplotlib.pyplot as mpl 
コード例 #8
0
ファイル: fredClearMap.py プロジェクト: fshen11/fredClearMap
# converting data to smaller integer types can be more memory efficient!

imgB = bgr.removeBackground(img, size=(8, 8), verbose=True)
io.writeData(os.path.join(homeDir, 'Results/BackgroundRemoval.tif'), imgB)

#image filter
imgD = filterDoG(imgB, size=(15, 15, 1), verbose=True)
io.writeData(os.path.join(homeDir, 'Results/FilterDoG.tif'), imgD)

#Detect Maxima
imgMaxima = findExtendedMaxima(imgD, hMax=None, verbose=True, threshold=3)
points = findCenterOfMaxima(img, imgMaxima)
points = points.astype('int16')

#threshold intensities
dataShape = detectCellShape(imgD, points, threshold=5)
cellSizesPre = findCellSize(dataShape, maxlabel=points.shape[0])
io.writeData(os.path.join(homeDir, 'Results/CellShapes.tif'),
             20 * dataShape.astype('int32'))

#cintensity = findIntensity(imgD, points);

#points, intensities = thresholdPoints(points,cintensity, threshold = (5,20), row = (1,1));
points, cellSizesPost = thresholdPoints(points,
                                        cellSizesPre,
                                        threshold=(5, 100),
                                        row=(3, 3))

#pdb.set_trace()
#io.writeData(os.path.join(homeDir, 'Results/OverlayWatershed.tif'), overlay_Img);