Git Product home page Git Product logo

Comments (6)

hakonanes avatar hakonanes commented on July 23, 2024 1

Will look into this right away after making sure we can load HDF5 files with kp.load().

from kikuchipy.

tinabe avatar tinabe commented on July 23, 2024
  • ii. Solution that seems to work is:
            if (omd.deadpixels_corrected and omd.deadpixels.any() and
                    omd.deadvalue.any()):
  • iii. Also, a runtime error is encountered in the rescale:

RuntimeWarning: overflow encountered in byte_scalars
scale = float(omax / (pattern.max() - imin))

from kikuchipy.

hakonanes avatar hakonanes commented on July 23, 2024

i. Raising an error is the correct response since no background image is provided, however the error message could be clearer. I changed from except ValueError: to except (ValueError, AttributeError): so that the custom error message "No background image provided" is printed also when the original_metadata has no General.original_filepath parameter. Note that this error message will be raised when this is the case, regardless of which loading function (HyperSpy's or KikuchiPy's) is used.

ii. As you say, changing to omd.deadpixels.any() fixes the problem! There is no need to add it to a string though, i.e. omd.deadvalue.

iii. Pretty sure the problem is a too narrow data type (np.int8, [-128, 127]). If so, this warning is raised when the subtraction of a static background from a pattern yields some pixels with negative values below -128. This is prevented by setting both patterns data types to np.int16, [-32 768, 32 767], in kikuchipy/utils/expt_utils.py here:

def correct_background([...]):
[...]
    if static:
        # Change data types to avoid negative intensities in subtraction
        dtype = np.int16
        pattern = pattern.astype(dtype)
        bg = bg.astype(dtype)
[...]

Could you see if this fixes the problem? I cannot remember if correct_background() leaks much memory, I think not, but if so raising to 16-bit will make thinks worse... Will check this myself if this solves the problem.

from kikuchipy.

hakonanes avatar hakonanes commented on July 23, 2024

I see that the comment explaining the code (# Change data types...) is wrong, will remove this when pushing fixes to the problems.

from kikuchipy.

hakonanes avatar hakonanes commented on July 23, 2024

Have you checked my solution to problem iii?

from kikuchipy.

hakonanes avatar hakonanes commented on July 23, 2024

Solved in PR #28.

from kikuchipy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.