pythonhyperspy

How can you export images from an .emd file with hyperspy?


Given a HAADF-STEM Spectrum Image (SI) as .emd (Velox) file, I want to extract all individual HAADF-images from the stack.

I assume there is an easy way with hyperspy, but I am unable to identify it.

My code so far:

import hyperspy.api as hs
path = r'C:\Users\SI_File.emd'
s = hs.load(path)

Solution

  • I used the following, the code can be simpler but I included variables to minimise retyping filenames.

    In order, the process is:

    -import file

    -split stack into individual images

    -iterate save for all images (my stack was 30 images, hence i<=29) into a new folder and save as ripple format. http://hyperspy.org/hyperspy-doc/current/user_guide/io.html#id38

    Install the ripple-to-dm4 script to digital micrograph and batch convert the ripple files to .dm4. http://hyperspy.org/hyperspy-doc/current/user_guide/io.html#import-rpl

    %matplotlib qt
    import hyperspy.api as hs
    import numpy as np
    import matplotlib.pyplot as plt
    
    f="FILENAME"
    s = hs.load(f'{f}.emd')
    
    s_haadf = s[1].split()
    
    i = 0
    while i<=29:
        s_haadf[i].save(f'{f}/{f}_{i:03d}.rpl')
        i+=1