Skip to content

Commit

Permalink
add filter
Browse files Browse the repository at this point in the history
  • Loading branch information
melonora committed Mar 26, 2024
1 parent fd50273 commit a818847
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
12 changes: 9 additions & 3 deletions src/cell_gater/model/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DataModel:
_lower_bound_marker: str | None = field(default=None, init=False)
_upper_bound_marker: str | None = field(default=None, init=False)
_markers: Sequence[str] = field(default_factory=list, init=False)
_marker_filter: str = field(default="dna,dapi", init=True)

_active_marker: str | None = field(default=None, init=False)
_active_sample: str | None = field(default=None, init=False)
Expand Down Expand Up @@ -109,6 +110,11 @@ def active_marker(self):
def active_marker(self, marker: str) -> None:
self._active_marker = marker

def validate(self):
"""Validate the input data from the user provided through the SampleWidget."""
pass
@property
def marker_filter(self):
"""The string filters separated by commas."""
return self._marker_filter

@marker_filter.setter
def marker_filter(self, marker_filter: str) -> None:
self._marker_filter = marker_filter
13 changes: 10 additions & 3 deletions src/cell_gater/widgets/sample_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,19 @@ def __init__(self, viewer: Viewer, model: DataModel | None = None) -> None:
self.layout().addWidget(upper_col, 2, 1)
self.layout().addWidget(self.upper_bound_marker_col, 3, 1)

# Filter field for user to pass on strings to filter markers out.
filter_label = QLabel("Marker column filters")
self.filter_field = QLineEdit("", placeholderText="Filter(s) separated by commas.")
self.filter_field = QLineEdit(
"",
placeholderText="Filter(s) separated by commas.",
)
self.filter_field.editingFinished.connect(self._update_filter)
self.layout().addWidget(filter_label, 4, 0)
self.layout().addWidget(self.filter_field, 5, 0)

# Button to start validating all the input
self.validate_button = QPushButton("Validate input")
self.validate_button.clicked.connect(self.model.validate)
self.validate_button.clicked.connect(self._validate)
self.layout().addWidget(self.validate_button, 6, 0)

self.model.events.regionprops_df.connect(self._set_dropdown_marker_lowerbound)
Expand Down Expand Up @@ -173,5 +178,7 @@ def _update_model_upperbound(self):
self.model.upper_bound_marker = upper_bound_marker

def _update_filter(self):
# TODO implement filter, add filter list to datamodel.
self.model.marker_filter = self.filter_field.text()

def _validate(self):
pass

0 comments on commit a818847

Please sign in to comment.