usnistgov / PyHyperScattering

Tools for hyperspectral x-ray and neutron scattering data loading, reduction, slicing, and visualization.
Other
6 stars 8 forks source link

Bug in loading image masks #110

Closed BijalBPatel closed 3 months ago

BijalBPatel commented 8 months ago

Attempting to load an image as a mask yields a KeyError on 'maskPath'.

Problem: The maskpath (and maskrotate) variables dont actually get passed into the loadImageMask function i think because they're explicitly in the signature and not part of kwargs.

Reference:

Function loadImageMask:

https://github.com/usnistgov/PyHyperScattering/blob/52aee5ad8cefabe012ccd4d00fe5be2a39f5fdf8/src/PyHyperScattering/PFGeneralIntegrator.py#L384-L401

Constructor for PFGeneralIntegrator:

https://github.com/usnistgov/PyHyperScattering/blob/52aee5ad8cefabe012ccd4d00fe5be2a39f5fdf8/src/PyHyperScattering/PFGeneralIntegrator.py#L259-L284

A possible fix is to just explicitly pass in the variables:

elif maskmethod == "image": self.loadImageMask(maskpath=maskpath, maskrotate=maskrotate, **kwargs)

This may also be an issue for the other mask loading methods (polygon and pyhyper).

BijalBPatel commented 8 months ago

I might take the opportunity of fixing this and #33 together in the next week or so

pbeaucage commented 8 months ago

Thanks, this is a good catch. (can you tell I rarely save image masks?). Your fix seems reasonable to me, let me know if you need a hand with anything.