Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
new_setting_values.append(cps.NO)
else:
new_setting_values.append(cps.YES)
setting_values = new_setting_values
from_matlab = False
variable_revision_number = 1
if from_matlab:
NotImplementedError("Don't know how to convert Matlab IdentifySecondary revision # %d"%(variable_revision_number))
if variable_revision_number != self.variable_revision_number:
NotImplementedError("Don't know how to handle IdentifySecondary revision # %d"%(variable_revision_number))
if (not from_matlab) and variable_revision_number == 1:
# Removed test mode
# added Otsu parameters.
setting_values = setting_values[:11]+setting_values[12:]
setting_values += [cpmi.O_TWO_CLASS, cpmi.O_WEIGHTED_VARIANCE,
cpmi.O_FOREGROUND]
variable_revision_number = 2
if (not from_matlab) and variable_revision_number == 2:
# Added discarding touching
setting_values = setting_values + [cps.NO, cps.NO, "FilteredNuclei"]
variable_revision_number = 3
if (not from_matlab) and variable_revision_number == 3:
# Added new primary outlines
setting_values = setting_values + [cps.NO, "FilteredNucleiOutlines"]
variable_revision_number = 4
return setting_values, variable_revision_number, from_matlab
new_setting_values[UNCLUMP_METHOD_VAR] = UN_NONE
if new_setting_values[WATERSHED_VAR] == cps.DO_NOT_USE:
new_setting_values[WATERSHED_VAR] = WA_NONE
variable_revision_number = 1
from_matlab = False
if (not from_matlab) and variable_revision_number == 1:
# Added LOG method
setting_values = list(setting_values)
setting_values += [ cps.YES, ".5" ]
variable_revision_number = 2
if (not from_matlab) and variable_revision_number == 2:
# Added Otsu options
setting_values = list(setting_values)
setting_values += [cpmi.O_TWO_CLASS, cpmi.O_WEIGHTED_VARIANCE,
cpmi.O_FOREGROUND]
variable_revision_number = 3
if (not from_matlab) and variable_revision_number == 3:
# Added more LOG options
setting_values = setting_values + [cps.YES, "5"]
variable_revision_number = 4
if (not from_matlab) and variable_revision_number == 4:
# Added # of object limits
setting_values = setting_values + [LIMIT_NONE, "500"]
variable_revision_number = 5
if (not from_matlab) and variable_revision_number == 5:
# Changed object number limit option from "No action" to "Continue"
if setting_values[-2] == "No action":
setting_values[-2] = LIMIT_NONE
def calculate_threshold(self, image_group, workspace):
'''Calculate a threshold for this image'''
image_name = image_group.image_name.value
image = workspace.image_set.get_image(image_name,
must_be_grayscale = True)
threshold_method = image_group.threshold_algorithm
object_fraction = image_group.object_fraction.value
two_class_otsu = (image_group.two_class_otsu == O_TWO_CLASS)
use_weighted_variance = (image_group.use_weighted_variance == O_WEIGHTED_VARIANCE)
assign_middle_to_foreground = (image_group.assign_middle_to_foreground == O_FOREGROUND)
(local_threshold, global_threshold) = \
(cpthresh.get_threshold(threshold_method,
cpthresh.TM_GLOBAL,
image.pixel_data,
mask = image.mask,
object_fraction = object_fraction,
two_class_otsu = two_class_otsu,
use_weighted_variance = use_weighted_variance,
assign_middle_to_foreground = assign_middle_to_foreground)
if image.has_mask
else
cpthresh.get_threshold(threshold_method,
cpthresh.TM_GLOBAL,
image.pixel_data,
object_fraction = object_fraction,
two_class_otsu = two_class_otsu,