#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access. #pragma moduleName=normalizer #pragma IgorVersion=8 #pragma version=1.2 // GUI to aid in normalising FTIR spectra to unit thickness. // https://www.wavemetrics.com/user/tony // version 1.2 records info in wavenotes for input and output waves Menu "Macros" Submenu "IR and Raman" "Normalise Spectra...", /Q, normalizer#MakeNormalizeWavesPanel() end end static function MakeNormalizeWavesPanel() DoWindow /K NormPanel NewDataFolder /O root:Packages NewDataFolder /O root:Packages:Normalizer DFREF dfr=root:Packages:Normalizer Make /O/N=(0,3)/T dfr:w_newList /WAVE=w_newList Make /O/W/U/N=(3,5,3) dfr:w_color/WAVE=w_color w_color={{0,0,0},{65535,0,0}} MatrixTranspose w_color Make /O/N=(0,3,3) dfr:w_selection /WAVE=w_selection SetDimLabel 2,1,backColors,w_selection // define plane 1 as background colors Make /O/N=3 /T dfr:w_titles /wave=w_titles w_titles={"input","mm","output"} wave /T w_WaveList=ListToTextWave(WaveList("*",";","DIMS:1"), ";") KillWaves /Z dfr:w_wavelist MoveWave w_wavelist dfr:w_wavelist Make /O/N=(numpnts(w_wavelist)) dfr:w_waveselection /wave=w_waveselection string /G dfr:s_edit="" NewPanel /K=1/N=NormPanel/W=(100,100,950,560) as "Normalize" ModifyPanel /W=NormPanel fixedSize=1 SetDrawLayer UserBack SetDrawEnv fsize= 14 DrawText 25,30,"Choose waves:" SetDrawEnv fsize= 14 DrawText 335,30,"Enter thickness in mm:" ListBox ListBoxWaves,win=NormPanel, pos={20, 40},size={200, 350}, listwave=w_wavelist, selwave=w_waveselection, mode=9 ListBox ListBoxWaves,win=NormPanel, proc=normalizer#normListBox Button ButtonGrabWaves win=NormPanel, pos={250,150},size={50,50},title=">", proc=normalizer#normButtons Button ButtonGrabWaves win=NormPanel, help={"Add selected waves"} Button ButtonReleaseWaves win=NormPanel, pos={250,220},size={50,50},title="<", proc=normalizer#normButtons Button ButtonReleaseWaves win=NormPanel, help={"Remove selected waves"} ListBox ListBoxOut,win=NormPanel, mode=8, selwave=w_selection, titlewave=w_titles, pos={330, 40},size={500, 350}, editstyle=1 ListBox ListBoxOut,win=NormPanel, colorwave=w_color, listwave=w_newList,widths={150,50,150}, fsize=14, proc=normalizer#normListBox Button ButtonDoIt win=NormPanel,pos={780,410},size={50,30},title="Do It", proc=normalizer#normButtons Button ButtonCancel win=NormPanel,pos={700,410},size={60,30},title="Cancel", proc=normalizer#normButtons normUpdateButtonStatus() end // rebuild list of 1D waves in current data folder static function resetWaveList() DFREF dfr=root:Packages:Normalizer wave /T w_wavelist=ListToTextWave(WaveList("*",";","DIMS:1"), ";") Duplicate /O w_wavelist dfr:w_wavelist Redimension /N=(numpnts(w_wavelist)) dfr:w_waveselection end // wrapper for buttons static function normButtons(ba) STRUCT WMButtonAction &ba DFREF dfr=root:Packages:Normalizer wave /T w_wavelist=dfr:w_wavelist wave w_waveselection=dfr:w_waveselection wave /T w_newList=dfr:w_newList wave w_selection=dfr:w_selection wave w_color=dfr:w_color variable i,count if(ba.eventCode!=2) return 0 endif if(stringmatch(ba.ctrlName, "buttonGrabWaves")) count=numpnts(w_wavelist) for (i=0;irowsinwave) // add a wave w_newList[DimSize(w_newList, 0)][]={{w_wavelist[i]},{"0"},{CleanupName(w_wavelist[i]+"_cm",0)}} w_selection[DimSize(w_selection, 0)][]={{0},{2},{2}} normSanityCheck() endif endif endfor normUpdateButtonStatus() elseif(stringmatch(ba.ctrlName, "buttonReleaseWaves")) MatrixOP /free numSelections = sumCols(w_selection) if(numSelections[0]==0) return 0 endif i=DimSize(w_selection,0)-1 do if(w_selection[i][0]) DeletePoints /M=0 i, 1, w_selection, w_newList endif i-=1 while(i>=0) if(DimSize(w_selection,0)==0) // preserve dimensionality of w_selection Redimension /N=(0,3,3) w_selection endif normUpdateButtonStatus() elseif(stringmatch(ba.ctrlName, "buttonDoIt")) count=DimSize(w_newList, 0) for (i=0;i