Reading an EELS spectrum image from a tiff file #54
-
Describe the bugI recorded some EELS data using GMS 2 yesterday and didn't notice that the previous user had been saving in tiff and not dm4 format so saved all my spectra in this format. Thankfully the spectra are saved as tiff stacks with the all relevant axes information in the tiff header, however when I try and read these files with exspy the conversion to an EELS datatype within hyperspy is not occuring properly To ReproduceSteps to reproduce the behavior:
Using the exspy.signals.EELSSpectrum object more explicity:
Trying to pass the gpf.axes_manager object as the axes kwarg yielded:
Expected behaviorThere might be a better way to do this conversion, if so please let me know. Python environment:Name Version Build Channelhyperspy 2.1.0 pyhd8ed1ab_0 conda-forge Additional contextI can't upload the raw spectrum as it is too large but can share a onedrive link if requested. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
@HamishGBrown it looks like the data is 28,30|2048 channels? Is that correct. Tiffs only support 3 dimension stacks with 2 of the dimensions for each "image" so likely the data is saved transposed which is why it is loaded in as a signal 2D or 2048|30,28. Try this: gfp = hs.load("/home/hbrown/Mount/F30data/Hamish/20240603_GFP_BSA_comparison/{0}/{1}_EELS Spectrum Image.tif".format('1_5mgmlGFP','AF'))
gfp = gfp.T #the signal is now a Signal1D
gfp.set_signal_type("EELSSpectrum") You might need to manually adjust the axes manager based on the header and set things like Let me know if you need more help and if you share the data I can look at it further. If there is enough metadata in the header this might be some thing we could support |
Beta Was this translation helpful? Give feedback.
-
@CSSFrancis, this seems to have fixed the problem so thank you for your help. I had to make one edit:
To the code you suggested since the transpose method seems to return a copy of the object but doesn't affect the original object. |
Beta Was this translation helpful? Give feedback.
-
I transfer this issue to the exspy discussion, hoping that it would be easier to find than an issue in rosettasciio. This could also be made an example, but I think that this is a bit of an unusual/unfortunate case and as such shouldn't an example! |
Beta Was this translation helpful? Give feedback.
@HamishGBrown it looks like the data is 28,30|2048 channels? Is that correct. Tiffs only support 3 dimension stacks with 2 of the dimensions for each "image" so likely the data is saved transposed which is why it is loaded in as a signal 2D or 2048|30,28.
Try this:
You might need to manually adjust the axes manager based on the header and set things like
gfp.axes_manager.signal_axes[0].scale
Let me know if you need more help and if you share the data I can look at it further…