-
Notifications
You must be signed in to change notification settings - Fork 2
Fixes #236 / #118 possibility to add filters on selected volumes folder #252
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
base: main
Are you sure you want to change the base?
Conversation
…://github.com/neuropoly/slicercart into kyw/issue213-remove-edit-configuration-button
…exclusion and inclusion filters
|
@maxradx @SomeoneInParticular I only tested it on configuration_config.yaml |
|
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. |
|
Got it @SomeoneInParticular There is now a known bug: upon selecting the output folder, filters' effect seem to be nulled. Like mentioned, will tackle |
There was a problem hiding this 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 = [] |
There was a problem hiding this comment.
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", [])| if inclusion == []: | ||
| inclusion = None | ||
| if exclusion == []: | ||
| exclusion = None |
There was a problem hiding this comment.
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.
| inclusion = [item.lower() for item in (inclusion or [])] | ||
| exclusion = [item.lower() for item in (exclusion or [])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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] |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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...
| slice_view_color: Yellow | ||
| slice_view_color: Red |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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?
| # Check for duplicates within each category | ||
| def find_duplicates(lst): | ||
| return set(x for x in lst if lst.count(x) > 1) |
There was a problem hiding this comment.
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?
| # 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
|
A few other concerns as well:
|
|
for myself
|
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
inclusionandexclusion. 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:
Currently, limited testing has been done, this PR is for reviews and a showcase of the UI
Action steps:
Continue from existing segmentation(filtering should not be an option)New Configurationtype