-
Notifications
You must be signed in to change notification settings - Fork 14
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
Threshold masking #1544
Threshold masking #1544
Conversation
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.
Looking great so far! A few things to fix:
- Toggling visibility in the mask manager dialog for the threshold mask doesn't appear to do anything
- If you remove the threshold mask from the mask manager and click "Apply" in the threshold dialog, the threshold mask doesn't come back (it looks like you have to exit the program to be able to make a new threshold mask)
- I think we should consider eliminating the combo boxes and just having it display two spinboxes that are a range of values that will not be thresholded. This could default to
-inf to inf
, and if you wanted to, for instance, threshold all values below 0 and above 50, it would be0 to 50
. But let's see if this is okay with Saransh first. I think the text is a little confusing anyways - does "Less than" mean that all values less than that value will be thresholded (masked out) or kept? Looks like it means those values should be masked out. But if I try to keep only pixels between a certain range such as 0 and 50, it doesn't look like I can do that for some reason.
This seems to work for me, but please let me know if I am misunderstanding what you mean:
Sounds good! So something like this maybe?
Yes, after asking Saransh we should be |
52a366e
to
c19ebf0
Compare
I'll try it again tonight! (tomorrow for me)
Yes that looks good!
So, the range we are defining is the range of pixel values that will not be masked out, not the range of pixel values that will be masked out. I confirmed this with Saransh (and he thinks the range is better too). So that means if it defaults to |
Ah, okay. This is the opposite of what I thought he was asking for. In that case this makes sense. Thanks! |
This should be fixed now! |
@psavery @saransh13 I think this is all fixed up now and ready for a final review |
One more issue I see: If I set the range to be Traceback (most recent call last):
File "/Users/patrick/virtualenvs/hexrd/src/hexrdgui/hexrd/ui/threshold_mask_dialog.py", line 68, in accept
apply_threshold_mask()
File "/Users/patrick/virtualenvs/hexrd/src/hexrdgui/hexrd/ui/create_raw_mask.py", line 21, in apply_threshold_mask
mask = create_threshold_mask(img)
File "/Users/patrick/virtualenvs/hexrd/src/hexrdgui/hexrd/ui/create_raw_mask.py", line 29, in create_threshold_mask
lt_val, gt_val = HexrdConfig().threshold_values
ValueError: not enough values to unpack (expected 2, got 1) We should also make sure setting one of the values in the range to We also need to modify the cartesian and polar generation to take this masking into account, but I will look into that in a separate PR! |
@saransh13 I tested the example that you shared with me but it seems to work for me. Can you make sure your branch is up-to-date and try again? @psavery Thanks for that! We're now saving the range regardless of value which fixes that bug. |
56574ef
to
1ee1fc3
Compare
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.
Let's just do the name change ("Range" -> "Unmasked Range") and then this PR looks good to me!
<item row="0" column="0"> | ||
<widget class="QLabel" name="comparison_label"> | ||
<property name="text"> | ||
<string>Range</string> |
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.
<string>Range</string> | |
<string>Unmasked Range</string> |
Can we change the text to "Unmasked Range" for clarity?
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.
Changed
@@ -250,6 +239,8 @@ def write_all_masks(self, h5py_group=None): | |||
for i, (det, mask) in enumerate(data): | |||
parent = d.setdefault(det, {}) | |||
parent.setdefault(name, {})[str(i)] = mask | |||
if self.threshold: | |||
d['threshold'] = HexrdConfig()._threshold_data |
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 tried writing out just the masks (via "Export Masks"), and sometimes, this 'threshold' group in the HDF5 file is just an empty group. This produces an error when we load in the masks.
Maybe there are some situations where HexrdConfig()._threshold_data
is invalid?
But I can't actually reproduce this issue now. Let's keep an eye out for it.
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.
Okay, sounds good.
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.
LGTM
Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
The visibility of the threshold mask was not being saved. Makes sure that it is. Signed-off-by: Brianna Major <[email protected]>
Users are now provided two spin boxes that default to (-inf, inf). The range input will represent the range of values that will *not* be masked. Signed-off-by: Brianna Major <[email protected]>
Move threshold_mask_changed signal from threshold mask dialog to the apply_threshold_mask function. Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
eb4173b
to
1ba89e1
Compare
Fixes #1528