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

Velox EMD Complex dtype issue #3040

Merged
merged 2 commits into from Oct 9, 2022

Conversation

bryandesser
Copy link
Contributor

Applied fix to Velox EMD fft_dtype to allow for FFT selection with odd numbers of pixels. Small 128x128 HAADF examples are provided, one with an FFT selection with odd number of pixels, one with an even number of pixels. The even selection works, the odd cannot be imported with hyperspy.

Description of the change

There remains a small bug in reading Velox EMD files with FFTs. In _read_image(): fft_dtype = [('realFloatHalfEven', '<f4'), ('imagFloatHalfEven', '<f4')]; however, this is not always the case. If, for example, an FFT is taken of a region with odd number of pixels, then Velox saves the data as fft_dtype = [('realFloatHalfOdd', '<f4'), ('imagFloatHalfOdd', '<f4')]

This issue causes hs.load() to fail in the presence of an FFT with odd number of pixels.

In emd.py:

  • Expand fft_dtype to accomodate odd pixel dimensions (line 1101):
    fft_dtype = [[('realFloatHalfEven', '<f4'),('imagFloatHalfEven', '<f4')],[('realFloatHalfOdd', '<f4'), ('imagFloatHalfOdd', '<f4')]]
  • Change dtype check statement accordingly (line 1105):
    if h5data.dtype in fft_dtype or h5data.dtype == dpc_dtype:

Progress of the PR

  • Change implemented (can be split into several points),
  • update docstring (if appropriate),
  • update user guide (if appropriate),
  • add an changelog entry in the upcoming_changes folder (see upcoming_changes/README.rst),
  • Check formatting changelog entry in the readthedocs doc build of this PR (link in github checks)
  • add tests,
  • ready for review.

hyperspyComplexOddEven.zip

Minimal example of the bug fix or the new feature

import hyperspy.api as hs

dataEven = hs.load("hyperspyComplexEven.emd")
dataEven
[<ComplexSignal2D, title: Half FFT, dimensions: (|36, 70)>,
 <Signal2D, title: HAADF, dimensions: (|128, 128)>]

dataOdd = hs.load("hyperspyComplexOdd.emd")
# ERROR:hyperspy.io:If this file format is supported, please report this error to the HyperSpy developers.

@codecov
Copy link

codecov bot commented Oct 3, 2022

Codecov Report

Base: 81.42% // Head: 81.42% // No change to project coverage 👍

Coverage data is based on head (7376a42) compared to base (19f62eb).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@                 Coverage Diff                  @@
##           RELEASE_next_patch    #3040    +/-   ##
====================================================
  Coverage               81.42%   81.42%            
====================================================
  Files                     200      200            
  Lines                   27042    27042            
  Branches                 5996     5811   -185     
====================================================
  Hits                    22018    22018            
  Misses                   3574     3574            
  Partials                 1450     1450            
Impacted Files Coverage Δ
hyperspy/io_plugins/emd.py 66.84% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

bryandesser and others added 2 commits October 9, 2022 18:58
Applied fix to Velox EMD `fft_dtype` to allow for FFT selection with odd numbers of pixels as described in PR3028 (hyperspy#3028)
@ericpre ericpre changed the base branch from RELEASE_next_minor to RELEASE_next_patch October 9, 2022 18:10
Copy link
Member

@ericpre ericpre left a comment

Choose a reason for hiding this comment

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

Thank you @bryandesser, this looks good.

For information, I have rebased on RELEASE_next_patch and added a changelog entry and pushed these changes to your branch.

@ericpre ericpre merged commit e17d8ff into hyperspy:RELEASE_next_patch Oct 9, 2022
@ericpre ericpre added this to the v1.7.3 milestone Oct 29, 2022
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.

None yet

2 participants