program choppa; var wid,twid,sets,specs,points,rws,i,x,y,c,nullpunkt,str,nd,pl,sou,scwid,n : integer; var offset,max: real; var filos,tmp,name_set,formulos : string; procedure OpenNewWindow(x); begin NumberToString(x+1, tmp, 1, 0); name_set := filos + ' Set '+ tmp; NewDataWindow(nrRows rws, name name_set, info tmp); twid := FrontmostWindow(datatype); end; procedure GetTimeBase(x); begin nullpunkt := x*specs*points; SelectWindow(wid); SetCurrentWindow(wid); SelectCell(fromRow nullpunkt+1, toRow nullpunkt+points, col 1); DoMenu('Edit:Copy'); SelectWindow(twid); SetCurrentWindow(twid); SelectCell(fromRow 1, toRow 51, col 2); DoMenu('Edit:Paste'); SelectColumn(col 1); c:=x*specs*pl; NumberToString(c, tmp, 1, 0); tmp := 'c2-' + tmp; Transform(window twid, operation formulaOp, xColumn 0, yColumn 1, formula tmp, makePermanent false); SetColumnProperties(col 1, name 'Time [s]'); end; procedure CopySingleSpectrum(x,twid); begin nullpunkt := x*specs*points; i:= 0; repeat str := nullpunkt+i*points+1; nd := nullpunkt+i*points+points; SelectWindow(wid); SetCurrentWindow(wid); SelectCell(fromRow str, toRow nd, col sou); DoMenu('Edit:Copy'); SelectWindow(twid); SetCurrentWindow(twid); SelectCell(fromRow 1, toRow 51, col i+2); DoMenu('Edit:Paste'); i:=i+1; until i>=specs; SetColumnProperties(col 1, name 'Time [s]'); end; procedure AddEmptyRows(x,twid); {Frameshift over 8 Datapoints} begin for i:=15 downto 8 do {Data to spread are in line 8-15} begin InsertRows(window twid, at i+1, count 3-x); InsertRows(window twid, at i, count x); end; end; procedure LazyAverage(twid); begin InsertColumns(window twid, at 2, count 2); Transform(window twid, operation formulaOp, xColumn 0, yColumn 3, formula '(c4+c5+c6)/3', makePermanent true); tmp := name_set + ' (av)'; SetColumnProperties(col 3, name tmp); end; procedure LazyNormalize(twid); {Col was already at LazyAverage inserted - coz otherwise it went crazy } begin SelectWindow(twid); SetCurrentWindow(twid); SelectRow(fromRow 1, toRow 7); Fit(window twid, function 'lIn3ar', algorithm levenberg, xColumn 1, yColumn 3, selRowsOnly true, printResults false); offset:=GetResult(fittedParameter, 1); NumberToString(offset, tmp, 0, 7); formulos := '(c3 - (' + tmp + '))'; {Normalize by t=4sec - t= 5sec } { SelectRow(fromRow 40, toRow 50); Statistics(window twid, column 3, withMedian false, withSkew false, selRowsOnly true, printResults false); max := GetResult(statMean); NumberToString(max, tmp, 0, 7); formulos := formulos + '/' + tmp; writeln(x+1, ' ', max); } SelectColumn(col 2); Transform(window twid, operation formulaOp, xColumn 0, yColumn 2, formula formulos, makePermanent false); SetDefaultCols(1,2,0,0); tmp := name_set + '.(av&z)'; SetColumnProperties(col 2, name tmp); DoMenu('Edit:Copy'); end; procedure PasteOverCollecta(x,scwid); begin SelectWindow(scwid); SetCurrentWindow(scwid); SelectColumn(col x+3); DoMenu('Edit:Paste'); end; procedure AddPoints(scwid); begin x:=0; n:=8; SelectWindow(scwid); SetCurrentWindow(scwid); repeat for y:=1 to 4 do begin SelectCell(row n, col y+2); Copy; for i:=1 to 4 do {increasing for loop} begin SelectCell(row n, col i+2); Paste; end; n:=n+1; end; x:=x+1; until x>7; end; procedure AverageSCWID; begin SetColumnProperties(col 2, name filos+'.av'); Transform(window scwid, operation formulaOp, xColumn 0, yColumn 2, formula '(c3+c4+c5+c6)/4', makePermanent false); SetDefaultCols(1,2,0,0); end; procedure DoubleSlowPts; begin SelectRow(fromRow 40, toRow 75); Copy; SelectRow(row 76); Paste; SelectRow(fromRow 8, toRow 111); end; begin {----------> MAIN <----------} writeln('==[Choppa V1.0]================='); wid := GetCurrentWindow(datatype); i := YColumn; filos := GetColumnProperty(i, name); x:= 0; twid:=0; {Delete pre-defined vars -->} sets:=4;specs:=3;points:=51;pl:=40; SetBoxTitle('Series-Sets-Specs-Points?'); Input('Which column', sou, 'How many Sets',sets,'How many Specs/Set?',specs,'How many points/spec?',points, 'Peroidlenght [s] ?', pl); {Counting DataRows and check input} Statistics(window wid, column 1); rws:= GetResult(statCount); {Checking input} if points*specs*sets <> rws then begin Alert('Dude! - Data imput type mismatch. Selecting your first spectra and exiting'); SelectRow(fromRow 0, toRow points); exit; end; {Preparing collecta window} if scwid = 0 then begin NewDataWindow; scwid := FrontmostWindow(datatype); end; tmp := 'merged Collecta window - SAVE ME!'; SetWindowProperties(window scwid, name tmp); SetWindowProperties(window scwid, boundsLeft 704, boundsTop 394, boundsRight 1262, boundsBottom 723); {Looping over sets} repeat OpenNewWindow(x); GetTimeBase(x); CopySingleSpectrum(x,twid); AddEmptyRows(x,twid); LazyAverage(twid); LazyNormalize(twid); PasteOverCollecta(x,scwid); CloseWindow(window twid, saveOption dontSave); x:=x+1; until x>=sets; AddPoints(scwid); AverageSCWID; DoubleSlowPts; SaveWindow(window scwid, file '/Volumes/Users/fu/Documents/_2002 - 2005 Saclay Doktorarbeit/Kinetix/zzz_working/'+ filos); end;