Exemplo n.º 1
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())
Exemplo n.º 2
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))
Exemplo n.º 3
0
    #Atlas and Annotation
    transformParameterFN = os.path.join(alignDir, 'TransformParameters.1.txt')

    print(cfos_fn)
    img = io.readData(cfos_fn)
    img = img[..., numpy.newaxis]
    img = img.astype('int16')
    # converting data to smaller integer types can be more memory efficient!

    imgB = bgr.removeBackground(img, size=backgroundSize, verbose=True)
    io.writeData(os.path.join(resultDir, fName + '_BackgroundRemoval.tif'),
                 imgB)

    ##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)
Exemplo n.º 4
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`. 
    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())
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))
Exemplo n.º 6
0
from ClearMap.ImageProcessing.CellSizeDetection import findCellSize, findCellIntensity

cmap = matplotlib.colors.LinearSegmentedColormap.from_list(
    "", ["white", "red"])

inputs = "/home/wanglab/LightSheetData/rat-brody/processed/201910_tracing/clearmap/"
filename = os.path.join(inputs, "z265_zpln315-340_x4785_y3793_img.tif")

data = tifffile.imread(filename)

dataBGR = bgr.removeBackground(data.astype('float'),
                               size=(25, 25),
                               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,
Exemplo n.º 7
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());
dataBGR_write = plt.overlayPoints(dataBGR, fileRange)
mplt.pyplot.savefig(os.path.join(BaseDirectory, 'dataBGR_write.tif'))

io.writeData(os.path.join(BaseDirectory, 'background_8.tif'), dataBGR_write)
io.writeData(os.path.join(BaseDirectory, 'cells_check.tif'), data)

pointSource = os.path.join(BaseDirectory, FilteredCellsFile[0])
data_write = plt.overlayPoints(filename,
                               dataBGR_write,
                               fileRange,
                               pointColor=None)
io.writeData(os.path.join(BaseDirectory, 'cells_check.tif'), data)

#DoG Filter
from ClearMap.ImageProcessing.Filter.DoGFilter import filterDoG
dataDoG = filterDoG(dataBGR, size=(7, 7, 9), verbose=False)
plt.plotTiling(dataDoG, inverse=True, x=(600, 700), y=(600, 700), z=(1, 15))

#Find Extended Maxima
from ClearMap.ImageProcessing.MaximaDetection import findExtendedMaxima
dataMax = findExtendedMaxima(dataDoG, hMax=None, verbose=True, threshold=500)
plt.plotOverlayLabel(dataDoG / dataDoG.max(),
                     dataMax.astype('int'),
                     x=(1750, 1850),
                     y=(1050, 1150),
                     z=(1, 9))

#Find Peak Intensity
findIntensityParameter = {
    "method":
    'Max',  # (str, func, None)   method to use to determine intensity (e.g. "Max" or "Mean") if None take intensities at the given pixels
Exemplo n.º 9
0
                        orientation + 'Atlas')
annoDir = os.path.join('/media/sf_Fred_Data/testClearMap/',
                       orientation + 'Annotation')
transformParameterFN = os.path.join(alignResultDir,
                                    'TransformParameters.1.txt')

img = io.readData(input_fn)
img = img[..., numpy.newaxis]
img = img.astype('int16')
# 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);