Linking navigation plots

45 views
Skip to first unread message

Magnus Nord

unread,
Nov 4, 2013, 7:38:16 AM11/4/13
to hypersp...@googlegroups.com
Hey,

when doing spectral imaging using STEM I collect several different kinds of signals (for example EDX and EELS). These signals are saved to different files as spectral images (with the same navigation axes sizes).

In hyperspy I can open the signals and see the spectrum stored in each spectrum image position. Lets say I want to look at both an EDX and an EELS-spectrum image at the same time. If I want to go to a specific navigation position in each spectrum image, I have to manually click that position in both the spectrum image navigators.

Is it possible to link the two plots, so changing the navigation position in one of the plots also automatically changes it in the other plot?

Magnus

Francisco de la Peña

unread,
Nov 4, 2013, 7:42:04 AM11/4/13
to hypersp...@googlegroups.com
I think that you can get what you want by using the e.g. keyword of the plot method e.g.:

>>> s1 = signals.Spectrum(np.random.random((10,20,100)))
>>> s2 = signals.Spectrum(np.random.random((10,20,100)))
>>> s1.plot()
>>> s2.plot(axes_manager=s1.axes_manager)

Does this answer your question?



2013/11/4 Magnus Nord <magn...@gmail.com>

--
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/groups/opt_out.

Magnus Nord

unread,
Nov 4, 2013, 7:58:39 AM11/4/13
to hypersp...@googlegroups.com
Yes, that works nicely. Thanks :)

Should this functionally maybe be rolled into a function for easier access?

For example:
plot_same_navigation(s1,s2,s3,...)
Or with some better name.

Is there some way to combine this with a "regular" image. For example a STEM-ADF image? Where it will just show the navigation "box" in the navigation window?

Magnus

Magnus Nord

unread,
Nov 4, 2013, 9:04:02 AM11/4/13
to hypersp...@googlegroups.com
Hey,

I made a function which does this automatically, so the user only has to specify which spectra should be linked: https://github.com/magnunor/hyperspy/commit/d3eb885cf58e085a4f1f0b0fa96e1cfe9cd8714d

The current name is "plot_same_navigation", I don't know if that is a very good name... Any ideas?
Is utils.py a good place to put it?

Magnus

Pierre Burdet

unread,
Nov 4, 2013, 9:53:11 AM11/4/13
to hypersp...@googlegroups.com
Hi Magnus,

Nice idea. Tools for easy comparison is an important feature to have. I did a similar function to compare images. I use utils.stack to put the images side to side (in a 2D array). The images have then the same contrast (I needed it). Could it be useful for you?

Similarly I did a compare_signal function that given several spectra or several indices compare the signal in one plot. So I have done a compare_image and a compare_signal (and compare_histogram).

It would be nice to put things together in a nice way. Maybe a global utils.compare function that
  1. take a list as input
  2. an argument how to compare. Same navigation (different windows for signal), Same signal (spectrum in the same plot, image side by side), Same histogram.

What do you think?

Magnus Nord

unread,
Dec 5, 2013, 12:46:36 PM12/5/13
to hypersp...@googlegroups.com
Hey,

I'm not certain if putting all that functionally in the same function would be good or bad. I'm thinking it could maybe get a little bit too complex having them all in the same function?

Would it be better to put all of them in the same python file ("compare_signals.py" or "utils_compare.py"?), and give them similar names so it is easy for people to find the functionality they are looking for?

Magnus

Francisco de la Peña

unread,
Dec 6, 2013, 11:20:17 AM12/6/13
to hypersp...@googlegroups.com
Actually, I am a big fan of the plot_spectra function syntax in Magnus' save_to_figure branch. We could add a similar plot_images one. Also, currently plot_spectra only accept single spectra as input. It could be nice to let it accept nd spectra and change update the line in the plot when changing coordinates. Would these two functions be enough to satisfy all your comparison needs?

Francisco


Pierre Burdet

unread,
Dec 9, 2013, 7:51:00 AM12/9/13
to hypersp...@googlegroups.com
I have a look to the plot_spectra, nice one with lot of option. It is the kind of function I need. plot_images and plot_spectra sound good.

Pierre
Reply all
Reply to author
Forward
0 new messages