Re: SEM EDS Raw file in Python

543 views
Skip to first unread message

Francisco de la Peña

unread,
Jun 5, 2014, 12:07:16 PM6/5/14
to hypersp...@googlegroups.com
Jon,

RAW is not a standard format and, therefore, in order to help you, we need to know more about what RAW means in the context of the software that you are using.

If you are lucky, the RAW file will be a binary file containing just the data and it'll be accompanied by an additional text file (the header) containing the information required to read it. If that is not the case, you probably can get the information that you need from the software that you use to save the file.

If you are really lucky, the header file will have extension ".rpl" and then you'll be able to read it directly with HyperSpy. If not, you can write manually the header file with the information extracted from the header file provided by the software or the information about the dataset that you should be able to get from the software. I send attached a header file to read a spectrum image that you can use as a template. It is essential to get the following keys right: data-length, data-type, depth, height, width. For a SI you shouldn't need to modify byte-order and record-by, and the rest of the keys just contain calibration information. This format is fully documented here. HyperSpy's implementation is documented in the code.


Does this help?

Best wishes,

Francisco


On 5 June 2014 06:32, Jon barnes <catoth...@gmail.com> wrote:
I am trying to import in a RAW file of a SmartMap from EDS using the
Zeiss SEM at Portland State University.  I am able to import the file
using the GDAL libarary, if I convert the RAW file to an ENVI file.
But do you have any advice or tips on how to read in the RAW file
using PIL or another tool?

I am trying to read in the RAW file to Python so I can use Python
tools instead of INCA/AZTEC to do spectral analysis.

I am trying to use something like the following (from http://stackoverflow.com/questions/3397157/how-to-read-a-raw-image-using-pil);
if __name__ == "__main__":
    if (len(sys.argv) != 4):
        print 'Error: missing input argument'
        sys.exit()

    file = open(sys.argv[1], 'rb')
    rawData = file.read()
    file.close()

    imgSize = (int(sys.argv[2]), int(sys.argv[3]))

    # Use the PIL raw decoder to read the data.
    #   - the 'F;16' informs the raw decoder that we are reading a little endian, unsigned integer 16 bit data.
    img = Image.fromstring('L', imgSize, rawData, 'raw', 'F;16')

    im.save('out.png')


Thank you for any help or tips or suggestions.

--
You received this message because you are subscribed to the Google Groups "hyperspy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hyperspy-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

example.rpl

Pierre Burdet

unread,
Jun 16, 2014, 9:59:53 AM6/16/14
to hypersp...@googlegroups.com
Dear Jon,

As Fransisco said, hyperspy can open raw file through the header (.rpl).

>>> s = load('my_file.rpl')

Hyperspy read the raw file exported from INCA (smartMap). I never tried to import raw file exported from AZTEC. It might work. If not, I would happy to adapt hyperspy to read such a file.

Cheers

Pierre
Message has been deleted

John Minter

unread,
Jun 17, 2014, 8:10:35 PM6/17/14
to hypersp...@googlegroups.com
We have the current AZtec system (v. 2.2) Export is still via INCA. BTW - Pierre, your correction of the INCA .rpl format is really helpful. 
I have used it to correct files for input in R using Jeff Davis (NIST) code. It is also nice to add the the calibration info to the .rpl file.

Best Regards,
John Minter

Pei Liu

unread,
Dec 8, 2017, 1:32:28 PM12/8/17
to hyperspy-users
Dear Pierre,

Now I'm trying to open Aztec EDS 'raw' data via Hyperspy, but it not works. Do you know any update since then? 
Thank you very much.

Best,
Pei

Thomas Aarholt

unread,
Dec 8, 2017, 2:04:51 PM12/8/17
to hyperspy-users
Hi Pei,

In order to help you it would be great if you could supply a bit more information, ideally an example of a small map file you are trying to import.


Best,
Thomas

To unsubscribe from this group and stop receiving emails from it, send an email to hyperspy-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Thomas M. Aarholt

Post Doc, University of Oslo 
 
Mobile: +47 92855828
Reply all
Reply to author
Forward
0 new messages