Esempio n. 1
0
 def test_candidates_dismiss(self):
     series = ImageSeriesFactory(patient_id='42', series_instance_uid='13', uri='/images/1.dcm')
     new_case = CaseFactory(series=series)
     candidate = CandidateFactory(case=new_case)
     url = reverse('candidate-detail', kwargs={'pk': candidate.pk})
     resp = self.client.patch(url, {'review_result': enums.CandidateReviewResult.DISMISSED.value})
     self.assertEqual(resp.status_code, status.HTTP_200_OK)
     candidate.refresh_from_db()
     self.assertEquals(candidate.review_result, enums.CandidateReviewResult.DISMISSED.value)
Esempio n. 2
0
    def test_report(self):
        url = reverse('case-report', kwargs={'pk': 0})
        response = self.client.get(url)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

        series = ImageSeriesFactory(patient_id='42', series_instance_uid='13', uri='/images/1.dcm')
        new_case = CaseFactory(series=series)
        centroid1 = ImageLocationFactory(x=1, y=2, z=3)
        candidate1 = CandidateFactory(case=new_case, centroid=centroid1, probability_concerning=0.8)
        centroid2 = ImageLocationFactory(x=10, y=20, z=30)
        candidate2 = CandidateFactory(case=new_case, centroid=centroid2, probability_concerning=0.98)
        nodule1, _ = candidate1.get_or_create_nodule()
        nodule2, _ = candidate2.get_or_create_nodule()

        url = reverse('case-detail', kwargs={'pk': new_case.pk})
        response = self.client.get(url)
        expected = {
            'patient_id': '42',
            'series_instance_uid': '13',
            'uri': '/images/1.dcm',
            'url': '/api/images/9/',
            'images': [],
        }
        self.assertDictEqual(expected, response.data['series'])

        candidate1_dict = dict(response.data['candidates'][0])
        self.assertEqual(candidate1_dict['probability_concerning'], 0.8)
        self.assertEqual(candidate1_dict['centroid']['x'], nodule1.candidate.centroid.x)
        self.assertEqual(candidate1_dict['centroid']['y'], nodule1.candidate.centroid.y)
        self.assertEqual(candidate1_dict['centroid']['z'], nodule1.candidate.centroid.z)

        candidate2_dict = response.data['candidates'][1]
        self.assertEqual(candidate2_dict['probability_concerning'], 0.98)
        self.assertEqual(candidate2_dict['centroid']['x'], nodule2.candidate.centroid.x)
        self.assertEqual(candidate2_dict['centroid']['y'], nodule2.candidate.centroid.y)
        self.assertEqual(candidate2_dict['centroid']['z'], nodule2.candidate.centroid.z)

        nodule1_dict = response.data['nodules'][0]
        self.assertEqual(nodule1_dict['candidate']['centroid']['x'], nodule1.candidate.centroid.x)
        self.assertEqual(nodule1_dict['candidate']['centroid']['y'], nodule1.candidate.centroid.y)
        self.assertEqual(nodule1_dict['candidate']['centroid']['z'], nodule1.candidate.centroid.z)

        nodule2_dict = response.data['nodules'][1]
        self.assertEqual(nodule2_dict['candidate']['centroid']['x'], nodule2.candidate.centroid.x)
        self.assertEqual(nodule2_dict['candidate']['centroid']['y'], nodule2.candidate.centroid.y)
        self.assertEqual(nodule2_dict['candidate']['centroid']['z'], nodule2.candidate.centroid.z)
Esempio n. 3
0
 def test_create_image_series(self):
     image_series = ImageSeriesFactory()
     self.assertRegex(image_series.series_instance_uid, '^[0-9\.]{64}')
     self.assertIn(image_series.series_instance_uid, image_series.uri)