Пример #1
0
def doGaussianFilter(imp, radius=30):
    """This function takes an input stack, and subtracts a gaussian filtered image
    from each individual frame. Thereby, everything that is not moving 
    in a timeseries is filtered away.

    Args:
        imp (ImagePlus): An input stack as ImagePlus object.
        projectionMethod (str, optional): Choose the projection method. Options are 
            'Average Intensity', 'Max Intensity', 'Min Intensity', 'Sum Slices', 'Standard Deviation', 'Median'. 
            Defaults to "Median".

    Returns:
        ImagePlus: The resulting stack.
    """
    #Start by getting the active image window and get the current active channel and other stats
    cal = imp.getCalibration()
    title = imp.getTitle()

    # Make gaussian filtered image.
    gaussian = IJ.run(imp, "Gaussian Blur...", "sigma=30 stack")

    # Subtract Z-Projection and return output ImagePlus.
    impout = ImageCalculator().run("Subtract create 32-bit stack", imp,
                                   gaussian)
    impout.setCalibration(cal)
    return impout
Пример #2
0
def subtractzproject(imp, projectionMethod="Median"):
    """This function takes an input stack, and subtracts a projection from the 
    whole stack from each individual frame. Thereby, everything that is not moving 
    in a timeseries is filtered away.

    Args:
        imp (ImagePlus): An input stack as ImagePlus object.
        projectionMethod (str, optional): Choose the projection method. Options are 
            'Average Intensity', 'Max Intensity', 'Min Intensity', 'Sum Slices', 'Standard Deviation', 'Median'. 
            Defaults to "Median".

    Returns:
        ImagePlus: The resulting stack.
    """
    #Start by getting the active image window and get the current active channel and other stats
    cal = imp.getCalibration()
    title = imp.getTitle()

    # Define a dictionary containg method_name:const_fieled_value pairs for the projection methods.
    methods_as_strings = [
        'Average Intensity', 'Max Intensity', 'Min Intensity', 'Sum Slices',
        'Standard Deviation', 'Median'
    ]
    methods_as_const = [
        ZProjector.AVG_METHOD, ZProjector.MAX_METHOD, ZProjector.MIN_METHOD,
        ZProjector.SUM_METHOD, ZProjector.SD_METHOD, ZProjector.MEDIAN_METHOD
    ]
    method_dict = dict(zip(methods_as_strings, methods_as_const))

    # Run Z-Projection.
    zp = ZProjector(imp)
    zp.setMethod(method_dict[projectionMethod])
    zp.doProjection()
    impMedian = zp.getProjection()

    # Subtract Z-Projection and return output ImagePlus.
    impout = ImageCalculator().run("Subtract create 32-bit stack", imp,
                                   impMedian)
    impout.setCalibration(cal)
    return impout