       ControllerHelper.cleanBrowserUrl($rootScope.project)
   ]
 
+
+  ctlrs.controller 'VolumeImageCtrl', [
+    '$scope',
+    ($scope) ->
+      # Create the image object on demand for the element scope.
+      $scope.image = $scope.volume.image
+  ]

define ['angular', 'modeling', 'breast'], (ng) ->
  ctlrs = ng.module 'qiprofile.controllers', ['qiprofile.modeling', 'qiprofile.breast']

  # The local controller helper methods.
  ctlrs.factory 'ControllerHelper', [

    ($rootScope, $scope, subject, ControllerHelper) ->
      # Capture the current project.
      $rootScope.project = subject.project
      # Place the subject in scope.
      $scope.subject = subject
      # If the project is the default, then remove it from the URL.
      ControllerHelper.cleanBrowserUrl($rootScope.project)
  ]


  ctlrs.controller 'ScanVolumeSelectCtrl', [
    '$scope',
    ($scope) ->
      # Place the scan protocol id in scope.
      $scope.protocolId = $scope.scan.protocol
  ]


  ctlrs.controller 'RegistrationVolumeSelectCtrl', [
    '$scope',
    ($scope) ->
      # Place the registration protocol id in scope.
      $scope.protocolId = $scope.registration.protocol
  ]


  ctlrs.controller 'ScanProtocolCtrl', [
    '$scope', '$modal', 'ScanProtocol',
    ($scope, $modal, ScanProtocol) ->      
      # Open a modal window to display the scan procedure properties.
      $scope.open = ->
        $modal.open
          controller: 'ProtocolModalCtrl'
          templateUrl: '/partials/scan-protocol.html'
          size: 'sm'
          resolve:
            # Fetch the scan protocol.
            protocol: ->
              ScanProtocol.find(id: $scope.protocolId).$promise
  ]


  ctlrs.controller 'RegistrationProtocolCtrl', [
    '$scope', '$modal', 'RegistrationProtocol',
    ($scope, $modal, RegistrationProtocol) ->      
      # Open a modal window to display the registration properties.
      $scope.open = ->
        $modal.open
          controller: 'ProtocolModalCtrl'
          templateUrl: '/partials/registration-protocol.html'
          size: 'sm'
          resolve:
            # Fetch the registration protocol.
            protocol: ->
              RegistrationProtocol.find(id: $scope.protocolId).$promise
  ]


  ctlrs.controller 'ProtocolModalCtrl', [
    '$scope', '$modalInstance', 'protocol',
    ($scope, $modalInstance, protocol) ->
      # Place the protocol object in the modal scope.
      $scope.protocol = protocol
      $scope.close = ->
        $modalInstance.close()
  ]
