-
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
Support for Spinsolve Files? #146
Comments
Are there example Spinsolve files and/or documentation on the format available. |
I've attached some of the documentation provided by the software as well as two data examples, one from Spinsolve and one from Spinsolve Expert (although I believe they are very similar in structure, if not completely the same). If you want the full documentation or have questions about the data format I suggest writing to Magritek (the company that distributes the software as well as the spectrometers). |
I am working this out at the moment as I was stumbling on the same problem for our spinsolve device. I found the answer in this thread. The issue is that reading the FID (dic,data = ng.jcampdx.read...) creates an array containing 2 arrays with either the real or imaginary data instead of a normal 'data' object. Therefore, doing the normal things like fourier transformation or listing all the real points with 'data.real', are not working properly. See here the solution for Spinsolve data:
|
This question is actually a duplicate of this closed issue. |
@LCageman's solution works perfectly if there is a |
@mobecks and @NichVC , thanks for sharing the documentation. Based on these, I think we will need functions specific to def read(fpath, fname):
with open(os.path.join(fpath, fname), "rb") as f:
data_raw = f.read()
dic = {"spectrum": {}, "acqu": {}, "proc":{}}
keys = ["owner", "format", "version", "dataType", "xDim", "yDim", "zDim", "qDim"]
for i, k in enumerate(keys):
start = i * 4
end = start + 4
value = int.from_bytes( data_raw[start:end], "little")
dic["spectrum"][k] = value
data = np.frombuffer(data_raw[end:], "<f")
split = data.shape[-1] // 3
xscale = data[0 : split]
dic["spectrum"]["xaxis"] = xscale
data = data[split : : 2] + 1j * data[split + 1 : : 2]
with open(os.path.join(fpath, "acqu.par"), "r") as f:
info = f.readlines()
for line in info:
line = line.replace("\n", "")
k, v = line.split("=")
dic["acqu"][k.strip()] = v.strip()
with open(os.path.join(fpath, "proc.par"), "r") as f:
info = f.readlines()
for line in info:
line = line.replace("\n", "")
k, v = line.split("=")
dic["proc"][k.strip()] = v.strip()
return dic, data I suggest that this function be used instead of the one described in #117 (since that was just a hack, without knowing the exact file structure). With this, you can read the "Expert" files in the following manner: dic, data = read(path, "spectrum.1d") # or, read(path, "fid.1d")
fig, ax = plt.subplots()
ax.plot(dic["spectrum"]["xaxis"], data.real) Similar functions can be made to read in the ".pt" files as well. Before we put the above function in nmrglue, some additional things need to be done: (1) Most of the values in |
I wrote something that can use the function of @kaustubhmote (thanks!) and export the processed spectrum with one the 4 possible files given by the Spinsolve software (data.1d, fid.1d, spectrum.1d and spectrum_processed.1d). Note that data.1d and fid.1d are the raw FIDs, so they need a Fourier transform. Also the plotting depends on whether the raw data or processed data is read.
Also, there are some differences in the files between the expert software and normal software. Different parameters are stored in "acqu.par" and the expert software has the .pt1 files and a proc.par. All of the acqu parameters used in the script above are present in both versions of "acqu.par". @kaustubhmote, As proc.par is only present in the expert software, I suggest to make this part optional in the read function:
I am new to NMRGlue and Github, but would love to see a spinsolve module. Let me know if I can be of help. |
@LCageman , I'll be happy to review and add to any PRs you submit. My suggestion would be to start with a simple |
I created the read and guess_udic for spinsolve data, as mentioned in issue jjhelmus#146. The read function will work on a directory and a filename can be specified, otherwise the standard names are tried. When I compared to other fileio scripts I realized that I put everything into one function instead of using smaller functions. I can still do this for a next iteration. I also use the fileio/jcampdx.py script here to read the (optional) .dx file, I'm not sure if that is preferred or if it's better to copy (only) the necessary code here. guess_udic uses acqu.par file parameters (should be always present), otherwise the .dx file header parameters are used (only when using the .dx file)
Hello, is it possible to add a function writing NMR files of spinsolve or convert it to other file format? |
You can convert spinsolve files to other formats via the dic, data = ng.spinsolve.read(".")
udic = ng.spinsolve.guess_udic(dic, data)
C = ng.convert.converter()
C.from_universal(udic, data)
dic_pipe, data_pipe = C.to_pipe()
ng.pipe.write(dic_pipe, dic_data)
# dic_bruker, data_bruker = C.to_bruker()
# ng.bruker.write(dic_bruker, dic_bruker) You cannot convert other formats to spinsolve as of now, but this should not be a hard thing to add. |
Is there any plans for support of Spinsolve files in the future? (From Magritek Spinsolve Spectrometers, either Spinsolve or Spinsolve Expert software).
Sorry in advance if this is not the right place to ask this question, but I didn't know where else to go.
The text was updated successfully, but these errors were encountered: