You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I tried reading a Bruker NMR file, but somehow I only get a weird spectra:
#%matplotlib inline
import matplotlib.pyplot as plt
import nmrglue as ng
import numpy as np
import scipy as sp
import os
import glob
plt.style.use('ggplot')
print(" ")
class process_nmr:
def getpath(self):
self.filepath = os.path.dirname(os.path.realpath(__file__))
nmr = process_nmr()
nmr.getpath()
d = nmr.filepath
print(d)
path = "./" #Current dir
dirlist = os.listdir(d) #get dirlist
dirlist = list(filter(lambda x : ( x.find(".") == -1 ), dirlist)) #filter files in dirlist
print(dirlist)
root_folder = nmr.filepath
zero_fill_size = 32768
data = [] # <1>
for folder in dirlist:
print(folder)
dic, data = ng.fileio.bruker.read(os.path.join(root_folder,folder))
# remove the digital filter
data = ng.bruker.remove_digital_filter(dic, data)
# process the spectrum
data = ng.proc_base.zf_size(data, 32768) # zero fill to 32768 points
data = ng.proc_base.fft(data) # Fourier transform
data = ng.proc_base.ps(data, p0=-50.0) # phase correction
data = ng.proc_base.di(data) # discard the imaginaries
data = ng.proc_base.rev(data) # reverse the data
fig = plt.figure(figsize=(12,4))
ax = fig.add_subplot(1,1,1)
#ax.plot(np.arange(0, data.shape[0]), data) # <1>
ax.plot(data) # <1>
plt.show()
Apart from the correct phasing, and optionally using a different way remove the digital filter, I find that I can read and process the spectrum correctly using nearly the same script as you.
dic, data = ng.bruker.read("./")
datap = ng.proc_base.em(data, lb=1/dic["acqus"]["SW_h"])
datap = ng.proc_base.fft(data)
datap = ng.bruker.remove_digital_filter(dic, datap, post_proc=True)
datap = ng.proc_autophase.autops(datap, fn='acme', disp=False)
datap = ng.proc_base.rev(datap)
udic = ng.bruker.guess_udic(dic, datap, strip_fake=True)
uc = {i: ng.fileiobase.uc_from_udic(udic, dim=i) for i in range(udic["ndim"])}
fig, ax = plt.subplots(figsize=(8, 2))
ax.plot(uc[0].ppm_scale(), datap.real, linewidth=0.5)
ax.set_ylim(-1e7, 1e8)
ax.set_xlim(4.1, 1.0)
ax.set_title("zoomed in to better see the small peaks", fontsize=12)
plt.show()
Hi, I tried reading a Bruker NMR file, but somehow I only get a weird spectra:
RawData from Bruker
The text was updated successfully, but these errors were encountered: