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

[Bug]: Incorect scaling of JPK image files #116

Open
derollins opened this issue Feb 24, 2025 · 1 comment
Open

[Bug]: Incorect scaling of JPK image files #116

derollins opened this issue Feb 24, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@derollins
Copy link

Describe the bug

When loading JPK file the raw data needs to be scaled and offset, the values of these offsets are found in the tags of the channel pages but there are multiple scaling factors currently AFMReader can choose the incorrect scaling factor leading to incorrect z values.

I have fixed this by seperating out the different scaling factors into their slots and selecting the 'default' slot that was used within the instrument.

Copy of the output

There is no error, the z values of loaded images are just incorrect.

To Reproduce

No response

AFMReader Version

0.1.0

Python Version

3.11

Operating System

Windows

Python Packages

No response

@derollins derollins added the bug Something isn't working label Feb 24, 2025
@derollins
Copy link
Author

Some extra information.

The image below shows the output of 9 channels from the sample jpk used in examples and testing. When compared with other software that reads .jpk files (gwyddion, JPK DP, NanoLocz) the scaling is incorrect for each channel other than for measuredHeight.

Image

Additionally phase can not be processed due to a key error when reading the scaling type. That gives this error message:

  File "C:\Users\ggjh246\OneDrive - University of Leeds\Code\test_jpk_load.py", line 15, in <module>
    raw_image, px2nm = load_jpk(file_path, channel)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ggjh246\AppData\Local\anaconda3\envs\AFMReader_pip\Lib\site-packages\AFMReader\jpk.py", line 95, in load_jpk
    scaling_type = channel_page.tags["33027"].value
                   ~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "C:\Users\ggjh246\AppData\Local\anaconda3\envs\AFMReader_pip\Lib\site-packages\tifffile\tifffile.py", line 11915, in __getitem__
    raise KeyError(key)
KeyError: '33027' 

Through introducing a function that can accurately read the channel and scaling data this can be corrected and the output matches the values from the other AFM image processing programmes.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant