Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asking for a feature to open .spc file for EDS-TEM #307

Open
sofomryu opened this issue Aug 29, 2024 · 5 comments
Open

Asking for a feature to open .spc file for EDS-TEM #307

sofomryu opened this issue Aug 29, 2024 · 5 comments

Comments

@sofomryu
Copy link

Hi, I'm writing this to ask the feature to read a .spc file for EDAX(EDS) spectrum with TEM.
Hyperspy support to read .spc file but it couldn't read my spc file. Maybe it is because hyperspy only support EDS-SEM, not EDS_TEM.

https://rosettasciio.readthedocs.io/en/v0.3/user_guide/supported_formats/edax.html

From this link, I was able to find it doesn't support EDS-TEM, saying "Currently, HyperSpy will load data as an EDSSEMSpectrum signal. If support for TEM EDS data is needed, please open an issue in the issues tracker to alert the developers of the need."

If I still try to read my spc file with the following code,

import hyperspy.api as hs
s=hs.load('myspcfile.spc')

the following error occurs.

ERROR | Hyperspy | If this file format is supported, please report this error to the RosettaSciIO developers at https://github.com/hyperspy/rosettasciio/issues (hyperspy.io:599)
Traceback (most recent call last):
File "/Users/username/test_hyperspy.py", line 4, in
hs.load(doc)
File "/Users/username/myenv/lib/python3.12/site-packages/hyperspy/io.py", line 537, in load
load_single_file(filename, lazy=lazy, **kwds) for filename in filenames
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/username/myenv/lib/python3.12/site-packages/hyperspy/io.py", line 596, in load_single_file
return load_with_reader(filename=filename, reader=reader, **kwds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/username/myenv/lib/python3.12/site-packages/hyperspy/io.py", line 618, in load_with_reader
file_data_list = importlib.import_module(reader["api"]).file_reader(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/username/myenv/lib/python3.12/site-packages/rsciio/edax/_api.py", line 1013, in file_reader
return spc_reader(filename, lazy, endianess, load_all_spc=load_all_spc, *kwds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/username/myenv/lib/python3.12/site-packages/rsciio/edax/_api.py", line 719, in spc_reader
data = np.memmap(
^^^^^^^^^^
File "/Users/username/myenv/lib/python3.12/site-packages/numpy/_core/memmap.py", line 262, in new
bytes = int(offset + size
_dbytes)
^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: only length-1 arrays can be converted to Python scalars

shell returned 1

@jat255
Copy link
Member

jat255 commented Aug 29, 2024

Thanks for reporting this @sofomryu. This limitation was mostly because we did not have an example file from a TEM at the time the reader was developed. Could you share the file that you're having issues with by attaching it to a comment here?

@sofomryu
Copy link
Author

Thanks for reporting this @sofomryu. This limitation was mostly because we did not have an example file from a TEM at the time the reader was developed. Could you share the file that you're having issues with by attaching it to a comment here?

Of course! Here it is. Thank you for your swift reply.

N2-01.SPC.zip

@jat255
Copy link
Member

jat255 commented Aug 29, 2024

Hmm, does this error happen with every file produced by your system? There's no header in that .spc file that contains the metadata required to read the data (this is why the error you posted in the original comment occurs).

If it does, can you please provide more information about the software that produced the file (name, version number, etc.). It's possible EDAX has updated the file format. I no longer have access to an EDAX system to test on.

@jat255
Copy link
Member

jat255 commented Aug 29, 2024

Oh, actually it looks like I can see the version of the file is 0.34. I'm not sure of the vintage of that version, but it's at least older than when the EDAX reader was originally written in the ~2015 timeframe. We only had documentation for formats 0.61 and 0.70, so I think without some difficult reverse engineering work, we probably won't be able to read this file. You could also try reaching out to the EDAX applications team to see if they could provide you any documentation they have for that file version, which would definitely help implementing a reader.

@sofomryu
Copy link
Author

Wow, it is much complicated problem than I expected. I don't remember the exact software generating the spc file, but it is possible to read the file with spectrum viewer software in the following link. https://www.edax.com/support/spectrum-viewer
I was able to obtain the related information of the file. I'll open the file tomorrow and let you know just in case.
Meanwhile, I just contacted the EDAX team to ask the documentation with the old version. I'll let you know if I got some news. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants