-- program to extract the values of gradient strength from a Bruker DOSY experiment -- run this script ONCE to let iNMR process the current spectrum as a DOSY -- no need to run it again in future, because the results are saved into a file called "zeta" gamma = 267524618.573 -- hydrogen gyromagnetic constant local path = pathtofile() last = 1 while true do slash = string.find( path, sys_slash(), last + 1 ) if not slash then break end last = slash end path = string.sub( path, 1, last ) -- path to the folder io.input( path.."acqus" ) local line repeat line = string.sub( io.read("*line"), 1, 5 ) -- delays "d0, d1..." until line == "##$D=" local delay = {} for i=0,20 do delay[i] = io.read("*number") -- unit = seconds end repeat line = string.sub( io.read("*line"), 1, 5 ) -- pulses "p0, p1..." until line == "##$P=" local pulse = {} for i=0,30 do pulse[i] = io.read("*number") -- unit = us (microseconds) end repeat line = io.read("*line") local beginning = string.sub( line, 1, 11 ) -- pulseprogram until beginning == "##$PULPROG=" pulse_program = string.sub( line, string.find(line,"<")+1, string.find(line,">")-1 ) delta = 1e-6 * pulse[30] -- small delta (gradient pulse), in units of seconds if string.find( pulse_program, "bp" ) then delta = 2 * delta end --DELTA = delay[20] - 2e-6*pulse[1] - delta - 2*delay[6] DELTA = delay[20] -- big delta (time for diffusion) local D_d = DELTA - delta / 3 print( "DELTA = ", DELTA ) print( "delta = ", delta ) print( "DELTA' = ", D_d ) print( "gamma = ", gamma ) local dosyconstant = gamma*gamma * delta*delta * D_d print( "dosyconstant = ", dosyconstant ) io.input( path.."difflist" ) -- Bruker file that contains the values of gradient strength G = {} local counter = 0 while true do local found = io.read("*number") -- gradient strength if not found then break end counter = counter + 1 found = found * 0.01 print (found) G[counter] = found end io.output( path.."zeta" ) for i = 1,counter do local x = G[i] io.write( x * x * dosyconstant, "\n" ) -- values required by iNMR (independent variable) end io.close( ) -- closing and saving the output file zeta print (counter, "values extracted and converted")