diff --git a/Modules/IO/GDCM/test/Baseline/itkGDCMLegacyMultiFrameTest.mha.sha512 b/Modules/IO/GDCM/test/Baseline/itkGDCMLegacyMultiFrameTest.mha.sha512 new file mode 100644 index 00000000000..d72a7296b76 --- /dev/null +++ b/Modules/IO/GDCM/test/Baseline/itkGDCMLegacyMultiFrameTest.mha.sha512 @@ -0,0 +1 @@ +39bdfb6ac14e79744d717a80733456dc17b23e7f8917660ded9f23f3cce50800b336f3e303ea024fc9681433c248df91b04a38cc1f9ebbfc1ead98648ed63aca diff --git a/Modules/IO/GDCM/test/CMakeLists.txt b/Modules/IO/GDCM/test/CMakeLists.txt index a2100b375a9..b647db28013 100644 --- a/Modules/IO/GDCM/test/CMakeLists.txt +++ b/Modules/IO/GDCM/test/CMakeLists.txt @@ -11,6 +11,7 @@ itkGDCMImagePositionPatientTest.cxx itkGDCMImageIOOrthoDirTest.cxx itkGDCMImageOrientationPatientTest.cxx itkGDCMLoadImageSpacingTest.cxx +itkGDCMLegacyMultiFrameTest.cxx ) CreateTestDriver(ITKIOGDCM "${ITKIOGDCM-Test_LIBRARIES}" "${ITKIOGDCMTests}") @@ -144,6 +145,19 @@ itk_add_test(NAME itkGDCMLoadImageNoSpacingTest 1.0 ) +itk_add_test(NAME itkGDCMLegacyMultiFrameTest + COMMAND ITKIOGDCMTestDriver + --compare ${ITK_TEST_OUTPUT_DIR}/itkGDCMLegacyMultiFrameTest.mha + DATA{Baseline/itkGDCMLegacyMultiFrameTest.mha} + itkGDCMLegacyMultiFrameTest + # This dataset was derived from + # https://www.dropbox.com/s/8m7ugu4cmw83fvd/dicoms-anon.zip?dl=0 + # per the discussion here + # https://discourse.slicer.org/t/dicom-multiframe-support/4806/9 + DATA{Input/LegacyMultiFrame.dcm} + ${ITK_TEST_OUTPUT_DIR}/itkGDCMLegacyMultiFrameTest.mha + ) + list(FIND ITK_WRAP_IMAGE_DIMS 2 wrap_2_index) if(ITK_WRAP_float AND wrap_2_index GREATER -1) itk_python_add_test(NAME PythonReadDicomAndReadTagTest diff --git a/Modules/IO/GDCM/test/Input/LegacyMultiFrame.dcm.sha512 b/Modules/IO/GDCM/test/Input/LegacyMultiFrame.dcm.sha512 new file mode 100644 index 00000000000..9fb75dabda7 --- /dev/null +++ b/Modules/IO/GDCM/test/Input/LegacyMultiFrame.dcm.sha512 @@ -0,0 +1 @@ +84d22e7b3e6df2c53eca5444d5dd113dc5d6b0f7589ee9a22667222cec99cde2d33a35eb705fbcb1b9959788eec14d7b2011312ea1270104905612698e772d2b diff --git a/Modules/IO/GDCM/test/itkGDCMLegacyMultiFrameTest.cxx b/Modules/IO/GDCM/test/itkGDCMLegacyMultiFrameTest.cxx new file mode 100644 index 00000000000..a6c067a8f3f --- /dev/null +++ b/Modules/IO/GDCM/test/itkGDCMLegacyMultiFrameTest.cxx @@ -0,0 +1,63 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#include +#include "itkGDCMImageIO.h" +#include "itkImageFileReader.h" +#include "itkImageFileWriter.h" + +// This test verifies that we obtain the correct origin and spacing for a +// Legacy MultiFrame DICOM file with IOD +// LegacyConvertedEnhancedMRImageStorage. + +int itkGDCMLegacyMultiFrameTest(int argc, char *argv[]) +{ + if(argc < 3) + { + std::cerr << "Usage: " << argv[0] << " " << std::endl; + return EXIT_FAILURE; + } + + const char * inputFileName = argv[1]; + const char * outputFileName = argv[2]; + + using PixelType = unsigned short; + constexpr unsigned int Dimension = 3; + using ImageType = itk::Image; + + using ReaderType = itk::ImageFileReader; + ReaderType::Pointer reader = ReaderType::New(); + itk::GDCMImageIO::Pointer imageIO = itk::GDCMImageIO::New(); + reader->SetImageIO( imageIO ); + reader->SetFileName( inputFileName ); + + using WriterType = itk::ImageFileWriter; + WriterType::Pointer writer = WriterType::New(); + writer->SetInput( reader->GetOutput() ); + writer->SetFileName( outputFileName ); + try + { + writer->Update(); + } + catch( itk::ExceptionObject & error ) + { + std::cerr << "Error when running pipeline: " << error << std::endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +}