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

axes fix for loading JPG with no exif_tags #283

Merged
merged 7 commits into from
Jul 3, 2024
Merged

Conversation

ThorstenBASF
Copy link
Contributor

@ThorstenBASF ThorstenBASF commented Jun 24, 2024

Description of the change

A few sentences and/or a bulleted list to describe and motivate the change:

  • JPG files with no exif_tags had no axes or dimensions when loaded.
  • instead of returning empty axes, axes are returned with an scale of 1 pixel/pixel.
  • with fix this images can be handled with hs/axes commands as usual. (s.calibrate e.g.)

Progress of the PR

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

  • add testfile

Minimal example of the bug fix or the new feature

import hyperspy.api as hs
tfile = "./rsciio/tests/data/image/jpg_no_exif_tags.jpg"
s = hs.load(tfile)
s.calibrate(x0=0, y0=0, x1=0, y1=1, new_length=0.2, units="nm", interactive=False)

Copy link

codecov bot commented Jun 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.52%. Comparing base (de98a8e) to head (2b38d85).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #283      +/-   ##
==========================================
+ Coverage   86.33%   86.52%   +0.18%     
==========================================
  Files          83       83              
  Lines       10674    10676       +2     
  Branches     2332     2332              
==========================================
+ Hits         9215     9237      +22     
+ Misses        940      922      -18     
+ Partials      519      517       -2     

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

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.

Thanks, this looks good, I left two comments.

# return of axes must not be empty, or dimensions are lost
offsets = [0,0]
scales = [sizes[1],sizes[0]]
unit = "pixel"
Copy link
Member

Choose a reason for hiding this comment

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

In this case, the standard pattern is to set to None and in hyperspy will be parsed a traits.api.undefined value.

Suggested change
unit = "pixel"
unit = None

# if no exif_tags exist, axes are set to scale of 1 pixel/pixel
# return of axes must not be empty, or dimensions are lost
offsets = [0,0]
scales = [sizes[1],sizes[0]]
Copy link
Member

Choose a reason for hiding this comment

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

While you are at it and in the interest of readability, can you please rename here and in the two other places below to

Suggested change
scales = [sizes[1],sizes[0]]
fiels_of_views = [sizes[1],sizes[0]]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, did the changes, also set unit to "None".

@ericpre
Copy link
Member

ericpre commented Jul 3, 2024

pre-commit.ci autofix

@ericpre ericpre merged commit ee8a226 into hyperspy:main Jul 3, 2024
31 checks passed
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