hyperspy / rosettasciio

Python library for reading and writing scientific data format
https://hyperspy.org/rosettasciio
GNU General Public License v3.0
46 stars 28 forks source link

Renishaw reader calculates the scale for the microscope image incorrectly #301

Open Asharits opened 1 month ago

Asharits commented 1 month ago

Describe the bug

In the Renishaw reader, the scale for the microscope image (WHTL) is being calculated incorrectly for hyperspectral maps. This causes the mapped area (red box) to show up in the wrong area.

To Reproduce

I verified this by comparing images to mapped area in the WiRE versus what Hyperspy is plotting for multiple datasets.

Expected behavior

I am not sure where in the reader this is being calculated but it is an easy fix. In the original metadata for the microscope image, FocalPlaneXYOrigins contains the origin for X and Y. FocalPlaneXResolution and FocalPlaneYResolution contains the length of the image. These values just need to be added to the origin values and then divided by the image shape to obtain the correct scale.

I tested this out on some of my datasets and it fixed the scale and the red box was now in the correct place.

Python environment:

ericpre commented 1 month ago

Are you saying that the offset and scale of the microscope image are incorrect but the hyperspectral maps are correct?

The scale and offset of the microscope image are calculated in https://github.com/hyperspy/rosettasciio/blob/e49911047c03465a84facac546053576a23ef915/rsciio/utils/image.py#L42-L70

And what it does seems to be consistent with your description of how it should be calculated.

As I remember, the data that I have doesn't have this issue. Can you share files and screenshots?

Asharits commented 1 month ago

Hmm, I wonder why it isn't working for me. Below is a screenshot of the same dataset from WiRE and in Hyperspy. You can see the map area does not match up.

WiRE Screenshot Screenshot 2024-08-14 141404

Hyperspy Screenshot Screenshot 2024-08-14 111531

Asharits commented 1 month ago

To me it looks like an issue with the way scale is calculated using FieldOfViewXY. Maybe there is a difference depending on the version of WiRE? I am on 5.6