Skip to content

Commit 82991cb

Browse files
authored
Remove redundant settings, fixes (mostly by Erin) (#267)
1 parent 677fb7a commit 82991cb

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

active_plugins/filterobjects_stringmatch.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import scipy.sparse
1717

1818
import cellprofiler_core.object
19-
from cellprofiler.utilities.rules import Rules
2019

2120
LOGGER = logging.getLogger(__name__)
2221

@@ -25,16 +24,13 @@
2524
METHOD_KEEP_EXACT = "Keep only strings matching"
2625
METHOD_KEEP_CONTAINS = "Keep only strings containing"
2726

27+
ADDITIONAL_STRING_SETTING_INDEX = 5
28+
2829
class FilterObjects_StringMatch(ObjectProcessing):
2930
module_name = "FilterObjects_StringMatch"
3031

3132
variable_revision_number = 2
3233

33-
def __init__(self):
34-
self.rules = Rules()
35-
36-
super(FilterObjects_StringMatch, self).__init__()
37-
3834
def create_settings(self):
3935
super(FilterObjects_StringMatch, self).create_settings()
4036

@@ -88,8 +84,6 @@ def create_settings(self):
8884
Click this button to add an additional string to apply to the objects with the same rules.""",
8985
)
9086

91-
self.rules.create_settings()
92-
9387
def add_additional_string(self):
9488
group = SettingsGroup()
9589
group.append(
@@ -111,11 +105,18 @@ def add_additional_string(self):
111105

112106
def settings(self):
113107
settings = super(FilterObjects_StringMatch, self).settings()
114-
settings += [self.filter_out,self.filter_method, self.filter_column]
108+
settings += [self.filter_out,self.filter_method, self.filter_column, self.additional_string_count]
115109
for x in self.additional_strings:
116-
settings += [self.filter_out]
110+
settings += [x.additional_string]
117111
return settings
118112

113+
def prepare_settings(self, setting_values):
114+
additional_string_count = int(setting_values[ADDITIONAL_STRING_SETTING_INDEX])
115+
while len(self.additional_strings) > additional_string_count:
116+
del self.additional_images[additional_string_count:]
117+
while len(self.additional_strings) < additional_string_count:
118+
self.add_additional_string()
119+
119120
def visible_settings(self):
120121
visible_settings = super(FilterObjects_StringMatch, self).visible_settings()
121122
visible_settings += [

0 commit comments

Comments
 (0)