Mask out invalid pixels in the polar view#755
Merged
Conversation
This makes it so that any invalid pixels (as defined by the detector's
panel buffer) do not have an effect on the resulting polar image and
lineout. Any polar view pixels that were interpolated with an invalid
pixel will be nan.
The intended usage is as follows:
```python
img = pv.warp_image(image_dict, pad_with_nans=True,
do_interpolation=True)
cake = np.mean(img, axis=0)
```
The `img` that is returned from the warp image is a masked array,
with all invalid pixels being masked out. If `np.mean(img, axis=0)` is
applied to this, it ignores all masked out pixels when computing the
mean along the axis (which is the behavior we want). This is preferred
over doing something like `np.sum(img.filled(0), axis=0)`, since columns
with invalid pixels will be reduced in value.
Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #755 +/- ##
==========================================
+ Coverage 39.79% 39.82% +0.02%
==========================================
Files 141 142 +1
Lines 22744 22763 +19
==========================================
+ Hits 9052 9065 +13
- Misses 13692 13698 +6 ☔ View full report in Codecov by Sentry. |
bnmajor
approved these changes
Feb 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes it so that any invalid pixels (as defined by the detector's panel buffer) do not have an effect on the resulting polar image and lineout. Any polar view pixels that were interpolated with an invalid pixel will be nan.
The intended usage is as follows:
The
imgthat is returned from the warp image is a masked array, with all invalid pixels being masked out. Ifnp.mean(img, axis=0)is applied to this, it ignores all masked out pixels when computing the mean along the axis (which is the behavior we want). This is preferred over doing something likenp.sum(img.filled(0), axis=0), since columns with invalid pixels will be reduced in value.A previous caking that didn't mask out the invalid pixels for Eiger data looked like this:
Note that invalid Eiger pixels have a very high value, and this resulted in very high values in intensity for
any column that were interpolated using invalid pixels.
The new caking looks correct: