diff --git a/background_sub.py b/background_sub.py index 05ad8e6..58f6a7f 100644 --- a/background_sub.py +++ b/background_sub.py @@ -108,7 +108,6 @@ def process_metadata(metadata, markers): def isNaN(x): return x != x - def subtract_channel(image, markers, channel, background_marker, output): scalar = markers[markers.ind == channel].exposure.values / background_marker.exposure.values @@ -117,14 +116,14 @@ def subtract_channel(image, markers, channel, background_marker, output): back = copy.copy(image[background_marker.ind])[0] # subtract background from processed channel and if the background intensity for a certain pixel was larger than # the processed channel, set intensity to 0 (no negative values) - back = np.rint(ne.evaluate("back * scalar")).astype(np.uint16) + back = np.rint(ne.evaluate("back * scalar")) + back = np.where(back>65535,65535,back.astype(np.uint16)) # set the pixel value to 0 if the image channel value is lower than the scaled background channel value # otherwise, subtract. output[channel] = np.where(image[channel]