Пример #1
0
def fromBruker(file, remove_filter=True, read_pdata=True):
    dic, data = bruker.read(file)
    if read_pdata:
        pdata_file = find_pdata(file, data.ndim)

        if (pdata_file is not None):
            procs, data = bruker.read_pdata(pdata_file)
        else:
            read_pdata = False

    if remove_filter and not read_pdata:
        if ng_version > 0.5:
            data = bruker.remove_digital_filter(dic, data, True)
        else:
            data = bruker.remove_digital_filter(dic, data)

    u = bruker.guess_udic(dic, data)
    u["original_format"] = 'Bruker'
    u["Name"] = get_name(file)
    if (read_pdata):
        for i in range(0, data.ndim):
            u[i]['complex'] = False
            u[i]['freq'] = True
            u[i]['time'] = False

    uc = [uc_from_udic(u, dim) for dim in range(0, data.ndim)]

    if read_pdata and 'procs' in procs.keys():
        proc_names = ['procs', 'proc2s']
        for i, uc_i in enumerate(uc[::-1]):
            if procs[proc_names[i]] and procs[proc_names[i]]['OFFSET']:
                uc_i._first = procs[proc_names[i]]['OFFSET']

    return NMRSpectrum(data, udic=u, uc=uc)
Пример #2
0
def fromBruker(file, remove_filter=True, read_pdata=True):
    dic, data = bruker.read(file);
    if read_pdata:
        pdata_file = find_pdata(file, data.ndim)
        
        if(pdata_file is not None):
            procs, data = bruker.read_pdata(pdata_file)
        else: read_pdata = False
    
    if remove_filter and not read_pdata:
        if ng_version > 0.5:
            data = bruker.remove_digital_filter(dic, data, True)
        else:
            data = bruker.remove_digital_filter(dic, data)
    
    u = bruker.guess_udic(dic, data)    
    u["original_format"] = 'Bruker'
    u["Name"] = get_name(file)
    if(read_pdata):
        for i in range(0, data.ndim):
            u[i]['complex'] = False
            u[i]['freq'] = True
            u[i]['time'] = False
    
    uc  = [uc_from_udic(u, dim) for dim in range(0, data.ndim)]
    
    if read_pdata and 'procs' in procs.keys():
        proc_names = ['procs', 'proc2s']
        for i, uc_i in enumerate(uc[::-1]):
            if procs[proc_names[i] ] and procs[proc_names[i] ]['OFFSET']:
                uc_i._first = procs[proc_names[i] ]['OFFSET']
    
    return NMRSpectrum(data, udic=u, uc=uc)
Пример #3
0
 def test_apod_gmb(self):
     spec = fromBruker(self.filename, False, False)
     spec = apod(spec, w=lambda s: GMB(s, 2, 0.5))
     C = converter()
     u = guess_udic(self.dic,self.data)
     C.from_bruker(self.dic, self.data, u)
     
     pipe_dic, pipe_data = C.to_pipe()
     test_data = pipep.gmb(pipe_dic, pipe_data, lb=2, gb=0.5)[1]
     ts.assert_allclose(spec, test_data, 1e-7,1e-3, 'GBM apodization not equal to NMRPipe processed one.')
Пример #4
0
 def test_apod_gm(self):
     spec = fromBruker(self.filename, False, False)
     spec = apod(spec, w=lambda s: GM(s, 1, 10, 5))
     C = converter()
     u = guess_udic(self.dic,self.data)
     C.from_bruker(self.dic, self.data, u)
     
     pipe_dic, pipe_data = C.to_pipe()
     test_data = pipep.gm(pipe_dic, pipe_data, g1=1, g2=10, g3=5)[1]        
     ts.assert_allclose(spec, test_data, 1e-7,1e-3, 'GM apodization not equal to NMRPipe processed one.')
Пример #5
0
 def test_apod_sp(self):
     spec = fromBruker(self.filename, False, False)
     spec = apod(spec, w=lambda s: SP(s, off=0.5, power=2))
     C = converter()
     u = guess_udic(self.dic,self.data)
     C.from_bruker(self.dic, self.data, u)
     
     pipe_dic, pipe_data = C.to_pipe()
     test_data = pipep.sp(pipe_dic, pipe_data, off=0.5, pow=2)[1]        
     ts.assert_allclose(spec, test_data, 1e-7,1e-3, 'SP apodization not equal to NMRPipe processed one.')
Пример #6
0
 def test_apod_jmod(self):
     spec = fromBruker(self.filename, False, False)
     spec = apod(spec, w=lambda s: JMOD(s, 0.5, 5, 1))
     C = converter()
     u = guess_udic(self.dic,self.data)
     C.from_bruker(self.dic, self.data, u)
     
     pipe_dic, pipe_data = C.to_pipe()
     test_data = pipep.jmod(pipe_dic, pipe_data, off=0.5, j=5, lb=1)[1]        
     ts.assert_allclose(spec, test_data, 1e-7,1e-3, 'JMOD apodization not equal to NMRPipe processed one.')
Пример #7
0
 def test_apod_tri(self):
     spec = fromBruker(self.filename, False, False)        
     # Loc < 1 results in dimension reduction of the apodization vector
     with self.assertRaises(NMRShapeError):
         apod(spec, w=lambda s: TRI(s, 0.5, 0.7, 0.5))
     
     spec = fromBruker(self.filename, False, False)
     spec = apod(spec, w=lambda s: TRI(s, 5000, 0.7, 0.5))
     C = converter()
     u = guess_udic(self.dic,self.data)
     C.from_bruker(self.dic, self.data, u)
     
     pipe_dic, pipe_data = C.to_pipe()
     test_data = pipep.tri(pipe_dic, pipe_data, loc=5000, lHi=0.7, rHi=0.5)[1]
     ts.assert_allclose(spec, test_data, 1e-7,1e-3, 'TRI apodization not equal to NMRPipe processed one.')