SlicerRt / SlicerRT

Open-source toolkit for radiation therapy research, an extension of 3D Slicer. Features include DICOM-RT import/export, dose volume histogram, dose accumulation, external beam planning (TPS), structure comparison and morphology, isodose line/surface generation, etc.
https://slicerrt.org
128 stars 60 forks source link

py_DicomRtImportTest failing #126

Closed Sunderlandkyl closed 2 years ago

Sunderlandkyl commented 4 years ago

Automated test for importing DICOM-RT data is currently failing.

test_DicomRtImportTest_FullTest1 (DicomRtImportTest.DicomRtImportTest) ... Database folder does not contain ctkDICOM.sql file: /Volumes/Dashboards/Preview/S-0-E-b/SlicerRT-build/inner-build/DicomRtImportExport/Testing/Python
Finished with download test data
Import study
W: DcmItem: Length of element (6854,2065) is odd
E: DcmElement: Unknown Tag & Data (6854,2065) larger (1953724787) than remaining bytes in file
Could not load  "/var/folders/6y/zp9dkw5d5wg35y8qvn29hpww0000gn/T/Slicer-tmp-kitware/DicomRtImportTest/EclipseProstatePhantomRtData/RD.1.2.246.352.71.7.2088656855.452083.20110920153746.dcm" 
DCMTK says:  I/O suspension or premature end of stream
Could not read DICOM file:/var/folders/6y/zp9dkw5d5wg35y8qvn29hpww0000gn/T/Slicer-tmp-kitware/DicomRtImportTest/EclipseProstatePhantomRtData/RD.1.2.246.352.71.7.2088656855.452083.20110920153746.dcm
W: DcmItem: Length of element (6854,2065) is odd
E: DcmElement: Unknown Tag & Data (6854,2065) larger (1953724787) than remaining bytes in file
Could not load  "/var/folders/6y/zp9dkw5d5wg35y8qvn29hpww0000gn/T/Slicer-tmp-kitware/DicomRtImportTest/EclipseProstatePhantomRtData/RI.1.2.246.352.71.3.2088656855.2381134.20110921150951.dcm" 
DCMTK says:  I/O suspension or premature end of stream
Could not read DICOM file:/var/folders/6y/zp9dkw5d5wg35y8qvn29hpww0000gn/T/Slicer-tmp-kitware/DicomRtImportTest/EclipseProstatePhantomRtData/RI.1.2.246.352.71.3.2088656855.2381134.20110921150951.dcm
W: DcmItem: Length of element (6854,2065) is odd
E: DcmElement: Unknown Tag & Data (6854,2065) larger (1953724787) than remaining bytes in file
Could not load  "/var/folders/6y/zp9dkw5d5wg35y8qvn29hpww0000gn/T/Slicer-tmp-kitware/DicomRtImportTest/EclipseProstatePhantomRtData/RP.1.2.246.352.71.5.2088656855.377401.20110920153647.dcm" 
DCMTK says:  I/O suspension or premature end of stream
Could not read DICOM file:/var/folders/6y/zp9dkw5d5wg35y8qvn29hpww0000gn/T/Slicer-tmp-kitware/DicomRtImportTest/EclipseProstatePhantomRtData/RP.1.2.246.352.71.5.2088656855.377401.20110920153647.dcm
W: DcmItem: Length of element (6854,2065) is odd
E: DcmElement: Unknown Tag & Data (6854,2065) larger (1953724787) than remaining bytes in file
Could not load  "/var/folders/6y/zp9dkw5d5wg35y8qvn29hpww0000gn/T/Slicer-tmp-kitware/DicomRtImportTest/EclipseProstatePhantomRtData/RS.1.2.246.352.71.4.2088656855.2404649.20110920153449.dcm" 
DCMTK says:  I/O suspension or premature end of stream
Could not read DICOM file:/var/folders/6y/zp9dkw5d5wg35y8qvn29hpww0000gn/T/Slicer-tmp-kitware/DicomRtImportTest/EclipseProstatePhantomRtData/RS.1.2.246.352.71.4.2088656855.2404649.20110920153449.dcm
"DICOM indexer has successfully processed 4 files [0.01s]"
"DICOM indexer has updated display fields for 0 files [0.00s]"
FAIL
runTest (slicer.ScriptedLoadableModule.ScriptedLoadableModuleTest) ... No test is defined in ScriptedLoadableModuleTest
ok

======================================================================
FAIL: test_DicomRtImportTest_FullTest1 (DicomRtImportTest.DicomRtImportTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Volumes/Dashboards/Preview/S-0-E-b/SlicerRT/DicomRtImportExport/Testing/Python/DicomRtImportTest.py", line 38, in test_DicomRtImportTest_FullTest1
    self.TestSection_ImportStudy()
  File "/Volumes/Dashboards/Preview/S-0-E-b/SlicerRT/DicomRtImportExport/Testing/Python/DicomRtImportTest.py", line 105, in TestSection_ImportStudy
    self.assertEqual( len(slicer.dicomDatabase.patients()), 1 )
AssertionError: 0 != 1

http://slicer.cdash.org/testDetails.php?test=9875840&build=1797453

MichaelColonel commented 4 years ago

Slicer 4.11.0-2020-01-12 r8ea6945

SlicerRT master branch. All tests have passed on linux.

cpinter commented 4 years ago

Unfortunately for me the test crashes after the suggested changes. It needs to be investigated.

MichaelColonel commented 4 years ago

Here is my test log output. No DCMTK errors, only warnings.

LastTest.log

cpinter commented 4 years ago

Thanks, very interesting. I have a consistent crash while importing. The crash is in the QSql calls, see call stack:

 Qt5Cored.dll!qt_message_fatal(QtMsgType __formal, const QMessageLogContext & context, const QString & message) Line 1710   C++
 Qt5Cored.dll!QMessageLogger::fatal(const char * msg, ...) Line 822 C++
 Qt5Cored.dll!qt_assert(const char * assertion, const char * file, int line) Line 3126  C++
 qsqlited.dll!QList<int>::first() Line 345  C++
qsqlited.dll!QSQLiteResult::exec() Line 491 C++
 Qt5Sqld.dll!QSqlQuery::exec() Line 1002    C++
 CTKDICOMCore.dll!ctkDICOMDatabase::fileForInstance(const QString sopInstanceUID) Line 2028 C++
 vtkSlicerDicomRtImportExportModuleLogic.dll!vtkSlicerDicomRtImportExportModuleLogic::vtkInternal::ExamineRtDoseDataset(DcmDataset * dataset, OFString & name, std::vector<OFString,std::allocator<OFString>> & referencedSOPInstanceUIDs) Line 267 C++
 vtkSlicerDicomRtImportExportModuleLogic.dll!vtkSlicerDicomRtImportExportModuleLogic::ExamineForLoad(vtkStringArray * fileList, vtkCollection * loadables) Line 1971    C++
 vtkSlicerDicomRtImportExportModuleLogicPythonD.dll!PyvtkSlicerDicomRtImportExportModuleLogic_ExamineForLoad(_object * self, _object * args) Line 152   C++

I'll try deleting the downloaded file, maybe it's corrupted. We are at the Slicer project week, so I cannot work on this this week.

cpinter commented 4 years ago

I fixed the DicomRtImportTest by updating some baseline numbers. I have not checked if they are correct, but looking at the viewers during the test it seems that all the data is loaded.

IGRTWorkflow_SelfTest still fails, however, and quite badly. It starts with an endless stream of errors like this Input port 0 of algorithm vtkCleanPolyData(0000025DFBB94D80) has 0 connections but is not optional. then there are errors about wrong number of nodes etc. @MichaelColonel since mainly you made changes in the near past that could cause these errors, and also that changes the number of loaded nodes etc, can you please take a look at this test and fix it after your current beam changes with sequences are done? Thank you!

MichaelColonel commented 4 years ago

All python tests are failed with such message:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/test/devel/git/Slicer/Slicer-SuperBuild-Release/python-install/lib/python3.6/imp.py", line 170, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 618, in _exec
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/test/devel/git/SlicerRT/SlicerRT-test/inner-build/lib/Slicer-4.11/qt-scripted-modules/PlmRegister.py", line 4, in <module>
    import RegistrationLib
ModuleNotFoundError: No module named 'RegistrationLib'
loadSourceAsModule - Failed to load file "/home/test/devel/git/SlicerRT/SlicerRT-test/inner-build/lib/Slicer-4.11/qt-scripted-modules/PlmRegister.py"  as module "PlmRegister" !
Fail to instantiate module  "PlmRegister"
The following modules failed to be instantiated:
   PlmRegister
Sunderlandkyl commented 4 years ago

Landmark registration was previously disabled in Slicer, which caused the Python tests to fail. This should be fixed now (See https://github.com/SlicerRt/SlicerRT/issues/140).

You'll probably need to update and rebuild the Slicer SuperBuild.

cpinter commented 4 years ago

Yes. This has been recently fixed. That's how I was able to run them now. As @Sunderlandkyl suggests, please update your Slicer.

MichaelColonel commented 4 years ago

The #147 is ready for checking and testing.

cpinter commented 4 years ago

All the tests pass in the branch referred above. After integration this issue can be closed. Thank you!

cpinter commented 4 years ago

One comment: although IGRTSelfTest passes, it actually does not finish successfully. Here are the errors it outputs:

First

Number of loaded vtkMRMLScalarVolumeNode nodes was 3, but 2 was expected
Number of loaded vtkMRMLModelHierarchyNode nodes was 0, but 7 was expected
Traceback (most recent call last):
  File "E:/e/_Extensions/SlicerRT_R/inner-build/lib/Slicer-4.11/qt-scripted-modules/IGRTWorkflow_SelfTest.py", line 141, in TestSection_01_LoadDicomData
    self.assertTrue(success)
  File "E:\e\ScR\python-install\Lib\unittest\case.py", line 682, in assertTrue
    raise self.failureException(msg)
AssertionError: False is not true
Test caused exception!

then

Setting display options for loaded data
Traceback (most recent call last):
  File "E:/e/_Extensions/SlicerRT_R/inner-build/lib/Slicer-4.11/qt-scripted-modules/IGRTWorkflow_SelfTest.py", line 242, in TestSection_02C_SetDisplayOptions
    day1Dose = slicer.util.getNode(self.day1DoseName)
  File "E:\e\ScR\Slicer-build\bin\Python\slicer\util.py", line 996, in getNode
    raise MRMLNodeNotFoundException("could not find nodes in the scene by name or id '%s'" % (pattern if (isinstance(pattern, str)) else ""))
slicer.util.MRMLNodeNotFoundException: could not find nodes in the scene by name or id '5: RTDOSE: BRAI1'
Test caused exception!
could not find nodes in the scene by name or id '5: RTDOSE: BRAI1'

Not sure how it passes with such an error.

cpinter commented 4 years ago

Same thing happens with py_BatchStructureSetConversion

62: Number of loaded vtkMRMLScalarVolumeNode nodes was 3, but 2 was expected
62: Traceback (most recent call last):
62:   File "E:/e/_Extensions/SlicerRT_R/inner-build/lib/Slicer-4.11/qt-scripted-modules/BatchStructureSetConversion.py", line 237, in TestSection_1_LoadDicomData
62:     self.assertTrue(success)
62:   File "E:\e\ScR\python-install\Lib\unittest\case.py", line 682, in assertTrue
62:     raise self.failureException(msg)
62: AssertionError: False is not true
62: Test caused exception!
62: False is not true
MichaelColonel commented 4 years ago

Number of loaded vtkMRMLModelHierarchyNode nodes was 0, but 7 was expected

I can fix this, since there are no vtkMRMLModelHierarchyNode only vtkMRMLRTBeamNode, but about everything else i can't say anything particular, since other nodes are vtkMRMLScalarVolumeNode and node named '5: RTDOSE: BRAI1'.

MichaelColonel commented 4 years ago

I have fixed IGRTSelfTest. Dose volume name must be '5: RTDOSE', not '5: RTDOSE: BRAI1', since it's a name from the plan.

MichaelColonel commented 4 years ago

I have made a commit to #147 with tests fixes. Can you check this commit as well?

cpinter commented 4 years ago

The tests indeed work, thanks a lot for the quick fixes!

cpinter commented 2 years ago

Test passes, closing.