Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 28 10:43
    codecov[bot] commented #2871
  • Jan 28 10:23
    codecov[bot] commented #2871
  • Jan 28 10:12
    codecov[bot] commented #2871
  • Jan 28 10:12
    nem1234 synchronize #2871
  • Jan 28 08:44
    codecov[bot] commented #2871
  • Jan 28 08:24
    codecov[bot] commented #2871
  • Jan 28 08:14
    codecov[bot] commented #2871
  • Jan 28 08:14
    nem1234 synchronize #2871
  • Jan 28 07:58
    codecov[bot] commented #2871
  • Jan 28 07:40
    codecov[bot] commented #2871
  • Jan 28 07:27
    codecov[bot] commented #2871
  • Jan 28 07:27
    nem1234 synchronize #2871
  • Jan 27 09:16
    codecov[bot] commented #2871
  • Jan 27 09:00
    codecov[bot] commented #2871
  • Jan 27 08:45
    codecov[bot] commented #2871
  • Jan 27 08:45
    nem1234 synchronize #2871
  • Jan 26 13:50
    ericpre commented #2857
  • Jan 26 13:46
    AEljarrat commented #2857
  • Jan 26 13:07
    AEljarrat commented #2857
  • Jan 26 10:48
    codecov[bot] commented #2871
Abohaitham92
@Abohaitham92
Hello all, I have a question regarding loading an .edm file and then saving it to hdf5 file, i just loaded an edm file using s = hs.load(edm_file), which gave me a list of signals, what is the best way to save all of these signals into one hdf5 file ? I used to save one signal using s.save(test.hdf5). But now using the save command for each signal in my list on the same file will overwrite the file.
1 reply
lnaglecocco
@lnaglecocco
image.png
Hi, I think someone explained this to me before but I don't remember the explanation and can't find it - sorry. When I plot a model with plot_components=True, some of the components have features which shouldn't be part of the component. For example the red peak here is a GaussianHF yet it has features around 800 eV which contribute to the overall fit. What is that all about?
2 replies
lnaglecocco
@lnaglecocco
Another unrelated question, and thank you in advance. I have a dataset for which fitting a model can be quite time-consuming. So rather than re-fitting every time I load it up and want to look at it, I'd like to save it and simply load the file. However - when I try code like ".model.save("model",extension="hspy")", and then "model_2 = hs.load("model.hspy")", model_2 doesn't seem to have the model, just the experimental data. How can I save a model?
2 replies
DENSmerijn
@DENSmerijn
Hi all, we are trying to load a Velox .mrc file but we keep getting the following error: ValueError: cannot convert float NaN to integer
We have tried multiple files, all with the same outcome. Any idea what could be causing this issue?
7 replies
Mingquan Xu
@Mingquan_Xu_twitter
image.png
If I want to fit a fractional energy-range in my spectrum, how can I use the m.fit() function?
Like only fit the energy range marked in orange above
2 replies
Mingquan Xu
@Mingquan_Xu_twitter
image.png
3 replies
Hi, all, if I want to get the data-points of my model-fitting, the green line, how to do it? Because I want use those data-points to plot it individually.
Mingquan Xu
@Mingquan_Xu_twitter
Hi, all, recnetly I am trying Matlab to treat my spectrum image data, but I donot know how to expot the data after processing. Are there any matlab scripts can write the spectrum image data? such as to .mrc ?
lnaglecocco
@lnaglecocco
Hi, is there a way to exclude certain pixels (with each pixel containing a spectrum) from a model before fitting? I've written an algorithm which produces an array of coordinates representing pixels which are not part of my sample, but I'm not sure how to make that happen. I know I can use .inav[x1:x2,y1:y2] but my sample is not a perfect square so just cropping isn't quite what I want to do
8 replies
lnaglecocco
@lnaglecocco
I have another question which probably has a very simple fix. When I do model.plot() the spectrum at each pixel is normalised such that the plot fits perfectly. However, when I set plot_components=True, I get it so that only part of the data fits in the y axis. I've figured out that this is because it's setting the y-axis bounds for the graph based on a single component, rather than the total fit. How can I fix this so that model.plot(plot_components=True) gives each pixel normalised to the total fit rather than the y-span of a single component?
2 replies
OliDG
@OliDG
Hi,
I try to find a way to save my "file.hspy" using the save() function to a specific path, but I can't see a "path" argument in the function description. Ideally, I was hoping to get the path from the hs.load() function ("load.path/of/my/loadedfile") and use it to save to the same folder without having to manually enter a path ( I have many datasets from many different folders).
20 replies
Jędrzej Morzy
@JMorzy

Is there a way of adapting 'fit_component' function to work using multiple threads on a CPU? The only mention of parallel processes that I found in the docs was in SAMFire and in the map function. I have a relatively specific order of component fits (for EELS core-loss data) that I wouldn't want to change. Any advice on how to approach this would be appreciated!

(I just recently got my hands on a computer, where parallelising would save a significant amount of time)

2 replies
Rosenkranz1
@Rosenkranz1
Hello. I am fairly new to programming, and i am trying to write some extensions to the HyperSpy program. I know how to write a class and have the class inherit etc, but when i create a class for a HyperSpy extension, which should basically inherit the "whole" of HyperSpy so i can use the methodes in HyperSpy in my extension, what is the best approach for this?
I should fork the github repo, but for me it is not very intuitive, what the best way to write extensions are.
I have read the documentation on this, from HyperSpys websites, but i need some elaboration.
Any advice is highly appriciated!
6 replies
Rosenkranz1
@Rosenkranz1

Hello, i have a followup question for my question above.

I want to contribute to a package that already excist (The eds packages). How would i go about using my contribution? By forking the repo and including my methodes in the relevant classes or should i create my own class, and have that inherit from eds? In the latter case, i am struggeling to get the inheritance to work properly, i have written some code, but when i try to apply my method too a dataset it exclaim that EDSSpectrum does not have the attribute, should correct inheritance not fix this? Or is the only way to create my code in a forked repo of the relevant signal?
This might be a trivial question but i cant seem to find the answer. (Maybe i lack some understandig of classes)

6 replies
Weixin Song
@winston-song
Hi All, I use DM to record some EDX spectral images, when I process them using PCA, it shows 'ValueError: zero-size array to reduction operation minimum which has no identity' whether anyone knows how to resolve this problem? thanks
Weixin Song
@winston-song
image.png
Eric R. Hoglund
@erh3cq
Are there any EXELFS functions or plugins for HyperSpy?
Francisco de la Peña
@francisco-dlp
Is it an EDX model? The issue may be that more elements require more memory—are you saturating your memory by any chance?
1 reply
Markus Wollgarten
@w-markus
Dear all, a rather simple question: when loading dm3 files of diffraction data the metadata only contains the 'General' branch. Is there a signal type one should request upon loading, that more metadata fields are available even if not filled yet? Thanks a lot! Markus
5 replies
Mingquan Xu
@Mingquan_Xu_twitter
image.png
1 reply
A simple question: how to improve this fitting.
I used a "g1 = hs.model.components1D.Gaussian()" to do this fit and want to get the center of this peak.
Jonas Lähnemann
@jlaehne
kociak
@kociak
Dear all. I have an annoying issue with installing hyperspy for use in an environment having the last version of nionswift. The conflict comes from the fact that hs requires numba, and numba requires numpy <=1.20 (hs installs 1.20.3). But nionswift requires numpy 1.21.4 (I guess for the Typing functionalities). My question: can we switch off the use of numba in hyperspy? thanks guys
7 replies
kociak
@kociak
@thomasaarholt: lean and fit. i'll take a look at that and tell you if that works (hopefully I won't get stuck by another hidden compatibility issue :)
Javalde91
@Javalde91

Well, this does the job:

s.plot()
roi = hs.roi.RectangularROI(0.0, 0.0, 0.00001, 0.00001)
roi_signal = roi.interactive(s)

Hello Thomas and everyone, I'm trying to apply a CirleROI but I would like it to have it interactive way, is it possible to do it? Thanks

4 replies
Amina Saleh
@Amina_saleh_twitter
Hi, I used to get my spectrum images in color. Now, when I downloaded another version on another laptop, I only get grayscale rather than colorscale. How can I retrieve the color scale back?
1 reply
Joshua F Einsle
@jeinsle
I am trying to layout some results figures for collaborators and trying to be slightly more efficent than my normal save a plot and layout in powerpoint I decided to try set this up in hyperspy. What I would like to get is figure which looks like this example in the 'Visualisation' section of the Hyperspy website.
alt
however when I run my version of that cell I end up with two seperate figures, instead of a single figure with two subfigures like what is seen above. While I know how to do this with matplotlib, I was wanting to leverage the built in hyperspy tools so the metadata/ axis manger information is automatically applied, as opposed to having to do the heavy lifting again. Any insights would be appricaiated.
3 replies
Mohsen
@M0hsend
Hi All, I am trying to open .hspy files written with RELEASE_next_minor branch with the released 1.6.5 version and I get the following error: TypeError: __init__() got an unexpected keyword argument '_type'. Any ideas how to fix / work-around?
2 replies
Mohsen
@M0hsend

Hi All, I am trying to open .hspy files written with RELEASE_next_minor branch with the released 1.6.5 version and I get the following error: TypeError: __init__() got an unexpected keyword argument '_type'. Any ideas how to fix / work-around?

Never mind. Just reading with h5py and populating axes metadata works good enough. Thanks!

Javalde91
@Javalde91
Hello everyone! I'm trying to get the total electron counts from my SI. I usually do it on DM, but I can't get it on hyperspy, I use s.sum(), but the number that I get is "(|2036)>" from the dimension of my SI ("<EELSSpectrum, title: C_CL_0, dimensions: (80, 80|2036)>" What I'm trying to do is to get the total e- counts to normalize my SI and compare them.
Thomas Aarholt
@thomasaarholt
s.T.sum() :)
Thomas Aarholt
@thomasaarholt
(.T swaps around the navigation and signal dimensions)
OliDG
@OliDG

@thomasaarholt Hi,
I try to get quantified EDS from a sample with many elements (Al,C,Co,Cu,Cr,Mo,O,Pt,W,Zn) with a strong peak overlap between Cr-L (0.571 eV) and O-K (0.523 eV).
One layer is expected to be CrC but appears as CrO... the quantification output 30% of O in it, which is very unexpected for several reasons. Checking the EDS spectrum manually I can see the peak shift by maybe 1 channel when seeing Cr-L instead of O-K but the model fitting doesn't.
I am using the EDS model fitting and after several hours in the documentation I come here to ask: Is there a solution to this? is there a function somewhere that can for instance estimate Cr-L from the Cr-K intensity and subtract it from the O-K signal before saving the O-K intensity? I hope this question is clear enough!

Regards,
Olivier

8 replies
adriente
@adriente

I am trying to run the following code :

import hyperspy.api as hs
input_filename = "file1.emd"
spim = hs.load(input_filename)[-1] 
# the output of the load function is a list in which the last element is an EDSTEM object.
spim.change_dtype("float")
spim.crop(1,70,400)
spim.crop(2,0.3,19.0)

spim.decomposition(True)

It ouputs : ValueError: All the data are masked, change the mask.

It seems to me that the crop functions are at the source of this issue since when I comment them everything is fine.
I am asking here to check if I am missing something. But I will post an issue on github if not.

3 replies
TheTadpole97
@TheTadpole97

Hi, I'm not sure if it's just me missing something. But when I import images from Velox EMD (this particular file has 9538 HAADF frames), only the scaling from the first frame is retained in the axes_manager values. I've copied my code snippet below.

%matplotlib qt
import hyperspy.api as hs
import numpy as np
import matplotlib.pyplot as plt
import scipy
import hyperspy.misc as hsm
#prevent figure opening
plt.ioff()

#load file
s = hs.load("211217/HeatedTEM/HeatedTEM.emd")
print("imported")

print(s.axes_manager)

#format and save image with time stamp
for single_image in s:

    ####### Failed attempt at scaling

    single_image.axes_manager[1].scale
    single_image.axes_manager[0].scale

    single_image.axes_manager[1].offset
    single_image.axes_manager[0].offset

    single_image.axes_manager[1].units
    single_image.axes_manager[0].units

    a = single_image.plot(colorbar=False, scalebar=True, axes_ticks=False)
    plt.axis('off')
    plt.savefig('test/image %s.png' % str(s.axes_manager.indices), bbox_inches = 'tight', pad_inches = 0.1)
    plt.close()
    #single_image.save("test/image %s.png" % str(image_stack.axes_manager.indices))

But every single_image.axis_manager contains the same value as s.axis_manager (in this case 0.37nm) so the scaling is the same for every image

5 replies
aowenli
@aowenli
Hi, I wonder if I want to use two windows (before and after edge) to fit an EELS spectrum, what should I do?
rpsankaran
@rpsankaran

Hello
in Pycharm I had the below code that worked before with giving interactive hyperspy plots with s.plot()

import matplotlib
matplotlib.rcParams["backend"] = "Agg"
import hyperspy.api as hs

I am getting the following error and no plots shown. Please help if possible, and let me know if you need more information.
Thank you!

WARNING:hyperspy_gui_traitsui:The agg matplotlib backend is not compatible with the traitsui GUI elements. For more information, read http://hyperspy.readthedocs.io/en/stable/user_guide/getting_started.html#possible-warnings-when-importing-hyperspy.
WARNING:hyperspy_gui_traitsui:The traitsui GUI elements are not available.
rpsankaran
@rpsankaran
Also, having trouble with plotting an .emd. The navigator window comes up just fine, but is completely black. Should be the HAADF image - unsure how navigator sums/integrates/chooses the file for the navigator where the loaded data list has multiple signals: e.g. Any help in understanding why the navigator pane/window is black? Thank you!
[<EDSTEMSpectrum, title: EDS, dimensions: (|4096)>,
 <EDSTEMSpectrum, title: EDS, dimensions: (|4096)>,
 <EDSTEMSpectrum, title: EDS, dimensions: (|4096)>,
 <EDSTEMSpectrum, title: EDS, dimensions: (|4096)>,
 <Signal2D, title: x, dimensions: (|512, 512)>,
 <Signal2D, title: HAADF, dimensions: (|512, 512)>,
 <Signal2D, title: x, dimensions: (|512, 512)>,
 <Signal2D, title: x, dimensions: (|512, 512)>,
 <Signal2D, title: x, dimensions: (|512, 512)>,
 <Signal2D, title: x, dimensions: (|512, 512)>,
 <Signal2D, title: x, dimensions: (|512, 512)>,
 <Signal2D, title: x, dimensions: (|512, 512)>,
 <Signal2D, title: x, dimensions: (|512, 512)>,
 <Signal2D, title: x, dimensions: (|512, 512)>,
 <Signal2D, title: x, dimensions: (|512, 512)>,
 <EDSTEMSpectrum, title: EDS, dimensions: (512, 512|4096)>]
1 reply
zhanxun8
@zhanxun8
Hello, I analyze my EELS data using hyperspy. It worked well before. However, today when I ran remove_background function, it gave me error. Does anyone can help me with this problem? Thanks!
zhanxun8
@zhanxun8
image.png
zhanxun8
@zhanxun8
image.png
MurilooMoreira
@MurilooMoreira
Hello everyone, how are you? I saw in the documentation the new option to read the ASW files in the version 1.7dev. I can extract my image spectra frame by frame this way, but I cannot obtain the DF images frame by frame. I am obtaining in the list generated by the hs.load(), only the first DF image used to acquired the spectral image. Is it possible to extract all the DF images acquired? Using the AnalysisStation software I can see them but with Hyperspy I am having problems yet. Thank you!
Thomas Aarholt
@thomasaarholt
Screenshot 2022-01-26 at 14.18.06.png
@MurilooMoreira, I just made a function for you for the colormap you asked for. I thought it was a fun exercise. https://gist.github.com/thomasaarholt/169a1cf29048dd96c8a6c9b980adb9b6
See the gist for creating the cmap. This is how you would use it:
from scipy.misc import face
img = face(gray=True)
plt.figure()
plt.imshow(img, cmap=cmap)
plt.colorbar()
test.png
I was very surprised that there wasn't a built-in function to do this.