// This Procedure contains three Functions: // TransposeWaves(inputWaveNameList, outputBaseName) // KillAllWavesFunc(sWaveListToKill) // FindNoOfSubStrInStringFunc(sStrToFind,sStringToSearch) // TransposeWaves(inputWaveNameList, outputBaseName): // Given a semicolon-separated list (as string) of input wave names (in inputWaveNameList) // TransposeWaves generates a number of output waves such that the output waves // are a transposition of the input waves. A extension 0, 1 etc is appended to outputBaseName. // The waves must have the same length ! // This function needs the functions 'KillAllWavesFunc' and 'FindNoOfSubStrInStringFunc' // Example: TransposeWaves("In0;In1;In2", "Out") // KillAllWavesFunc(sWaveListToKill): // Given a semicolon-seperated list (as string) of input wave names (in sWaveListToKill) // KillAllWavesFunc kills all these waves. // This function needs the function 'FindNoOfSubStrInStringFunc'. // FindNoOfSubStrInStringFunc(sStrToFind,sStringToSearch): // This is a modification of a String or Char replacement function, which simply returns // the number of occurencies of a particular substring (sStrToFind) in another string (sStringToSearch) // All Functions by Matthias Haury (mhaury@pasteur.fr) based on WaveMetrics Functions or Macros FUNCTION TransposeWaves(sInputWaveNameList, sOutputBaseName) String sInputWaveNameList, sOutputBaseName Silent 1; PauseUpdate Variable vPos=0, vNumInputWaves=0, vNumPoints, vLength, vCount, vLimit, vCountIn String sInWave, sOutWave Make/O/N=2000 wTempTP // N = max number of waves to transpose vLength = StrLen(sInputWaveNameList) Do wTempTP[vNumInputWaves] = vPos If (vPos == vLength) // got terminating ";" last time around ? Break Endif vNumInputWaves += 1 vPos = StrSearch(sInputWaveNameList, ";", vPos) + 1 // start of next wave name If (vPos == 0) // no terminating ";" wTempTP[vNumInputWaves] = vLength + 1 Break Endif While (1) If (vNumInputWaves < 2) Abort "Transpose requires at least 2 Waves" Endif sInWave = sInputWaveNameList[0, wTempTP[1]-2 ] Wave wInWave=$sInWave vNumPoints = NumPnts(wInWave) // number of points in first wave vCount=0 // error checking that all are same lenght Do sInWave = sInputWaveNameList[wTempTP[vCount],wTempTP[vCount+1]-2 ] If (NumPnts(wInWave) != vNumPoints) Abort "All waves in Transpose must have the same Length !" Endif vCount+=1 While (vNumInputWaves<=vCount) vCount=0 Do sOutWave = sOutputBaseName+Num2Str(vCount) Make/O/N=(vNumInputWaves) $sOutWave Wave wOutWave=$sOutWave vCountIn=0 Do sInWave = sInputWaveNameList[wTempTP[vCountIn],wTempTP[vCountIn+1]-2 ] Wave wIn2Wave=$sInWave wOutWave[vCountIn] = wIn2Wave[vCount] vCountIn+=1 While (vCountIn