Advice on figuring out some magic numbers

59 views
Skip to first unread message

Camden Narzt

unread,
Aug 26, 2015, 2:31:02 PM8/26/15
to nmrglue-discuss
I've got a script that I have tacked together which I'm trying to use to measure noise in my fids, I'm testing it against some manually measured values from the same files in Chenomx. But in creating the script there have been some very strange values that I've had to use in places in order to get the scale and position of the data right. Hopefully someone can shed some light on why this is.

specifically I'm wondering about
mult(dic, data, r=7.5E4, inv=True)
and
udic[0]['car'] = 71.01+float(odic['procpar']['rfp1']['values'][0])
and

n_avg/3.18

the first is needed for the y axis scale to be close to the chenomx scale, and the second is needed for the x axis position to be close to the chenomx position (DSS on 0), and the third is correcting for the noise being significantly higher in the nmrglue results (by an average of 3.18x) even once the comound peaks are roughly the right scale.


import nmrglue as ng
import numpy as np
import os
from math import sqrt
import csv

def find_nearest(array,value):
 
return (np.abs(array-value)).argmin()

with open('7000noise.csv', 'wb') as csvfile:
    writer
= csv.writer(csvfile)
    writer
.writerow(['dir', 'romi', 'roma', 'rtmi', 'rtma', 'n_avg/3.18'])
    root
= '/Volumes/Data/7000/'
   
for dir in os.listdir(root):
     
if dir.startswith('7000'):
        odic
,odata = ng.varian.read(os.path.join(root,dir,dir,'data/Metnoesy_01.fid/'))
        udic
= ng.varian.guess_udic(odic,odata)
        udic
[0]['size']     = odata.shape[0] # Dimension size (R|I for last axis, R+I for others)
        udic
[0]['sw']       = float(odic['procpar']['sw']['values'][0])  # Spectral width in Hz.
        udic
[0]['obs']      = float(odic['procpar'][u'sfrq'][u'values'][0]) # Observation frequency in MHz.
        udic
[0]['car']      = 71.01+float(odic['procpar']['rfp1']['values'][0]) # Carrier frequency in Hz.
        udic
[0]['label']    = '1H'
        udic
[0]['complex']  = True
        udic
[0]['encoding'] = 'direct'
        C
= ng.convert.converter()
        C
.from_varian(odic, odata, udic)
        dic
,data = C.to_pipe()
        dic
,data = ng.pipe_proc.zf(dic, data, size=128E3) # Zero fill
        dic
,data = ng.pipe_proc.em(dic, data, 0.5) # line broadening
        dic
,data = ng.pipe_proc.ft(dic, data, auto=True) # Complex Fourier transform.
        data
= ng.proc_autophase.autops(data, 'peak_minima')
        dic
,data = ng.pipe_proc.di(dic, data) # Delete imaginaries
        dic
,data = ng.pipe_proc.mult(dic, data, r=7.5E4, inv=True) # Multiply by a constant
        dic
,data = ng.pipe_proc.med(dic, data) # Median baseline correction
        uc
= ng.pipe.make_uc(dic, data)
        x
= uc.ppm_scale()
        y
= data
        ro
= y[find_nearest(x,0.3):find_nearest(x,0.15)]
        roma
= ro.max()
        romi
= ro.min()
        rt
= y[find_nearest(x,10.4):find_nearest(x,9.4)]
        rtma
= rt.max()
        rtmi
= rt.min()
        n_avg
= ( (roma - romi) + (rtma - rtmi) ) / ( 2.0 * sqrt(2) )
        writer
.writerow([dir, roma, romi, rtma, rtmi, n_avg/3.18])



Jonathan Helmus

unread,
Aug 27, 2015, 3:49:10 PM8/27/15
to nmrglue...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "nmrglue-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nmrglue-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Camden,

    A am not familiar with the Chenomx software but I can take a few guesses at these "magic" numbers. 

The 7.5e4 multiplication performs an overall scaling of the data which is on an arbitrary scale.  One possibility is that a different version of the FFT or apodization function is used in Chenomx when processing.  There are a number of version of the FFT which differ in the sign of the exponent and the overall scaling, see the documentation of nmrglue.process.proc_base.fft for a detailed discussion [1].  If Chenomx uses a version of the FFT that is uses a different scaling then the overall amplitude may change.  It is also possible that different version of the exponential apodization window is used which applies a different overall scaling.  Trying to match amplitudes betweens different software products is quite challenging since this scale is arbitrary, matching the signal-to-noise values of peaks is more reasonable.

The 3.18 in the noise calculation may be an artefact from the non-standard method you are using to calculate noise.  Typically the variance or standard deviation is used as an estimate of the noise, not the difference between the extremes. 

I'm a bit in the dark on the 71.01.  Why you need to add this to the rfp1, which is the reference peak frequency in the indirect dimension, is a bit odd.  Perhaps someone else on the list is more familiar with the how Varian/Agilent referencing works?

Cheers,

    - Jonathan Helmus

[1] http://nmrglue.readthedocs.org/en/latest/reference/generated/nmrglue.process.proc_base.fft.html
Reply all
Reply to author
Forward
0 new messages