Example #1
0
    def load_DICOM(self):
        # create temporary database. Save original database path to restore
        # it when finished
        self.original_db_path = DICOMUtils.openTemporaryDatabase()
        #assert temporary database is open

        # import DICOM to database
        DICOMUtils.importDicom(self.locations_dict['DICOM'],
                               slicer.dicomDatabase)

        # get patient name
        patient_name = slicer.dicomDatabase.nameForPatient(
            slicer.dicomDatabase.patients()[0])

        # open DICOM by name
        DICOMUtils.loadPatientByName(patient_name)
        slicer.util.selectModule('SegmentationExtractionModule')
  def _test_PETLiverUptakeMeasurementQR2_WithQRExtension(self):
    """ verify SR measurements assuming QuantiativeReporting Extension is installed and enabled
    """
    from DICOMLib import DICOMUtils
    self.delayDisplay('Loading DICOM SEG and SR')

    # note: introduces dependency on QuantiativeReporting and DICOMPETExtension

    # with QuantiativeReporting installed, this should load the DICOM SR and SEG together with the PET scan
    # disable all dicom plugins except those necessary
    dicomWidget = slicer.modules.dicom.widgetRepresentation().self()
    dicomPluginCheckbox =  dicomWidget.detailsPopup.pluginSelector.checkBoxByPlugin
    dicomPluginStates = {(key,value.checked) for key,value in dicomPluginCheckbox.iteritems()}
    for cb in dicomPluginCheckbox.itervalues():
      cb.checked=False
    dicomPluginCheckbox['DICOMRWVMPlugin'].checked = True
    dicomPluginCheckbox['DICOMPETSUVPlugin'].checked = True
    dicomPluginCheckbox['DICOMSegmentationPlugin'].checked = True
    dicomPluginCheckbox['DICOMTID1500Plugin'].checked = True
    DICOMUtils.loadPatientByName(self.patienName)
    for key,value in dicomPluginStates:
      dicomPluginCheckbox[key].checked=value

    # with QuantiativeReporting installed, this should load the DICOM SR and SEG together with the PET scan
    DICOMUtils.loadPatientByName(self.patienName)
    tableNode = slicer.mrmlScene.GetFirstNodeByClass("vtkMRMLTableNode")
    self.assertIsNotNone(tableNode, "Loading SR into mrmlScene failed. No vtkMRMLTableNodes were found within the scene.")
    self.assertEqual(tableNode.GetNumberOfRows(),1)
    self.assertTrue(tableNode.GetNumberOfColumns()>3)
    self.assertEqual(tableNode.GetColumnName(0),'Segment')
    self.assertEqual(tableNode.GetColumnName(1),'Mean [{SUVbw}g/ml]')
    self.assertEqual(tableNode.GetColumnName(2),'Standard Deviation [{SUVbw}g/ml]')
    self.assertEqual(tableNode.GetColumnName(3),'Median [{SUVbw}g/ml]')
    self.assertEqual(tableNode.GetCellText(0,0),'Liver reference region')
    self.assertTrue(abs(float(tableNode.GetCellText(0,1))-2.36253)<0.01)
    self.assertTrue(abs(float(tableNode.GetCellText(0,2))-0.402997)<0.01)
    self.assertTrue(abs(float(tableNode.GetCellText(0,3))-2.335)<0.01)
    self.delayDisplay('Test passed!')

    for key,value in dicomPluginStates:
      dicomPluginCheckbox[key].checked=value