diff --git a/IO/Image/Testing/Cxx/CMakeLists.txt b/IO/Image/Testing/Cxx/CMakeLists.txt index 86d418cce1e..28e9773efd5 100644 --- a/IO/Image/Testing/Cxx/CMakeLists.txt +++ b/IO/Image/Testing/Cxx/CMakeLists.txt @@ -1,3 +1,8 @@ +# Tell ExternalData to fetch test input at build time. + ExternalData_Expand_Arguments(VTKData _ + "DATA{${VTK_TEST_INPUT_DIR}/dicom/collection/,REGEX:.*}" + ) + vtk_add_test_cxx(${vtk-module}CxxTests data_tests # TestImageReader2Factory.cxx # fixme (deps not satisfied) TestNrrdReader.cxx @@ -13,11 +18,15 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests TestImportExport.cxx ) -# Each of these most be added in a separate vtk_add_test_cxx +# Each of these must be added in a separate vtk_add_test_cxx vtk_add_test_cxx(${vtk-module}CxxTests tests TestDICOMImageReader.cxx,NO_OUTPUT "DATA{${VTK_TEST_INPUT_DIR}/dicom/prostate.IMG}") +vtk_add_test_cxx(${vtk-module}CxxTests tests + TestDICOMImageReaderFileCollection.cxx,NO_OUTPUT + "collection") + vtk_add_test_cxx(${vtk-module}CxxTests tests TestTIFFReaderMultipleMulti,TestTIFFReaderMultiple.cxx,NO_VALID,NO_OUTPUT "DATA{${VTK_TEST_INPUT_DIR}/libtiff/multipage_tiff_example.tif}") diff --git a/IO/Image/Testing/Cxx/TestDICOMImageReaderFileCollection.cxx b/IO/Image/Testing/Cxx/TestDICOMImageReaderFileCollection.cxx new file mode 100644 index 00000000000..54e77a82fbe --- /dev/null +++ b/IO/Image/Testing/Cxx/TestDICOMImageReaderFileCollection.cxx @@ -0,0 +1,128 @@ +/*========================================================================= + + Program: Visualization Toolkit + Module: TestDICOMImageReaderFileCollection.cxx + + Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen + All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ +// .NAME Test of vtkDICOMImageReader +// .SECTION Description +// + + +#include "vtkSmartPointer.h" + +#include "vtkDICOMImageReader.h" + +#include "vtkImageData.h" +#include "vtkImageViewer2.h" +#include "vtkRenderer.h" +#include "vtkRenderWindowInteractor.h" +#include "vtkTestUtilities.h" + + +int TestDICOMImageReaderFileCollection(int argc, char *argv[]) +{ + + if ( argc <= 1 ) + { + cout << "Usage: " << argv[0] << " " << endl; + return 1; + } + + char* dirName = vtkTestUtilities::ExpandDataFileName( argc, argv, "Data/dicom/collection" ); + std::string directoryName = dirName; + delete [] dirName; + + vtkSmartPointer DICOMReader = + vtkSmartPointer::New(); + + // Read the input files + DICOMReader->SetDirectoryName(directoryName.c_str()); + cout << "Directory name: " << DICOMReader->GetDirectoryName() << endl; + + DICOMReader->Update(); + + // Read and display the image properties + const char* fileExtensions = DICOMReader->GetFileExtensions(); + cout << "File extensions: " << fileExtensions << endl; + + const char* descriptiveName = DICOMReader->GetDescriptiveName(); + cout << "Descriptive name: " << descriptiveName << endl; + + double* pixelSpacing = DICOMReader->GetPixelSpacing(); + cout << "Pixel spacing: " << *pixelSpacing << endl; + + int width = DICOMReader->GetWidth(); + cout << "Image width: " << width << endl; + + int height = DICOMReader->GetHeight(); + cout << "Image height: " << height << endl; + + float* imagePositionPatient = DICOMReader->GetImagePositionPatient(); + cout << "Image position patient: " << *imagePositionPatient << endl; + + float* imageOrientationPatient = DICOMReader->GetImageOrientationPatient(); + cout << "Image orientation patient: " << *imageOrientationPatient << endl; + + int bitsAllocated = DICOMReader->GetBitsAllocated(); + cout << "Bits allocated: " << bitsAllocated << endl; + + int pixelRepresentation = DICOMReader->GetPixelRepresentation(); + cout << "Pixel representation: " << pixelRepresentation << endl; + + int numberOfComponents = DICOMReader->GetNumberOfComponents(); + cout << "Number of components: " << numberOfComponents << endl; + + const char* transferSyntaxUID = DICOMReader->GetTransferSyntaxUID(); + cout << "Transfer syntax UID: " << transferSyntaxUID << endl; + + float rescaleSlope = DICOMReader->GetRescaleSlope(); + cout << "Rescale slope: " << rescaleSlope << endl; + + float rescaleOffset = DICOMReader->GetRescaleOffset(); + cout << "Rescale offset: " << rescaleOffset << endl; + + const char* patientName = DICOMReader->GetPatientName(); + cout << "Patient name: " << patientName << endl; + + const char* studyUID = DICOMReader->GetStudyUID(); + cout << "Study UID: " << studyUID << endl; + + const char* studyID = DICOMReader->GetStudyID(); + cout << "Study ID: " << studyID << endl; + + float gantryAngle = DICOMReader->GetGantryAngle(); + cout << "Gantry angle: " << gantryAngle << endl; + + + // Display the center slice + int sliceNumber = + (DICOMReader->GetOutput()->GetExtent()[5] + + DICOMReader->GetOutput()->GetExtent()[4]) / 2; + + // Visualize + vtkSmartPointer imageViewer = + vtkSmartPointer::New(); + imageViewer->SetInputConnection(DICOMReader->GetOutputPort()); + vtkSmartPointer renderWindowInteractor = + vtkSmartPointer::New(); + imageViewer->SetupInteractor(renderWindowInteractor); + imageViewer->SetSlice(sliceNumber); + imageViewer->Render(); + imageViewer->GetRenderer()->ResetCamera(); + renderWindowInteractor->Initialize(); + imageViewer->Render(); + + renderWindowInteractor->Start(); + + + return 0; +} diff --git a/IO/Image/Testing/Data/Baseline/TestDICOMImageReaderFileCollection.png.md5 b/IO/Image/Testing/Data/Baseline/TestDICOMImageReaderFileCollection.png.md5 new file mode 100644 index 00000000000..658aa0c058c --- /dev/null +++ b/IO/Image/Testing/Data/Baseline/TestDICOMImageReaderFileCollection.png.md5 @@ -0,0 +1 @@ +6c042ee4549194e7ad928446e82896b9 diff --git a/IO/Image/vtkDICOMImageReader.cxx b/IO/Image/vtkDICOMImageReader.cxx index 0878105ff62..e651315558f 100644 --- a/IO/Image/vtkDICOMImageReader.cxx +++ b/IO/Image/vtkDICOMImageReader.cxx @@ -102,7 +102,7 @@ int vtkDICOMImageReader::CanReadFile(const char* fname) } else { - vtkErrorMacro("DICOMParser couldn't parse : " << fname); + vtkWarningMacro("DICOMParser couldn't parse : " << fname); return 0; } } diff --git a/Testing/Data/dicom/collection/IM-0001-1983.dcm.md5 b/Testing/Data/dicom/collection/IM-0001-1983.dcm.md5 new file mode 100644 index 00000000000..f527c2e3a97 --- /dev/null +++ b/Testing/Data/dicom/collection/IM-0001-1983.dcm.md5 @@ -0,0 +1 @@ +3258ea5d2a205a17c47d9360c9748f5b diff --git a/Testing/Data/dicom/collection/IM-0001-1984.dcm.md5 b/Testing/Data/dicom/collection/IM-0001-1984.dcm.md5 new file mode 100644 index 00000000000..a2aee02413a --- /dev/null +++ b/Testing/Data/dicom/collection/IM-0001-1984.dcm.md5 @@ -0,0 +1 @@ +07ebebd3fd24d2391a6c70655b6796f6 diff --git a/Testing/Data/dicom/collection/IM-0001-1985.dcm.md5 b/Testing/Data/dicom/collection/IM-0001-1985.dcm.md5 new file mode 100644 index 00000000000..77a91475763 --- /dev/null +++ b/Testing/Data/dicom/collection/IM-0001-1985.dcm.md5 @@ -0,0 +1 @@ +8eb81359e5d950cf1afb0afe7b2371f6 diff --git a/Testing/Data/dicom/collection/IM-0001-1986.dcm.md5 b/Testing/Data/dicom/collection/IM-0001-1986.dcm.md5 new file mode 100644 index 00000000000..57457df4f0c --- /dev/null +++ b/Testing/Data/dicom/collection/IM-0001-1986.dcm.md5 @@ -0,0 +1 @@ +7bc8b3eeaf480aecba5d58ee83eee000 diff --git a/Testing/Data/dicom/collection/IM-0001-1987.dcm.md5 b/Testing/Data/dicom/collection/IM-0001-1987.dcm.md5 new file mode 100644 index 00000000000..9e11886cb49 --- /dev/null +++ b/Testing/Data/dicom/collection/IM-0001-1987.dcm.md5 @@ -0,0 +1 @@ +6d68ed1fbc44a83e5edc57def951a416 diff --git a/Testing/Data/dicom/collection/IM-0001-1988.dcm.md5 b/Testing/Data/dicom/collection/IM-0001-1988.dcm.md5 new file mode 100644 index 00000000000..c3907252f8d --- /dev/null +++ b/Testing/Data/dicom/collection/IM-0001-1988.dcm.md5 @@ -0,0 +1 @@ +ac8befa7248e9a6a98df3a8bb02e4e3a diff --git a/Testing/Data/dicom/collection/IM-0001-1989.dcm.md5 b/Testing/Data/dicom/collection/IM-0001-1989.dcm.md5 new file mode 100644 index 00000000000..4f4b4af4b5a --- /dev/null +++ b/Testing/Data/dicom/collection/IM-0001-1989.dcm.md5 @@ -0,0 +1 @@ +ca1cfecd2cd54e34f4d6715f030b7ca7 diff --git a/Testing/Data/dicom/collection/IM-0001-1990.dcm.md5 b/Testing/Data/dicom/collection/IM-0001-1990.dcm.md5 new file mode 100644 index 00000000000..7edf0f5652f --- /dev/null +++ b/Testing/Data/dicom/collection/IM-0001-1990.dcm.md5 @@ -0,0 +1 @@ +8bc833af0701dbf9e9e2101930ad95f8 diff --git a/Testing/Data/dicom/collection/IM-0001-1991.dcm.md5 b/Testing/Data/dicom/collection/IM-0001-1991.dcm.md5 new file mode 100644 index 00000000000..88288270fe4 --- /dev/null +++ b/Testing/Data/dicom/collection/IM-0001-1991.dcm.md5 @@ -0,0 +1 @@ +bfc7b2189f7f4ada15ecdbfb2416c223 diff --git a/Testing/Data/dicom/collection/IM-0001-1992.dcm.md5 b/Testing/Data/dicom/collection/IM-0001-1992.dcm.md5 new file mode 100644 index 00000000000..392cc21514b --- /dev/null +++ b/Testing/Data/dicom/collection/IM-0001-1992.dcm.md5 @@ -0,0 +1 @@ +c5ca32209c7ecd151635581d97a43b81 diff --git a/Testing/Data/dicom/collection/IM-0001-1993.dcm.md5 b/Testing/Data/dicom/collection/IM-0001-1993.dcm.md5 new file mode 100644 index 00000000000..650fb7248da --- /dev/null +++ b/Testing/Data/dicom/collection/IM-0001-1993.dcm.md5 @@ -0,0 +1 @@ +dc1ac27b3f31512d5863ea16e86ca634