nmrpy icon indicating copy to clipboard operation
nmrpy copied to clipboard

How to import multiple Bruker 1D spectra

Open Ricmelis80 opened this issue 2 years ago • 8 comments

Hi, I triead reading and processing multiple raw 1D Bruker NMR spectra with NMRpy. Bruker fids are orinally located in specific subfolders es "1" (i.e the original Topspin EXPNO number) , For more clarity I have attached a zip files containing the data structure of the original root folder nmr.zip.

How I can process and display them? Thank you in advance!

Ricmelis80 avatar Sep 12 '23 13:09 Ricmelis80

If you want to just load them individually, you specify the path up to the folder below the exp no subfolders (1/2/3). I.e. in your case:

fid_array_1 = nmrpy.from_path('root_folder/P_1')
fid_array_2 = nmrpy.from_path('root_folder/P_2')
fid_array_3 = nmrpy.from_path('root_folder/P_3')

Then each FID array will only contain one spectrum. If you want to load all the spectra into a single FID array, NMRPy expects a different folder structure where the experiment subfolders are located all imediately below the root folder, e.g.

root_folder/1
           /2
           /3

So you'd have to move the various "1" folders from P_1, P_2, P_3 to the root folder and rename them in sequence. In my experience Topspin saves these experiments like this automatically when queuing a number of experiments as in a time series.

Then you can simply do:

fid_array = nmrpy.from_path('root_folder')

and the FID array will contain all three spectra.

Hope this helps.

jmrohwer avatar Sep 15 '23 15:09 jmrohwer

Hi Johann,

Thanks a lot for useful suggestions! I'll try to implement it

Ricmelis80 avatar Sep 18 '23 08:09 Ricmelis80

Can this issue be closed?

jmrohwer avatar Sep 26 '23 07:09 jmrohwer

Hi, I kind of have the same issue, but my experiment folders with different numbers are in the same root folder as they have been generated by Topspin. When I try to import all the fid data into one FidArray, I receive the error message: "fid_path does not specify a valid .fid directory." I only can import fid data if the root folder contains one experiment folder only. Any suggestions?

AdriennR avatar Oct 27 '23 09:10 AdriennR

Hy,

Sorry, I'm totally forget to close this iussue. I have implemented the author's suggestion and it works well!

Ricmelis80 avatar Oct 27 '23 12:10 Ricmelis80

Hi, Interesting. It does not work for me though. :(

AdriennR avatar Oct 27 '23 12:10 AdriennR

Hi, I kind of have the same issue, but my experiment folders with different numbers are in the same root folder as they have been generated by Topspin. When I try to import all the fid data into one FidArray, I receive the error message: "fid_path does not specify a valid .fid directory." I only can import fid data if the root folder contains one experiment folder only. Any suggestions?

Can you post the directory tree structure of your files? In the nmrpy install directory (under site-packages) there is some example test Bruker data, the structure looks like this:

tests/test_data/bruker2
├── 1
│   ├── WS_FTP.LOG
│   ├── acqu
│   ├── acqum
│   ├── acqums
│   ├── acqus
│   ├── cpdprg2
│   ├── fid
│   ├── format.temp
│   ├── pdata
│   │   └── 1
│   │       ├── 1i
│   │       ├── 1r
│   │       ├── WS_FTP.LOG
│   │       ├── meta
│   │       ├── meta.ext
│   │       ├── outd
│   │       ├── proc
│   │       └── procs
│   ├── pulseprogram
│   └── scon
├── 2
│   ├── WS_FTP.LOG
│   ├── acqu
│   ├── acqum
│   ├── acqums
│   ├── acqus
│   ├── cpdprg2
│   ├── fid
│   ├── format.temp
│   ├── pdata
│   │   └── 1
│   │       ├── 1i
│   │       ├── 1r
│   │       ├── WS_FTP.LOG
│   │       ├── meta
│   │       ├── meta.ext
│   │       ├── outd
│   │       ├── proc
│   │       └── procs
│   ├── pulseprogram
│   └── scon
├── 3
│   ├── WS_FTP.LOG
│   ├── acqu
│   ├── acqum
│   ├── acqums
│   ├── acqus
│   ├── cpdprg2
│   ├── fid
│   ├── format.temp
│   ├── pdata
│   │   └── 1
│   │       ├── 1i
│   │       ├── 1r
│   │       ├── WS_FTP.LOG
│   │       ├── meta
│   │       ├── meta.ext
│   │       ├── outd
│   │       ├── proc
│   │       └── procs
│   ├── pulseprogram
│   └── scon
...
...

You would import that with fid_array = nmrpy.from_path('tests/test_data/bruker2') (obviously you have to specify this relative to the current directory). The individual experiment folders are 1, 2, 3, ... under "bruker2" which is the root folder.

jmrohwer avatar Oct 30 '23 18:10 jmrohwer

Yes, I first tried with the bruker2 experimental files. If I did that, it told me that there are only 3 fid files that can be imported (instead of the 20 ones present in the bruker2 folder's subfolders).

Then I also tried with my files, and it has written the error message OSError: Data could not be imported.. My command: fid_array = nmrpy.from_path('/Users/User/Desktop/doktori/Lyon-Strassbourg/NMR/DNP/Measuremens/20230228_LNP_C2')

cd /Users/User/Desktop/doktori/Lyon-Strassbourg/NMR/DNP/Measuremens/20230228_LNP_C2 tree . |____11 | |____uxnmr.par | |____format.ased | |____pulseprogram | |____format.temp | |____audita.txt | |____spnam0 | |____pdata | | |____1 | | | |____proc | | | |____title | | | |____auditp.txt | | | |____assocs | | | |____1r | | | |____1i | | | |____procs | | | |____outd | | | |____thumb.png | |____cpdprg2 | |____fid | |____shimvalues | |____uxnmr.info | |____scon2 | |____acqu | |____acqus | |____specpar

|____1 | |____uxnmr.par | |____popt.protocol | |____format.ased | |pulseprogram | |.DS_Store | |____format.temp | |____audita.txt | |____pdata | | |____999 | | | |____proc | | | |____title | | | |____auditp.txt | | | |____1r | | | |____1i | | | |____procs | | | |____outd | | | |____used_from | | | |thumb.png | | |.DS_Store | | |____1 | | | |____proc | | | |____title | | | |____auditp.txt | | | |____assocs | | | |____1r | | | |____1i | | | |____procs | | | |____outd | | | |____thumb.png | |____popt.array | |____fq1list | |____fid | |____popt.protocol.999 | |____shimvalues | |____uxnmr.info | |____scon2 | |____acqu | |____acqus | |____specpar |____10

| |____uxnmr.par | |____pulseprogram | |____format.temp | |____audita.txt | |____pdata | | |____1 | | | |____proc | | | |____title | | | |____auditp.txt | | | |____assocs | | | |____1r | | | |____1i | | | |____procs | | | |____outd | | | |____thumb.png | |____fq1list | |____fid | |____shimvalues | |____uxnmr.info | |____scon2 | |____acqu | |____acqus | |____specpar

|____12 | |____uxnmr.par | |____format.ased | |____pulseprogram | |____format.temp | |____audita.txt | |____pdata | | |____1 | | | |____proc | | | |____title | | | |____auditp.txt | | | |____1r | | | |____1i | | | |____procs | | | |____outd | | | |____thumb.png | |____fid | |____shimvalues | |____uxnmr.info | |____scon2 | |____acqu | |____acqus | |____specpar

|____2 | |____uxnmr.par | |____format.ased | |____pulseprogram | |____format.temp | |____audita.txt | |____spnam0 | |____pdata | | |____1 | | | |____proc | | | |____title | | | |____auditp.txt | | | |____1r | | | |____1i | | | |____procs | | | |____outd | | | |____thumb.png | |____cpdprg2 | |____fq1list | |____shimvalues | |____uxnmr.info | |____scon2 | |____acqu | |____acqus | |____specpar

|____13 | |____uxnmr.par | |____popt.protocol | |____format.ased | |____pulseprogram | |____format.temp | |____audita.txt | |____spnam0 | |____pdata | | |____999 | | | |____proc | | | |____title | | | |____auditp.txt | | | |____assocs | | | |____1r | | | |____1i | | | |____procs | | | |____outd | | | |____used_from | | | |____thumb.png | | |____1 | | | |____proc | | | |____title | | | |____auditp.txt | | | |____assocs | | | |____1r | | | |____1i | | | |____procs | | | |____outd | | | |____thumb.png | |____cpdprg2 | |____popt.array | |____fid | |____popt.protocol.999 | |____shimvalues | |____uxnmr.info | |____scon2 | |____acqu | |____acqus | |____specpar ...

AdriennR avatar Nov 02 '23 08:11 AdriennR