from __future__ import division import sys import brukerIO import numpy as n import argparse parser = argparse.ArgumentParser(description='Calculate (S0-S)/S0 spectrum from 1D REDOR or RESPDOR with interleaved acquisition') parser.add_argument('inputs', help='Full path of the dataset to process') parser.add_argument('--threshold', '-t', required=True, help='threshold signal below which S0 is not significant') parser.add_argument('--order', '-o', required=False, default='0', help='Order in 2D 0: S0-S / 1: S-S0') args = parser.parse_args() infile = args.inputs threshold = float(args.threshold) order = args.order dat =brukerIO.dataset(brukerIO.splitprocpath(infile)) spect = dat.readspect1d() # print("spectrum shape is ",spect.shape) (si2,) = spect.shape # print("si2=%d" % (si2,)) spect = spect.reshape(si2//2, 2) if order == '0': S0 = spect[:, 0] S = spect[:, 1] elif order == '1': S = spect[:, 0] S0 = spect[:, 1] else: raise("order should be 0 (S0-S) or 1 (S-S0)") for i in range(si2//2): if S0[i] < threshold :
import brukerIO from shutil import copyfile sample = "../data/qcpmg/4/pdata/1/" fresh = "../data/qcpmg/4/" + 'acqu' backup = "../data/qcpmg/4/" + 'acqu.bak' copyfile(backup, fresh) dat = brukerIO.dataset(brukerIO.splitprocpath(sample)) P = [ "P 1", "L 31", "SPNAM 8", "BF1", "NS", "AUNM", "LOCKED", "L 64", "TOTO", ] values = [ 1.5, 5, "test_shape", 180.2, 23, "toto", True, 7, 'bidule',
#SF # autres parameters pour interpreter correctement un processed file #BYTORDP #NC_proc #PPARMOD : dimension 0=1D 1=2D 2=3D... infile = sys.argv[1] infile1D = sys.argv[2] # create 1D processed dataset : # - copy 2D into 1D and adapt proc and procs to 1D #translate filename into bruker dataset components data = brukerIO.splitprocpath(infile) data1D = brukerIO.splitprocpath(infile1D) #initialize dataset dat = brukerIO.dataset(data) dat1D = brukerIO.dataset(data1D) # 2rr is the main file # 2ri or 2ir or 2ii could be the imaginary part depending on MC2 and PH_mod # typically MC2 is QF for popt (hence 2ii file is generated unless PH_mod is ps or mc meaning no imaginary part exists) # for now I only try to read 2ii imaginary file, and don't attempt to read other files (2ri or 2ir) #read 2D 2rr data Fr = "2rr" Fi = "2ii" spect = dat.readspect2d(Fr) try: specti = dat.readspect2d(Fi) except IOError: print("reading 2ii file failed") specti = np.zeros_like(spect)
required=False, type=int, default=0, help='last FID point of refocused echo') parser.add_argument('--tdeff', required=False, type=int, help='only keep tdeff points', default=0) parser.add_argument('infile', help='Full path of the dataset to process') args = parser.parse_args() data = brukerIO.splitprocpath(args.infile) #initialize dataset dat = brukerIO.dataset(data) #read 1D fid file and remove digital filter spect = dat.readfidc(rmGRPDLY=False) digfilt = int(round(dat.getdigfilt())) (td_spectrum, ) = spect.shape # calculate the theoretical td from pulse sequence parameters unless td is provided as argument if args.td: print("limit fid to " + str(args.td), digfilt) td = args.td // 2 - digfilt else: "p13+3.5+d6*2+de*2+d3*2" # delays to consider p13 = dat.readacqpar("P 13") d3 = dat.readacqpar("D 3") * 1e6 d6 = dat.readacqpar("D 6") * 1e6