Loading data in ENVI hdr format

1,776 views
Skip to first unread message

Karim Lenhard

unread,
Mar 29, 2014, 5:49:14 AM3/29/14
to hypersp...@googlegroups.com
Hi!

The data I work with comes in the ENVI hdr format (i.e. a BIL or BSQ binary file with a text file describing the data). Is there a convenient way to import this data into Hyperspy?

Thanks!

Francisco de la Peña

unread,
Mar 31, 2014, 5:35:50 AM3/31/14
to hypersp...@googlegroups.com
Hi,

This is not the first time that we are asked this question. At present, i.e. until we provide support for this format, the easiest way to import ENVI data into HyperSpy is to use an external library that supports reading ENVI files, e.g. Spectral Python

    from spectral import open_image
    img = open_image("your_file.hdr")
    im = signals.Spectrum(img.load(), original_parameters=img.metadata).to_image()

If you are using the development version of HyperSpy replace the lastest line with:

    im = signals.Spectrum(img.load(), original_metadata=img.metadata).to_image()

HyperSpy 0.7 (yet to be released) is much faster than 0.6 at displaying images, so if you're using HyperSpy 0.6 and you find the lag annoying you can upgrade to the development version or wait until we release 0.7.

Could you let us know if this helps?

Francisco




--
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.

Karim Lenhard

unread,
Mar 31, 2014, 6:49:23 AM3/31/14
to hypersp...@googlegroups.com
Hi Francisco,

Thank you, this helps. But my version of spectral python (0.14) does not include an open_image function. Instead, I used:

from spectral.io import envi
img = envi.open("image.hdr", "image.dat")

Cheers
Karim

Francisco de la Peña

unread,
Mar 31, 2014, 6:59:24 AM3/31/14
to hypersp...@googlegroups.com
Hi Karim,

Thanks for the correction. I don't have any ENVI file to test the code that I posted, so, most likely, my example didn't work simply because it was wrong, not because we're using different spectral python versions.

Cheers,

Francisco
Reply all
Reply to author
Forward
0 new messages