Skip to content
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

Display QPI image data #146

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

PinkShnack
Copy link
Member

As described in (create issue) I want to see qpi data non-scalar features in shapeout2.

@PinkShnack
Copy link
Member Author

Progress so-far:

I just need to generalise the methods and then this should be ready for review. (I'm sure I'll need some tests also)

view_normal
view_poly
view_zoom

Copy link
Member Author

@PinkShnack PinkShnack left a comment

Choose a reason for hiding this comment

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

@paulmueller when you get a chance, pleae have a look at the changes :)

I tested that it works on normal rtdc files, and on rtdc files with qpi data.

Perhaps I need to add some tests?

shapeout2/gui/quick_view/qv_main.py Show resolved Hide resolved
shapeout2/gui/quick_view/qv_main.py Outdated Show resolved Hide resolved
shapeout2/gui/quick_view/qv_main.py Outdated Show resolved Hide resolved
shapeout2/gui/quick_view/qv_main.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 31, 2023

Codecov Report

Attention: 30 lines in your changes are missing coverage. Please review.

Comparison is base (d0ec73d) 78.93% compared to head (0d94818) 78.71%.
Report is 23 commits behind head on master.

❗ Current head 0d94818 differs from pull request most recent head 44bd6c1. Consider uploading reports for the commit 44bd6c1 to get more accurate results

Files Patch % Lines
shapeout2/gui/quick_view/qv_main.py 48.27% 30 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #146      +/-   ##
==========================================
- Coverage   78.93%   78.71%   -0.22%     
==========================================
  Files          63       63              
  Lines        6768     6807      +39     
==========================================
+ Hits         5342     5358      +16     
- Misses       1426     1449      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@paulmueller paulmueller left a comment

Choose a reason for hiding this comment

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

The main issue that I see is that the current way contours are plotted is outdated and also does not work with phase data (changing pixels in an RGB image). So as far as I can see, there is no way around rewriting displaying the contour for phase and amplitude data.

Also, I believe there should be some way of setting the range for (at least) phase values. And phase values should always be centered at zero with the corresponding colormap showing white or no color. "coolwarm" from matplotlib is a good way of displaying phase, but you would have to copy-paste it to work with pyqtgraph, because I think it is not (yet) in pyqtgraph. "viridis" got ported to pyqtgraph, so it should be straight-forward.

shapeout2/gui/quick_view/qv_main.py Show resolved Hide resolved
return cellimg, imkw

@staticmethod
def display_contour(ds, event, state, cellimg):
Copy link
Member

@paulmueller paulmueller Oct 31, 2023

Choose a reason for hiding this comment

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

In the future, we might want to change how we compute/display the contour, i.e. we are planning to use non-discrete contours (@SaraKaliman). So it might make sense to implement two functions add_contour_to_image (for "image" data) and draw_contour_on_plot (for float32 qpi data) which could then also be used later for non-discrete contours.

Copy link
Member Author

Choose a reason for hiding this comment

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

Practically I want to use shapeout to visualise the image data so Kyoo can look at the data in one place. For that, what I have built right now is enough. The colormaps and contour issues will just hold that up. Could we put all that in a separate PR?

Copy link
Member

@paulmueller paulmueller Nov 3, 2023

Choose a reason for hiding this comment

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

If it is just for Kyoo, then you could just create a custom executable for him:

cd build_recipes
pip install -r win_build_requirements.txt
pyinstaller -y --log-level=WARN win_ShapeOut2.spec

Copy link
Member

Choose a reason for hiding this comment

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

I would not like to merge an incomplete feature. Moreover, the grayscale colormap leads to ambiguities. This should not be used by the general crowd.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you think it isn't a complete feature then I understand. I'll try to implement the colorbar etc soon.

Thanks for the custom executable, much better... I was just gonna do the dev version. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Phase is back!

Phase values are inverted here (as they are saved inverted in the example file).

image

I will impement the contour utility methods that you mentioned above now. Contour looks a bit crazy right now!

With contours:
image

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, I believe there should be some way of setting the range for (at least) phase values.

Do you envisage something like like:
phase_range

Or on a per-image basis? For per image, we can use the built-in histogram. However, I don't like this.

shapeout2/gui/quick_view/qv_main.py Outdated Show resolved Hide resolved
shapeout2/gui/quick_view/qv_main.py Outdated Show resolved Hide resolved
shapeout2/gui/quick_view/qv_main.ui Outdated Show resolved Hide resolved
@PinkShnack
Copy link
Member Author

PinkShnack commented Nov 17, 2023

A really fun side-effect of having floating-point values in the image display is that we get a pinkish contour for the phase. :) I guess we have to fix this :')

image

EDIT:

I (unfortunately) fixed the colour issue. I also confirmed that the colours are, in fact, the same!
image

@paulmueller paulmueller marked this pull request as draft March 20, 2024 14:00
cellimg[cont, 1] = int(imkw["levels"][0])
cellimg[cont, 2] = int(imkw["levels"][0])
else:
# just 2D images (not RGB)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a work in progress (probably going to follow your idea of having specific methods for contour handling).


try:
# if we have qpi data, image might be a different shape
if "qpi_pha" in ds:
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe there should be a separate class entirely that handles image plotting? Generalization is not easy due to the different data types and requirements for visualization.

I think a simple method works for our use-case for image display. Could even make this into a method, seeing as we use it twice.

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