From 82991cb7c69c3cf7f0ed972f8bafdc55521e28ab Mon Sep 17 00:00:00 2001 From: Beth Cimini Date: Tue, 7 Jan 2025 19:45:11 +0000 Subject: [PATCH] Remove redundant settings, fixes (mostly by Erin) (#267) --- active_plugins/filterobjects_stringmatch.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/active_plugins/filterobjects_stringmatch.py b/active_plugins/filterobjects_stringmatch.py index c3eccbb..dad8648 100644 --- a/active_plugins/filterobjects_stringmatch.py +++ b/active_plugins/filterobjects_stringmatch.py @@ -16,7 +16,6 @@ import scipy.sparse import cellprofiler_core.object -from cellprofiler.utilities.rules import Rules LOGGER = logging.getLogger(__name__) @@ -25,16 +24,13 @@ METHOD_KEEP_EXACT = "Keep only strings matching" METHOD_KEEP_CONTAINS = "Keep only strings containing" +ADDITIONAL_STRING_SETTING_INDEX = 5 + class FilterObjects_StringMatch(ObjectProcessing): module_name = "FilterObjects_StringMatch" variable_revision_number = 2 - def __init__(self): - self.rules = Rules() - - super(FilterObjects_StringMatch, self).__init__() - def create_settings(self): super(FilterObjects_StringMatch, self).create_settings() @@ -88,8 +84,6 @@ def create_settings(self): Click this button to add an additional string to apply to the objects with the same rules.""", ) - self.rules.create_settings() - def add_additional_string(self): group = SettingsGroup() group.append( @@ -111,11 +105,18 @@ def add_additional_string(self): def settings(self): settings = super(FilterObjects_StringMatch, self).settings() - settings += [self.filter_out,self.filter_method, self.filter_column] + settings += [self.filter_out,self.filter_method, self.filter_column, self.additional_string_count] for x in self.additional_strings: - settings += [self.filter_out] + settings += [x.additional_string] return settings + def prepare_settings(self, setting_values): + additional_string_count = int(setting_values[ADDITIONAL_STRING_SETTING_INDEX]) + while len(self.additional_strings) > additional_string_count: + del self.additional_images[additional_string_count:] + while len(self.additional_strings) < additional_string_count: + self.add_additional_string() + def visible_settings(self): visible_settings = super(FilterObjects_StringMatch, self).visible_settings() visible_settings += [