Skip to content
Snippets Groups Projects
Commit 948a18cc authored by Laurent Guerard's avatar Laurent Guerard
Browse files

Add background correction method

parent 5f704ad5
Branches
Tags
No related merge requests found
...@@ -107,20 +107,31 @@ def fix_BF_czi_imagetitle(imp): ...@@ -107,20 +107,31 @@ def fix_BF_czi_imagetitle(imp):
return image_title return image_title
def preprocess_membrane_channel(imp): def do_background_correction(imp, gaussian_radius=20):
"""apply myosoft pre-processing steps for the membrane channel """Perform background correction on an image.
This is done by applying a Gaussian blur to the image and then dividing the
original image by the blurred image.
Parameters Parameters
---------- ----------
imp : ImagePlus imp : ij.ImagePlus
a single channel image of the membrane staining The image to be corrected.
gaussian_radius : int
The radius of the Gaussian filter to be used. Default value is 20.
Returns
-------
ij.ImagePlus
The background-corrected image.
""" """
IJ.run(imp, "Enhance Contrast", "saturated=0.35") imp_bgd = imp.duplicate()
IJ.run(imp, "Apply LUT", "") IJ.run(
IJ.run(imp, "Enhance Contrast", "saturated=1") imp_bgd,
IJ.run(imp, "8-bit", "") "Gaussian Blur...",
IJ.run(imp, "Invert", "") "sigma=" + str(gaussian_radius) + " scaled",
IJ.run(imp, "Convolve...", "text1=[-1.0 -1.0 -1.0 -1.0 -1.0\n-1.0 -1.0 -1.0 -1.0 0\n-1.0 -1.0 24.0 -1.0 -1.0\n-1.0 -1.0 -1.0 -1.0 -1.0\n-1.0 -1.0 -1.0 -1.0 0] normalize") )
return ImageCalculator.run(imp, imp_bgd, "Divide create 32-bit")
def get_threshold_from_method(imp, channel, method): def get_threshold_from_method(imp, channel, method):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment