Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FilterObjects_StringMatch #267

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions active_plugins/filterobjects_stringmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import scipy.sparse

import cellprofiler_core.object
from cellprofiler.utilities.rules import Rules

LOGGER = logging.getLogger(__name__)

Expand All @@ -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()

Expand Down Expand Up @@ -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(
Expand All @@ -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 += [
Expand Down
Loading