-
Notifications
You must be signed in to change notification settings - Fork 17
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
Slicing TransientSpec #204
Comments
This touch on the fact that the To fix this, here are two options:
The first option defies the hyperspy signal paradigm and I suspect that this will be very messy. The second is clean and simple. |
Well, the issue is that TransientSpec basically inherits from two different Signal1D classes for the two axes and HyperSpy so far does not support two different signal types for a single object. A third (and my prefered) solution would be to expand the HyperSpy signal paradigm and allow for something like The issue is that neither the energy/wavelength nor the time axis should be a navigation axis. We can have linescans or maps of both types of 1DSignals, as well as of this 2DSignal and I would find it even more confusing to then add a non spatial dimensionality to navigation. The essence is that this type of signal is a new use case that so far was not covered by hyperspy. If a signal had multiple signal dimensions, these were always of the same type. |
This is usual to have non spatial dimension as navigation dimension, these can be time, stage tilt, energy (for example energy filtered TEM), angular dependence of diffraction pattern, etc.
The motivation behind the core concept of splitting dimensions between navigation and signal dimension is to be able to naturally operate on the signal dimension and map it to all (or a subset of the) navigation axes and vice versa for operation applied on navigation axes. When there is something special to do about a specific axis, this can be customised using transpose, etc. - see for example, the in situ diffraction data (pyxem/pyxem#900), where time correlation analysis has been implemented. @CSSFrancis may be able to comment more on this. Maybe it would be useful to have an example of operations that needs to operate on several signal axes of different signal type to justify having together in the signal space? |
There is a number of reasons, why I would like to have both as signal axes (and why it is not comparable to a stage tilt or angular dependence series):
As a consequence, the two axes are of equal relevance and I do not see which of the two should become the navigation and which the signal axis. Probably the most common use case will be that people use slicing to reduce the image to either time or wavelength dimensions by integrating over certain intervals of the other axis and then model the 1D data. However, doing so both ways for the same image! Changing the hyperspy paradigm and allowing different Writing wrappers in |
Point 1 to 3 seems fine to me (or will need small changes) using current hyperspy. Having navigation axes with different type (spatial, time, etc.) is usual.
One way to addressed this is by being explicit and documenting how to convert from one to another and what does it mean for visualisation and processing. |
A Gaussian2D would not be appropriate for the type of data - but so far I am not aware of anyone actually modeling that in both dimensions. Instead, it is common to model and plot individual slices (at different times or different wavelength ranges) to evaluate the evolution of the data. |
@jlaehne This is an interesting point. My opinion on this is strongly correlated with performance of the map function. Where the signal axes should be the ones you are actively operating on and navigation axes should be everything else. In this case it seems like you might have two signals with one being the transpose of the other if you want to operate on both separately. If you want to do as @ericpre suggests fitting a 2D function to a 2D image actually sounds like it would be an interesting thing to try. What about supporting convolving 1D models to create 2D models? In the long run we could make the map function operate on any axes but I would still use that as an exception rather than the rule. |
In 0d2c439 (#205), I have now implemented the following:
This way, all functions reducing the dimensionality seem to work correctly (just have to add the formal tests). However, having a
@CSSFrancis do you have an idea how to fix that behaviour? |
@jlaehne hmmm. So the I had plans for allowing the axes and signal type to be set with the map function but never got around to it. Currently we just have lots of code that just resets the axes and signal type after the map function. |
I could of course just set the signal type explicitly in Alternatively, I guess I could go back to having the 2D signal type |
This works (9b54af6), and it seems a decent solution! The only downside is that I have to register this additional class |
Would be allowed with hyperspy/hyperspy#3302 by defining an optional, additional key |
I really think that having a 2D signal with two different type of signal (here: time and energy) is what cause the issue/confusion here. As discussed above, there isn't any processing where this mixed signal is necessary. On top of that, some of the What is the issue with using a 1D signal (with either time or energy/wavelength as signal dimension) and transposing when necessary at the workflow level? |
Well, the first thing one usually does with the data is to plot it for visualization and the expected way to look at the streak camera data is an image with a time and a wavelength axis. For linescans and maps I would then expect a navigator that allows me to go through the different images. That is why I would want the 2D-signal as primary object. Besides the plotting, I do not see any of the two axes as "preferred" signal axis to which the object should be initialized. Instead, in the analysis one usually does certain operations on the one and certain operations on the other axis. Thus, when wanting to operate on one of the signal axes, one could transpose to a single signal axis, e.g. by With the current implementation, transposing to either of the signal axes, as well as using any dimensionality reducing command such as |
It should be possible to do that by improving the plotting, particularly with hyperspy/hyperspy#3199.
Yes, but at some point, I would imagine that you need to make that decision to process the data, as there is no processing that you can do when the data is in that 2D signal structure?
Yes, but it breaks some of the basic usage of I think that there is a solution which doesn't break |
@gkusch, @Attolight-NTappy you have quite some experience working with streak camera data, so it would be interesting to get your oppinion here. |
Hi everyone, happy to give my opinion. I am of @ericpre 's opinion that import hyperspy.api as hs
s = hs.load("Streakmap_P4_-1-0_-1-0.hspy")
"""Casting into TransientSpec"""
s.set_signal_type('TransientSpec')
s
# <LumiTransientSpectrum, title: , dimensions: (|672, 508)>
"""Summed signal casting into desired signal type"""
s2 = s.sum(0)
s2.set_signal_type('Transient')
s2
# <LumiTransient, title: , dimensions: (|508)> Why should anything be changed to save a benign call to Additionally, there is currently no functionality implemented in I also think that most time-resolved spectra are primarily treated as a succession of spectra during analysis and do not require functionality from |
It would be good to make sure things there are working with this case? I think you are right that is the best solution. |
@CSSFrancis continuing on the previous example import hyperspy.api as hs
s = hs.load("Streakmap_P4_-1-0_-1-0.hspy")
s.set_signal_type('TransientSpec')
s.as_signal1D(0).plot() already yields a map as a navigator, see below: don't understand what is the desired change in behaviour. Cheers Nicolas |
@Attolight-NTappy that is a single streak dataset for one position correct? If you wanted to visualize a 2-d map of streaks you would want a map of intensity in real space and then the set of streaks at each position. Correct? I've never done any of these experiments so I'm not really sure what I'm looking at 😅 |
Absolutely.
Yes. Depending on how the data dimensions are arranged between navigation and signal spaces, you would need to use Not sure how common 2d-scans of streak maps are, but that's an entirely different question ;] |
Thanks everyone for the thoughts, trying to get back into the discussion: Even if measurement time surely limits their frequent occurence, 1d and 2d scans of streak camera images should be covered - after all efficiently working with these types of multidimensional data is exactly what HyperSpy is for. Of course, current functionality of classes like For The main point with streak camera images is that the time and wavelength axes are somewhat of equal importance. It is not simply a stack of spectra at different times, but at the same time a series of transients at different wavelengths. In an analysis, one will often not only look at either of the two, but from the same dataset extract both spectra integrated over a certain range of times, as well as transients over a certain spectral range. One could for example track the position in wavelength of a peak over time, while also looking at the lifetimes extracted from the transients as a function of wavelength. With a Therefore, I still see the two axes as equally important, and choosing one as the primary signal axis and the other as a navigation axis seems somewhat arbitrary to me. And was, besides for visualization, a reason for me to go for the implementation of the Looking at the analysis in the zenodo repo shared by @Attolight-NTappy above, it does indeed do exactly the same as proposed here, first work with the streak image as |
When slicing, summing, integrating signals of type
TransientSpec
, the resulting signal will be aSignal1D
. It would be desirable to obtain signals of typeTransient
orLuminescence
depending on what axis the function operates on.The text was updated successfully, but these errors were encountered: