Shift traces

From Elsys Wiki - Help and Recources for TranAX and TraNET DAQ
Revision as of 15:35, 12 October 2017 by Tberger (talk | contribs) (Created page with "Category:TranAX Category:FormulaEditor In some cases it useful to have the possibility to shift multiple traces in the time axis. E.g. sliced traces from continuous re...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In some cases it useful to have the possibility to shift multiple traces in the time axis. E.g. sliced traces from continuous recordings or not synchronised traces from multiple devices.

Shift multiple traces in a files

In this example, the *.tpc5 file has be set to Reference 1 (ref1) in the Signal Source Browser. Cursor A marks the current position of the trace (event, spike) and will be shifted to postition of cursor B.

; Shift all traces from a file
; 12.10.2017 Elsys AG / TBE 
; TranAX 4.0 or newer

UseMemory(True)

t1 = GetCrs("Waveform 1","A") ;cursor A current postion
t2 = GetCrs("Waveform 1","B") ;cursor B new position
tshift = t2-t1


; Prepare list with traces and name of traces
nTraces = Length(ref1)
trChnName = Array(0 to nTraces-1) as String
trFileName = List()

; Open each trace, shift, and save it to the list
for n = 0 to nTraces-1 step 1.0 
    tr = File(ref1, n)
    trChnName(n) = GetChName(File(ref1, n))
    tr = Shift(tr, tshift)
    SetVariableValue("trnew" + n, tr)
    trFileName() = GetVariableValue("trnew" + n)
next

; Save all traces into a new File
Save("myNewFile.tpc5", trFileName, trChnName)