Skip to content
Snippets Groups Projects
Commit 312bc8e7 authored by Kai Schleicher's avatar Kai Schleicher
Browse files

Add optional calibration parameter

parent 58644cd3
No related branches found
No related tags found
No related merge requests found
...@@ -227,7 +227,7 @@ def get_threshold_from_method(imp, method): ...@@ -227,7 +227,7 @@ def get_threshold_from_method(imp, method):
return threshold_value return threshold_value
def convert_to_binary(imp, threshold=1, scale_binary=True): def convert_to_binary(imp, threshold=1, scale_binary=True, cal=None):
"""Convert grayscale image to a mask / binary image """Convert grayscale image to a mask / binary image
Parameters Parameters
...@@ -238,6 +238,8 @@ def convert_to_binary(imp, threshold=1, scale_binary=True): ...@@ -238,6 +238,8 @@ def convert_to_binary(imp, threshold=1, scale_binary=True):
the threshold above which pixels are considered foreground, by default 1 the threshold above which pixels are considered foreground, by default 1
scale_binary : bool, optional scale_binary : bool, optional
scale the mask image from 0/255 to 0/1, by default True scale the mask image from 0/255 to 0/1, by default True
cal : ImagePlus Calibration, optional
apply the calibration if given, by default None
Returns Returns
------- -------
...@@ -257,6 +259,9 @@ def convert_to_binary(imp, threshold=1, scale_binary=True): ...@@ -257,6 +259,9 @@ def convert_to_binary(imp, threshold=1, scale_binary=True):
IJ.run(mask_imp, "Divide...", "value=255") IJ.run(mask_imp, "Divide...", "value=255")
IJ.run(mask_imp, "Enhance Contrast", "saturated=0.35") IJ.run(mask_imp, "Enhance Contrast", "saturated=0.35")
mask_imp.changes = False mask_imp.changes = False
if cal != None:
mask_imp.setCalibration(cal)
return mask_imp return mask_imp
...@@ -502,7 +507,7 @@ quality_thresholds = quality_thresholds_string.split(",") ...@@ -502,7 +507,7 @@ quality_thresholds = quality_thresholds_string.split(",")
dapi_channel = BFopen_image(path_to_image, dapi_channel_number, series_number) dapi_channel = BFopen_image(path_to_image, dapi_channel_number, series_number)
if threshold <= 0: if threshold <= 0:
threshold = get_threshold_from_method(dapi_channel, "otsu") threshold = get_threshold_from_method(dapi_channel, "otsu")
dapi_binary = convert_to_binary(dapi_channel, threshold) dapi_binary = convert_to_binary(dapi_channel, threshold, cal=dapi_channel.getCalibration())
# detect spots and count them per fiber # detect spots and count them per fiber
results_table = ResultsTable() results_table = ResultsTable()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment