Skip to content

Conversation

@AcastaPaloma
Copy link
Collaborator

@AcastaPaloma AcastaPaloma commented Jun 22, 2025

Previous behavior
Upon selecting a volumes folder, it was impossible to filter/select specific cases (case paths) based off of characteristics in the file name.

Current behavior
A user can add filters of inclusion and exclusion. Loaded files from a selected volume are files that all have all inclusion filters within their file name and none of the exclusion filters within their file name. Casing does not matter (t1 == T1)

Some light UI changes included in this PR, could be applied to all windows:

  1. Adding fields to a window no longer requires a new window => Could reduce the amount of windows whenever something new is added (such as fields)
  2. Some spacing between configuration fields for readability

Currently, limited testing has been done, this PR is for reviews and a showcase of the UI
Action steps:

  • Adequate testing of existing functionalities
  • Testing on Continue from existing segmentation (filtering should not be an option)
  • Adding a button to modify filters, thus changing the active case list during a single segmentation session, if session is a New Configuration type

@AcastaPaloma
Copy link
Collaborator Author

@maxradx @SomeoneInParticular I only tested it on configuration_config.yaml
Just first wanted your opinions on the UI and the existing functions.

@SomeoneInParticular
Copy link
Collaborator

SomeoneInParticular commented Jun 22, 2025

Will do @AcastaPaloma; for future reference, if you want me (or anyone else) to review something, assign us as a reviewer as well. It gives us a notification that is much clearer than "someone somewhere mentioned you", and in some repositories is required for us to initiate a review of the code base/provide suggestions in the first place.

@SomeoneInParticular SomeoneInParticular self-requested a review June 23, 2025 04:13
@AcastaPaloma
Copy link
Collaborator Author

Got it @SomeoneInParticular

There is now a known bug: upon selecting the output folder, filters' effect seem to be nulled. Like mentioned, will tackle Continue from existing segmentation configuration

Copy link
Collaborator

@SomeoneInParticular SomeoneInParticular left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work! I have a few remarks that should be addressed before we merge, but overall this is an excellent addition.

if self.config_yaml["case_list_filters"]["exclusion"]:
filters_to_exclude = self.config_yaml["case_list_filters"]["exclusion"]
else:
filters_to_exclude = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are dict-like objects, which means we can use Python's get function w/ a default return to make them cleaner (and faster). I also replaced the empty list (which you end up replacing with None in the next function anyways) with None:

filters_to_include = self.config_yaml["case_list_filters"].get("inclusion", [])

filters_to_exclude = self.config_yaml["case_list_filters"].get("exclusion", [])

Comment on lines +781 to +784
if inclusion == []:
inclusion = None
if exclusion == []:
exclusion = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this; its entirely unnecessary given inclusion/exclusion are always a list (see prior remark), and thus the following list comprehension will always work with my suggested change.

Comment on lines +788 to +789
inclusion = [item.lower() for item in (inclusion or [])]
exclusion = [item.lower() for item in (exclusion or [])]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inclusion = [item.lower() for item in (inclusion or [])]
exclusion = [item.lower() for item in (exclusion or [])]
inclusion = [item.lower() for item in inclusion]
exclusion = [item.lower() for item in exclusion]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You pseudo-cast the list to None, then immediately replace it with an empty list again here. Seems odd, and may potentially mislead future developers.

default_volume_directory: ''
enable_debug: true
freetextboxes:
cheese: Cheese
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you; I was wondering what this was doing here...

Comment on lines -101 to +105
slice_view_color: Yellow
slice_view_color: Red
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for this change? Not that is particularly matters, but I'm curious...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that oftentimes, MRIs or CTs are taken on the axial; loading them on the sagittal/coronal would just result in a distorted image and could confuse first time users.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid; how does that relate to the color though? Or is this some poorly documented Slicer specific requirement?

# msg.buttonClicked.connect(self.push_error_label_list_empty)
msg.exec()
else:
ConfigPath.write_config_file()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed? For debugging, or was it causing an issue/conflict?

Comment on lines +2780 to +2782
# Check for duplicates within each category
def find_duplicates(lst):
return set(x for x in lst if lst.count(x) > 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we handle this at entry, rather than at application?

Comment on lines +2768 to +2771
# Check for empty filters
if "" in inclusion or "" in exclusion:
qt.QMessageBox.warning(self, "Warning", "All filters must be filled. Please remove or fill empty filters.")
return
Copy link
Collaborator

@SomeoneInParticular SomeoneInParticular Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just purge them in the first place then?

self.inclusion_table_view.setRowCount(num_inclusion_filters)

for incl_idx, incl_filter_value in enumerate(self.case_list_filters["inclusion"]):
# Create the remove filter button
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please go through the code and add comments like this for all buttons/UI elements. For some of the more common functions, you might even want to refactor them to standalone functions for modularity and reuse.

@SomeoneInParticular
Copy link
Collaborator

SomeoneInParticular commented Jun 24, 2025

A few other concerns as well:

  • The changes in this PR seem to have broken the initial rendering of the MRI sequences when an input folder is selected. Once and output folder is selected, it works fine, but something is wrong here and needs to be addressed...
  • Removing an inclusion/exclusion filter forces the entire window prompt to close and re-open; adding one doesn't, though. If possible, try to make the former act like the latter (so it doesn't "jump" every time an entry is removed).

@AcastaPaloma
Copy link
Collaborator Author

for myself

  • fix filters (list & dicts)
  • remove empty filters
  • listeners for duplicate filters
  • comments for UI
  • broken initial rendering of MRI

@AcastaPaloma AcastaPaloma marked this pull request as draft July 7, 2025 16:12
@AcastaPaloma AcastaPaloma changed the title Fixes #236 / #118 possibility to add filters on selected volums folder Fixes #236 / #118 possibility to add filters on selected volumes folder Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants