-- Script to remove Alias shifts from a spectrum in a project. -- User can remove ALL alias shifts, or only those whose spin has a defined label. -- F.Damberger 18.March.2004: script written -- F.Damberger 11.Jan.2005: modified to include dialogs: -- No editing necessary. The script asks the user for the input -- WARNING: always backup your project before you execute the script. -- There is no undo! -- create temporary table to store variables t = {} --1. Get Project local ProjectNames = {} i = 0 for a,b in pairs(cara:getProjects()) do i = i + 1 ProjectNames[ i ] = b:getName() end local ProjectName=dlg.getSymbol("Select Project","", unpack( ProjectNames ) ) t.P = cara:getProject( ProjectName ) -- 2. Get Spectrum to remove Alias shifts from: local SpectrumNames = {} local SpectrumID = {} i = 0 for a,b in pairs( t.P:getSpectra() ) do i = i + 1 SpectrumNames[ i ] = b:getName() SpectrumID[ i ] = b:getId() end local SpectrumName = dlg.getSymbol( "Select Spectrum to remove aliases from", "", unpack( SpectrumNames ) ) for i = 1, table.getn( SpectrumNames ) do if SpectrumNames[ i ] == SpectrumName then t.Spect = t.P:getSpectrum( SpectrumID[ i ] ) end end -- 3. Get optional label of spins whose alias shifts are removed (optional) t.choice = dlg.getSymbol("Do you want to remove all aliases (ALL) or only aliases for specific spins (SOME)?","","ALL", "SOME" ) if t.choice == "SOME" then t.label = dlg.getText("Enter Label of spins whose alias shifts are removed", "", "N" ) end -- look for spins and delete aliases local Num = 0 t.SpinsTable = t.P:getSpins() for a,b in pairs ( t.SpinsTable ) do if b:getShift( t.Spect ) ~= b:getShift() then if t.choice == "SOME" then if b:getLabel()== t.label then t.P:setShift( b,b:getShift(),t.Spect ) Num = Num + 1 end else t.P:setShift( b,b:getShift(),t.Spect ) Num = Num + 1 end -- if choice = SOME end -- if alias exists end -- for all spins -- report results to user if t.choice == "SOME" then print( "\n ------------------ Removing aliases for spins with label: "..t.label.." --------------------" ) else print ( "\nRemoving aliases for all spins" ) end print("\nRemoved "..Num.." aliases from spectrum "..SpectrumName.." in project "..ProjectName) print( "\n -------------------- Script RemoveAliases is finished. ---------------------" ) -- delete temporary table t = nil