-- Script to transfer Alias shifts from one spectrum to another -- F.Damberger 18.March.2004 -- Ver.2 -- F.Damberger 17.Oct.2005 -- modified: -- If a spin alias exists in the target spectrum with the same shift as -- a spin alias in the source spectrum, no alias is created. -- This change was made because of a bug in CARA which deletes the alias -- shift in the target spectrum. --Options: -- 1. You can set t.Filter="YES" to only copy aliases for spins -- with a specified label t.Label -- 2. You can set t.Overwrite="NO" to only overwrite shifts when -- no alias exists for the targetspectrum. -- WARNING: always back-up repository before executing script -- To undo - use the script RemoveAliases.lua -- create table for LUA script (all script variables are t.something) t={} -- Below are variables for User to modify: -- ---------------------------------------------------------------- -- 1. The Project you want to modify aliases in: t.ProjectName="projectname" -- 2. ID number of Spectrum to get Alias shifts from: t.SourceSpectrumId = "1" -- 3. ID number of Spectrum to copy Alias shifts to: t.TargetSpectrumId = "2" -- 4. Flag to turn ON/OFF filter for LABELS t.Filter="NO" -- 5. Label of spins whose alias shifts are transferred -- (optional: set filter = "YES" in step 4) t.Label = "N" -- 6. Flag to overwrite possibly existing aliases -- (optional: set to YES to force overwrite of existing aliases) t.Overwrite="NO" -- ---------------------------------------------------------------- -- get Project t.Project = cara:getProject( t.ProjectName ) -- get spectra t.SourceSpectrum = t.Project:getSpectrum( t.SourceSpectrumId ) t.TargetSpectrum = t.Project:getSpectrum( t.TargetSpectrumId ) local i=0 t.SpinsTable=t.Project:getSpins() for SpinId,Spin in pairs ( t.SpinsTable ) do if Spin:getShift( t.SourceSpectrum ) ~= Spin:getShift() then if not ( ( t.Overwrite=="NO" ) and ( Spin:getShift( t.TargetSpectrum )~= Spin:getShift() ) ) then if t.Filter=="YES" then if Spin:getLabel() == t.Label then --the following if is needed due to CARA bug if Spin:getShift( t.SourceSpectrum ) ~= Spin:getShift( t.TargetSpectrum ) then t.Project:setShift( Spin, Spin:getShift( t.SourceSpectrum ), t.TargetSpectrum ) i = i+1 end end else --the following if is needed due to CARA bug if Spin:getShift( t.SourceSpectrum ) ~= Spin:getShift( t.TargetSpectrum ) then t.Project:setShift( Spin, Spin:getShift( t.SourceSpectrum ), t.TargetSpectrum ) i = i+1 end end -- if Filter == "YES" end -- if Overwrite end -- copy only if alias exists for SourceSpectrum end -- for all Spins if t.Filter == "YES" then print("Only copying spins with label "..t.Label..".") end if t.Overwrite == "YES" then print("Overwriting existing aliases shifts in target spectrum.") else print("Existing aliases in target spectrum are not changed.") end print("Copied "..i.." aliases") print("CopyAliases is done") --free up script variables t = nil