-
Notifications
You must be signed in to change notification settings - Fork 206
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
Fix quant scaling error #2090
Fix quant scaling error #2090
Conversation
This change will not change the units in the original spectrum image, just locally within the function for the correct electron dose to be calculated. |
…gnal is not changed when doing a quantification.
bd2f87b
to
5e984cd
Compare
@k8macarthur I have rebased your branch on Rnp to fix some left over of a merge conflict and the merge commits. You will need to checkout this branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things need to be fixed:
- not to change the units in place,
- currently
get_dose("cross section")
works only for spectrum image.
See more detailed comments below.
hyperspy/_signals/eds_tem.py
Outdated
if self.axes_manager[0].units != 'nm': | ||
self.axes_manager[0].convert_to_units('nm') | ||
if self.axes_manager[1].units != 'nm': | ||
self.axes_manager[1].convert_to_units('nm') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changing the units in place. The following should work:
pixel_size = []
# in case there are more than 2 navigation axes.
for axis in self.axes_manager.navigation_axes[:2]:
pixel_size.append(axis.convert_to_units('nm', inplace=False)[0])
In particularly, for a dataset with navigation dimension > 2, how do we know if we pick the correct navigation axes? Here, I assume that the first two items of the axes_manager.navigation_axes
are the "x" and "y" spatial dimension but it could something else!
Depending on how this is implemented, this should be documented.
hyperspy/_signals/eds_tem.py
Outdated
if self.axes_manager[0].units != 'nm': | ||
self.axes_manager[0].convert_to_units('nm') | ||
if self.axes_manager[1].units != 'nm': | ||
self.axes_manager[1].convert_to_units('nm') | ||
pixel1 = self.axes_manager[0].scale | ||
pixel2 = self.axes_manager[1].scale |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the method to get the dose will be wrong for linescan: self.axes_manager[1].scale
could be a signal axis..
res2 = s2.quantification(intensities, method, factors) | ||
np.testing.assert_allclose(res[0][0].data, res2[0][0].data) | ||
# Check that the quantification doesn't change the units of the signal | ||
assert s.axes_manager[0].units == 'µm' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is this assertion which need to be true. At the moment, the units are changed inplace.
…uant_Scaling_Error-RNP
I have fixed the comments of my review. |
LGTM |
Description of the change
The dose calculation function used for cross section quantification previously assumed that the units of the navigation axis are in 'nm'. Therefore I've added a check to the function and convert_to_units for when the units are not 'nm'.
Test to check whether or not different units produces the same quantification results was also added.
As this is a bug fix no update to the user guide is needed.