           ]
 
         session_detail:
-          _id: 'b'
-          scans:
-            t1:
-              name: 't1'
-              intensity:
-                intensities: [2.4]
-              registration:
-                reg_01:
-                  intensity:
-                    intensities: [3.1]
-                reg_02:
-                  intensity:
-                    intensities: [2.7]
+          _id: 'sd1'
+          scans: [
+            {
+              number: 1
+              protocol: 'sp1'
+              volumes: [
+                {
+                  number: 1
+                  average_intensity: 2.4
+                }
+              ]  
+              registrations: [
+                {
+                  resource: 'reg_01'
+                  protocol: 'rp1'
+                  volumes: [
+                    {
+                      number: 1
+                      average_intensity: 3.1
+                    }
+                  ]
+                }
+              ]
+            }
+          ]
+              
 
       beforeEach ->
         # Fake the router service module.

            $httpBackend.whenGET(url).respond(JSON.stringify(_items: [mock.subject]))

            # The mock subject http call.
            url = encodeURI('/api/subject/a')
            $httpBackend.whenGET(url).respond(JSON.stringify(mock.subject))

            # The mock session-detail http call.
            url = encodeURI('/api/session-detail/b')
            $httpBackend.whenGET(url).respond(JSON.stringify(mock.session_detail))
        ]

      afterEach ->

          # Confirm that a subject was fetched.
          it 'should fetch the subject', ->
            expect(subject, "Subject was not fetched").to.exist
          
          describe 'Demographics', ->
            # Validate the birth date.
            it 'should anonymize the subject birth date', ->
              expect(subject.birthDate, "Subject is missing a birth date").to.exist
              expect(subject.birthDate.valueOf(), "Subject birth date is incorrect")
                .to.equal(moment('July 7, 1986').valueOf())
        
          describe 'Clinical', ->
            # Validate the encounters.
            it 'should set the subject encounters', ->
              expect(subject.encounters, "Subject is missing encounters").to.exist
              expect(subject.encounters.length, "Subject encounters length is" +
                                                " incorrect").to.equal(1)
              enc = subject.encounters[0]
              expect(enc._cls, "Encounter type is incorrect")
                .to.equal(mock.subject.encounters[0]._cls)
        
            # Validate the treatments.
            it 'should extend the subject treatments', ->
              expect(subject.treatments, "Subject is missing treatments").to.exist
              expect(subject.treatments.length, "Subject encounters length is" +
                                                " incorrect").to.equal(1)
              trt = subject.treatments[0]
              expect(trt.treatmentType, "Treatment type is missing").to.exist
              expect(trt.treatmentType, "Treatment type is incorrect")
                .to.equal(mock.subject.treatments[0].treatment_type)
              expect(trt.begin_date.valueOf(), "Treatment begin date is incorrect")
                .to.equal(mock.subject.treatments[0].begin_date)
        
          describe 'Session', ->
            session = null
            
            beforeEach ->
              if subject.sessions
                session = subject.sessions[0]
            
            # Validate the sessions (without detail).
            it 'should have a subject session', ->
              expect(subject.sessions, "Subject is missing sessions").to.exist
              expect(subject.sessions.length, "Subject session count is incorrect")
                .to.equal(1)
              expect(subject.isMultiSession, "Subject multi-session flag is" +
                                             " incorrect").to.be.false
            
            it 'should have a session modeling object', ->
              expect(session.modeling, "Session is missing modeling").to.exist
              expect(session.modeling.length, "Session modeling count is incorrect")
                .to.equal(1)

          describe.only 'Modeling', ->
            modeling = null
            
            beforeEach ->
              if subject.modeling
                modeling = subject.modeling[0]
            
            it 'should have a subject modeling object', ->
              expect(subject.modeling, "Subject is missing modeling").to.exist
              expect(subject.modeling.lenght, "Subject modeling length is incorrect")
                .to.equal(1)
            
            it 'should have a protocol', ->
              expect(modeling.protocol, "Modeling is missing a protocol")
                .to.exist
              expect(modeling.protocol, "Modeling protocol reference is incorrect")
                .to.equal(mock.protocol.modeling._id)
            
            it 'should have a source', ->
              expect(modeling.source, "Modeling is missing the source").to.exist
            
            it 'should model the registration', ->
              expect(modeling.source.registration, "Modeling source does not reference a registration")
                .to.exist
              expect(modeling.source.registration, "Modeling source does not reference the registration protocol")
                .to.equal(mock.protocol.registration._id)            
            
              
                # TODO - replace below by verification for sole modeling.
                # TODO - we will also have a subject modeling which groups
                # the session modeling by protocol into a
                # subject{modeling: {source: {protocol: [results]}
                # where the results are by session.
              
              
                # # There is one scan modeling objects.
                # scanMdl = subject.modeling.scan
                # expect(scanMdl, "The subject modeling scan is missing").to.exist
                # expect(scanMdl.length, "The subject modeling registration count" +
                #                        " is incorrect").to.equal(1)
                #           
                # # The scan modeling is for the T1 scan.
                # mdl = subject.modeling.scan[0]
                # expect(mdl.key, "Modeling is missing a key").to.exist
                # expect(mdl.source, "Modeling is missing a source").to.exist
                # expect(mdl.source.scanType, "The scan modeling source is missing" +
                #                             " the scan type").to.exist
                # expect(mdl.source.scanType, "Modeling source scan type is incorrect")
                #   .to.equal('t1')
                # mockMdl = mock.subject.scan_sets.t1.modeling.pk_03
                # expect(mdl.results, "Modeling is missing results").to.exist
                # expect(mdl.results.length, "Modeling results count is incorrect")
                #   .to.equal(1)
                # mdlResult = mdl.results[0]
                # expect(mdlResult.deltaKTrans, "Modeling results is missing" +
                #                               " deltaKTrans").to.exist
                # expect(mdlResult.deltaKTrans.average, "Modeling deltaKTrans is" +
                #                                       " incorrect")
                #   .to.equal(mockMdl.results[0].delta_k_trans.average)
                #           
                # # The modeling result object refers to its respective session.
                # expect(mdlResult.session, "Modeling results is missing session")
                #   .to.exist
                # expect(mdlResult.session, "Modeling results session is incorrect")
                #   .to.equal(subject.sessions[0])

          # describe 'Session', ->
          #   mockSession = null
