         # The rendering callback. This function is called after the
         # volume is initialized and prior to the first rendering.
         renderer.onShowtime = ->
-          gui = null
           # The volume display controls. The element is manually
           # placed later in this function.
           gui = new dat.GUI(autoplace: false)

  image = ng.module 'qiprofile.image', ['qiprofile.file', 'vr.directives.slider']

  image.factory 'Image', ['$rootScope', '$q', 'File', ($rootScope, $q, File) ->
    # The root scope {parent id: [Image objects]} cache.
    if not $rootScope.images
      $rootScope.images = {}


          # Display the label map (overlay) controls.
          labelmapCtls = gui.addFolder('Overlay')
          labelmapTypeCtl = labelmapCtls.add(_loader, 'Type', overlayTypes).name('Type')
          labelmapOpacityCtl = labelmapCtls.add(volume.labelmap, 'opacity', 0, 1).name('Opacity')
          labelmapCtls.open()

          # Label map selection callback.
          labelmapTypeCtl.onChange (value) ->
            selectOverlay(value, volume)
            # Destroy the old control...
            # ...it will be re-created.
            ctlElt.remove()

        # Adjust the camera position.
        renderer.camera.position = [0, 0, 240]
