ScienceSoft, LLC
www.ScienceSoft.net
TOC PREV NEXT INDEX


CHAPTER 6: Automated Shimming Example

The biggest challenge for manual and automated shimming alike is to shim a magnet starting without knowing initial shim values. Using a 300 MHz Varian UNITY spectrometer with an NCC Z*Spec probe this shimming example demonstrates how ShimIt can shim such a magnet in less than an hour starting from all shim values set to zero. The examples were run using a Sun SPARC II computer. The speed of ShimIt is compute limited and faster workstations obtain a significant speed-up. Experienced spectroscopists typically need at least a day to shim a magnet from scratch.

Currently the phasing module of ShimIt assumes that the signal in both the real and imaginary part of the displayed spectrum arises from the resonance to be optimized. So the shimming should be based on an isolated line in the spectrum.1 Another requirement for fast shimming is a short relaxation time of the observed resonance to avoid an excessive sample saturation. For the following example a plain water sample is used.

ShimIt contains a software lock which shifts the position of the analysis region in the acquired spectrum to compensate for resonance frequency shifts between FIDs. Therefore, the Vari autolock should be set to off. Even for samples which (in contrast to the water sample used) contain a lock substance the Varian autolock mechanisms should normally be turned off, at least during coarse shimming. The danger of using Varian's autolock is that when the lock signal is lost during the auto-shimming the lock mechanism wildly changes the field to search for the lock signal - even if an acquisition is in progress. ShimIt performs the software locking whether or not the spectrometer locking system is active.

For the UNITY-300 spectrometer used for this example the spectrum of the proton lineshape sample with all shims set to zero and no locking or sample spinning looks as follows:


Even though the shimming will only be based on the center resonance, the acquired spectral width should be chosen wider. For speed reasons ShimIt performs locking not by adjusting z0 but by shifting the analysis window over the acquired spectrum to compensate for constant offsets in impure shims.2 On the other hand the acquired spectral width should only be chosen as large as necessary. During a ShimIt run a large number of FIDs are acquired and a large spectral width has to be digitized by a large number of points which slows down the Fast Fourier Transform (FFT) of the FIDs.

The next step in preparation of the autoshimming is to reduce the displayed spectral region to be analyzed for the auto-shimming. The goal here is to include the signal and its tails but hardly any baseline. For this example the chosen area is:


Admittedly, the chosen spectral range does not completely include the signal tails as assumed for the mathematical derivation of the method. However, ShimIt was found to be very forgiving in this regard.

The ShimIt analysis parameters can now be set from the ShimIt menus and the shimming process can be started using menu buttons as discussed in previous chapters. However, the complete shimming of the room temperature shims from scratch involves several steps with increasing spectral resolution and some steps should be performed with a spinning sample and others without sample spinning. This general process can be done conveniently using macros instead of the menu buttons. In this chapter the parameters for the auto-shimming are set from a series of MAGICAL macros. Besides convenience there is no difference between issuing the commands manually vs. issuing them from macros.

The series of macros is started using the shimit_all command. The shimit_all macro optimizes all shims using a non-spinning sample as described in SECTION 6.1: "Optimization Of All Shims". On completion of the shimit_all macro the shimit_z macro starts and optimizes the z shims using sample spinning as described in SECTION 6.2: "Optimization Of Spinning (z) Shims". After shimit_z the shimit_non_z macro starts and optimizes the non-spinning shims as described in SECTION 6.3: "Optimization Of Non-Spinning Shims". Finally macro shimit_z_fine starts and further improves the z shims as described in SECTION 6.4: "Further Optimization Of Spinning (z) Shims". Each section shows the macro used and the spectra representing the successive improvements in magnet homogeneity.

Notice that an auto-shimming run can also be started from the other macros if the magnet homogeneity is already sufficiently high. While the shimming macros are assumed to be generally applicable it is quite instructive to at least once shim a magnet using ShimIt without additional macros. The macros themselves don't try to provide much of a user interface and should at this point be regarded as a demonstration of what ShimIt can do and how to integrate ShimIt in other software systems.

6.1 Optimization Of All Shims

"************************************************************************"
"*                                                                      *"
"*    MAGICAL macro shimit_all                                          *"
"*                                                                      *"
"*    Optimize all shims using non-spinning sample with auto-shimming   *"
"*    software ShimIt.                                                  *"
"*                                                                      *"
"*    (C) Reinhard Dunkel                               Nov 29, 1994    *"
"*                                                                      *"
"************************************************************************"

spin = 0                                "No sample spinning"
spin                                    "Stop spinning now"
alock = 'u'                             "No Varian locking"
lockpower = 0                           "No power for lock channel"
lockgain  = 0                           "Don't detect lock signal"
in = 'n'                                "No checking of lock or spin"
shimit_init                             "Create ShimIt variables"
shims = axial_shims+' '+radial_shims    "Optimize all available shims"
shimit_init                             "Initialize ShimIt"
task = 'shim'                           "Set ShimIt to auto-shimming"
sscycles = 0                            "No sample saturation expected"
shimstep = trunc(-sh_range/2)           "Shims completely unknown"
order = 1                               "Minimize first central moment"
converge = 1.0 * order                  "Termination by max_fid"
timeout = 300                           "Time-out after 5 minutes idle"
$iWord = -1                             "Count number of selected shims"
REPEAT
  $current_shim = ''
  $iWord = $iWord + 1
  substr(shims, $iWord+1):$current_shim
UNTIL $current_shim = ''
max_fid = $iWord * 8                    "Coarse shim adjustment"
cr = sp + wp/2                          "Cursor to middle of display"
$rflrfp = rfl - rfp                     "Assign 0 Hz to cursor position"
rfp = 0
rfl = cr + $rflrfp
sp = sp - cr + rfp
cr = rfp  
$oldtof = tof                           "Center display area in spectrum"
tof = $oldtof - sw/2 - rfp + rfl
rfl = rfl + $oldtof - tof               "Fix spectral referencing"
IF sw > sfrq * 20 THEN                  "Limit spectral width to 20 ppm"
   $oldsw = sw
   sw = sfrq * 20
   rfl = rfl - $oldsw/2 + sw/2          "Fix spectral referencing" 
ENDIF
at = 75 * at*sw*2/wp/np                 "Use 75 points for display"
nt = 1                                  "No time for signal averaging"
rm(userdir+'/ShimIt_all')               "Delete old ShimIt directory"
wshimit = 'mv(userdir+"/ShimIt",'+\
          'userdir+"/ShimIt_all")'+\
          ' shimit_z'                   "Finished? Save & start z shimming"
menu('shimit')                          "Show main ShimIt menu"
shimit_start                            "Start ShimIt"







6.2 Optimization Of Spinning (z) Shims

"************************************************************************"
"*                                                                      *"
"*    MAGICAL macro shimit_z                                            *"
"*                                                                      *"
"*    Optimize spinning shims using spinning sample with auto-shimming  *"
"*    software ShimIt.                                                  *"
"*                                                                      *"
"*    (C) Reinhard Dunkel                               Nov 29, 1994    *"
"*                                                                      *"
"************************************************************************"

spin = 50                               "Spin sample at 50 Hz"
spin                                    "Regulate spinning now"
alock = 'u'                             "No Varian locking"
lockpower = 0                           "No power for lock channel"
lockgain  = 0                           "Don't detect lock signal"
in = 'n'                                "No checking of lock or spin"
shimit_init                             "Create ShimIt variables"
shims = axial_shims                     "Optimize spinning shims"
shimit_init                             "Initialize ShimIt"
task = 'shim'                           "Set ShimIt to auto-shimming"
sscycles = 0                            "No sample saturation expected"
shimstep = trunc(sh_range/4)            "z shims partly optimized"
order = 1                               "Minimize first central moment"
converge = 1.0 * order                  "Termination by max_fid"
timeout = 300                           "Time-out after 5 minutes idle"
sp = sp + (wp - spin*1.5)/2             "Exclude spinning sidebands"
wp = spin * 1.5                         "Narrow displayed spectral area"
$iWord = -1                             "Count number of selected shims"
REPEAT
  $current_shim = ''
  $iWord = $iWord + 1
  substr(shims, $iWord+1):$current_shim
UNTIL $current_shim = ''
max_fid = $iWord * 8                    "Coarse shim adjustment"
cr = sp + wp/2                          "Cursor to middle of display"
$rflrfp = rfl - rfp                     "Assign 0 Hz to cursor position"
rfp = 0
rfl = cr + $rflrfp
sp = sp - cr + rfp
cr = rfp  
$oldtof = tof                           "Center display area in spectrum"
tof = $oldtof - sw/2 - rfp + rfl
rfl = rfl + $oldtof - tof               "Fix spectral referencing"
IF sw > sfrq * 15 THEN                  "Limit spectral width to 15 ppm"
   $oldsw = sw
   sw = sfrq * 15
   rfl = rfl - $oldsw/2 + sw/2          "Fix spectral referencing" 
ENDIF
at = 100 * at*sw*2/wp/np                "Display 100 points (.75 Hz/pt)"
nt = 1                                  "No time for signal averaging"
rm(userdir+'/ShimIt_z')                 "Delete old ShimIt directory"
wshimit = 'mv(userdir+"/ShimIt",'+\
          'userdir+"/ShimIt_z")'+\
          ' shimit_non_z'               "Finished? Save & start non-z shimming"
menu('shimit')                          "Show main ShimIt menu"
shimit_start                            "Start ShimIt"





6.3 Optimization Of Non-Spinning Shims

"************************************************************************"
"*                                                                      *"
"*    MAGICAL macro shimit_non_z                                        *"
"*                                                                      *"
"*    Optimize non-spinning shims using non-spinning sample using       *"
"*    auto-shimming software ShimIt.                                    *"
"*                                                                      *"
"*    (C) Reinhard Dunkel                               Nov 29, 1994    *"
"*                                                                      *"
"************************************************************************"

spin = 0                                "No sample spinning"
spin                                    "Stop spinning now"
alock = 'u'                             "No Varian locking"
lockpower = 0                           "No power for lock channel"
lockgain  = 0                           "Don't detect lock signal"
in = 'n'                                "No checking of lock or spin"
shimit_init                             "Create ShimIt variables"
shims = radial_shims                    "Optimize spinning shims"
shimit_init                             "Initialize ShimIt"
task = 'shim'                           "Set ShimIt to auto-shimming"
sscycles = 0                            "No sample saturation expected"
shimstep = trunc(-sh_range/8)           "z shims partly optimized"
order = 1                               "Increase weight of signal height"
converge = 1.0 * order                  "Termination by max_fid"
timeout = 300                           "Time-out after 5 minutes idle"
sp = sp + (wp - 100)/2                  "Display +/-40 Hz around signal"
wp = 80
$iWord = -1                             "Count number of selected shims"
REPEAT
  $current_shim = ''
  $iWord = $iWord + 1
  substr(shims, $iWord+1):$current_shim
UNTIL $current_shim = ''
max_fid = $iWord * 8                    "Coarse shim adjustment"
cr = sp + wp/2                          "Cursor to middle of display"
$rflrfp = rfl - rfp                     "Assign 0 Hz to cursor position"
rfp = 0
rfl = cr + $rflrfp
sp = sp - cr + rfp
cr = rfp  
$oldtof = tof                           "Center display area in spectrum"
tof = $oldtof - sw/2 - rfp + rfl
rfl = rfl + $oldtof - tof               "Fix spectral referencing"
IF sw > sfrq * 15 THEN                  "Limit spectral width to 15 ppm"
   $oldsw = sw
   sw = sfrq * 15
   rfl = rfl - $oldsw/2 + sw/2          "Fix spectral referencing" 
ENDIF
at = 75 * at*sw*2/wp/np                 "Display 75 points (1 Hz/pt)"
nt = 1                                  "No time for signal averaging"
rm(userdir+'/ShimIt_non_z')             "Delete old ShimIt directory"
wshimit = 'mv(userdir+"/ShimIt",'+\
          'userdir+"/ShimIt_non_z") '+\
          'shimit_z_fine'               "Finished? Save & start z-fine shimming"
menu('shimit')                          "Show main ShimIt menu"
shimit_start                            "Start ShimIt"










6.4 Further Optimization Of Spinning (z) Shims

"************************************************************************"
"*                                                                      *"
"*    MAGICAL macro shimit_z_fine                                       *"
"*                                                                      *"
"*    Final optimization of spinning shims using spinning sample with   *"
"*    auto-shimming software ShimIt.                                    *"
"*                                                                      *"
"*    (C) Reinhard Dunkel                               Nov 29, 1994    *"
"*                                                                      *"
"************************************************************************"

spin = 35                               "Spin sample at 35 Hz"
spin                                    "Regulate spinning now"
alock = 'u'                             "No Varian locking"
lockpower = 0                           "No power for lock channel"
lockgain  = 0                           "Don't detect lock signal"
in = 'n'                                "No checking of lock or spin"
shimit_init                             "Create ShimIt variables"
shims = axial_shims                     "Optimize spinning shims"
shimit_init                             "Initialize ShimIt"
task = 'shim'                           "Set ShimIt to auto-shimming"
sscycles = 0                            "No sample saturation expected"
shimstep = trunc(sh_range/8)            "z shims pre-optimized"
order = 0.5                             "Increase weight of signal height"
converge = 1.0 * order                  "Termination by max_fid"
timeout = 300                           "Time-out after 5 minutes idle"
sp = sp + (wp - spin)/2                 "Exclude spinning sidebands"
wp = spin * 0.8                         "Narrow displayed spectral area"
$iWord = -1                             "Count number of selected shims"
REPEAT
  $current_shim = ''
  $iWord = $iWord + 1
  substr(shims, $iWord+1):$current_shim
UNTIL $current_shim = ''
max_fid = $iWord * 10                   "Coarse shim adjustment"
cr = sp + wp/2                          "Cursor to middle of display"
$rflrfp = rfl - rfp                     "Assign 0 Hz to cursor position"
rfp = 0
rfl = cr + $rflrfp
sp = sp - cr + rfp
cr = rfp  
$oldtof = tof                           "Center display area in spectrum"
tof = $oldtof - sw/2 - rfp + rfl
rfl = rfl + $oldtof - tof               "Fix spectral referencing"
IF sw > sfrq * 10 THEN                  "Limit spectral width to 10 ppm"
   $oldsw = sw
   sw = sfrq * 10
   rfl = rfl - $oldsw/2 + sw/2          "Fix spectral referencing" 
ENDIF
at = 75 * at*sw*2/wp/np                 "Display 75 points (.35 Hz/pt)"
nt = 1                                  "No time for signal averaging"
rm(userdir+'/ShimIt_z_fine')            "Delete old ShimIt directory"
wshimit = 'mv(userdir+"/ShimIt",'+\
          'userdir+"/ShimIt_z_fine")'+\
          ' wshimit=""'                 "On termination: Save output"
menu('shimit')                          "Show main ShimIt menu"
shimit_start                            "Start ShimIt"






Final comparison:

In the final spectrum the first spinning sidebands (35 Hz) cannot even be seen. The visible low frequency second spinning sideband stems from the NCC Z*SPEC probe and is not a shimming problem. The center resonance is not quite Lorentzian in shape yet. Further ShimIt low-order z shimming using a low order parameter value would obtain the desired lineshape. However, given the current implementation of ShimIt manual or automated lock-level shimming would likely be faster for this final stage.

1Some research samples might not have a sufficiently isolated signal for use by the current version of ShimIt. Future ShimIt versions will address this issue.

2ShimIt can indeed also shift the field by adjusting z0. A currently disabled feature of ShimIt is to function as a software lock for data acquisitions where the normal deuterium hardware lock is not applicable.



ScienceSoft, LLC
www.ScienceSoft.net
TOC PREV NEXT INDEX