-
Notifications
You must be signed in to change notification settings - Fork 88
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
window function #8
Comments
The exponential window should depend on time, rather than number of points def em_cor(data, lb=0.0, dt=1.0):
apod = np.exp(-lb * (np.arange(data.shape[-1]) * dt))
return apod * data
|
Unfortunately there is no canonical definition of the window functions used in NMR (at least not in my opinion) and each program, spectrometer vendor and even researcher seems to have their own version which they use. For nmrglue I tried to make the the window function in proc_base be
For the exponential window most everyone agrees that this should be of the form exp(- apod = np.exp(-pi * np.arange(data.shape[-1]) * lb) So the @chatcannon added a dt to the em window parameters, this would be more in like the version in NMRPipe and the definition in Hoch and Stern, but introduces an addition parameter and both parameters now have units that are not points (Hz and seconds). I think the single parameter version in nmrglue is simpler. Also it should be noted that the mathematical form of all of the apodization function are given the in the nmrglue reference manual, e.g. Finally it you obtain a similar version of an exponential window like @BrunoVitorge purposed by using the current em function in nmrglue as follows: nmrglue.proc_base.em(data, lb / (data.shape[-1] * 3.1415926)) There is a index mismatch between the above and @BrunoVitorge function, but besides that they are identical. |
Hi guy I can see that you are very reactive, def em_cor(data,lb = 0.0, inv = False):
print 'shape', data.shape[-1]
apod = np.exp(- np.arange(data.shape[-1]) * (lb/(data.shape[-1]-1))).astype(data.dtype)
if inv:
apod = apod[::-1]
return apod * data There is two main differences between nmrglue version and my version: Of course I can use nmrglue function with an modify lb_mod = lb/data.size But now I understand why my lb coefficient was so low and changing in function of the number of points. |
@BrunoVitorge I did not mean for my first comment to come across as reactive, I was trying to provide some background on why the current form of the em window was chosen. I now see more clearly the two differences in your
data_0
data_1 = ng.proc_base.em(data_0, lb=2.0)
data_2 = ng.proc_base.emp(data_1, ln=2.0, inv=True)
# Now data_2 and data_0 should be nearly identical What your are proposing is to apply the reversed window, which is different from the inverse. There are cases in which applying the reversed window would be useful, but it should be an additional parameter, maybe named |
@jjhelmus , thank you for your answer. I apology, if I was offensive in my previous message . I did not find how to make word in bold (I just wanted to emphases what was the difference between your and my version of I was thinking that window function should not depend on the number of points in the fid, but It seems that I'm the only one :-) . After few test, Indeed So I will probably do that now. For the second point about the inverse exponential you are right again, and your suggestion about a "rev" option seems much better than what I proposed. Now I know how to apply an exponential function, next step, base line correction, :-) |
Commit 19b5d90 adds a |
Hello, I think I found a bug at least in the exponential window function.I did not check the others functions.
What I understood about exponential window function is that the last point of the fid should be multiply by the exp(-lb), so if the value of the last point is 1, and lb=5 after the application of exponential window function it value should be 0.006737946999085467
Then for the other points, the coefficient will depend on the number of point and on the point which is considered.
So the coefficient change for each points, for the point i, it will be i*lb/(number of points)
In the Bruker manual "procref" page 80 they also multiply by a "pi/2SWH" but I suppose it is to be consistent with the units.
Also the invert of the exponential should be more change also
Here is the way I programmed it :
I hope my explanation and the code above convinced you, that there is a problem with the window function.
I hope the other functions do not suffer such troubles
I found this bug because the signal to noise was decreasing along the spectrum (1D). And I was processing a fake fid with only 1 (a ones_like(fid)).
Hope this will help.
Thank a lot for the project.
Regards,
Bruno
The text was updated successfully, but these errors were encountered: