Skip to content

Commit

Permalink
ENH: Add DICOM preamble, no_preamble tests
Browse files Browse the repository at this point in the history
Both GDCM and DCMTK.

Related to #4108.

From @issakomi:

> Almost every DICOM file has the "preamble". There are old ACR-NEMA files without preamble / prefix / header (0x0002 group).
> Strictly speaking, the preamble consists of 128 (zero) bytes at the beginning (reserved), and the subsequent 4 bytes "DICM" are called the prefix.
> https://dicom.nema.org/medical/dicom/current/output/chtml/part10/chapter_7.html
>
> Here is one without preamble and prefix, starts with the header (0x0002 group), specially for testing purposes. Most DICOM viewers can open it. It is also 'dciodvfy' clean.
> https://data.kitware.com/#item/65efb5f18353a45974ec399b
>
> Here is one tiny and 'dciodvfy' clean file with correct preamble/prefix, just for simplicity, if a dedicated test is required. But again, every modern DICOM file should have this
> https://data.kitware.com/#item/65efb9518353a45974ec399e
  • Loading branch information
thewtex committed Mar 12, 2024
1 parent b04aed2 commit 8427bbe
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Modules/IO/DCMTK/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ itk_add_test(
${ITK_TEST_OUTPUT_DIR}/itkDCMTKImageIOTest4.png
${ITK_TEST_OUTPUT_DIR}/itkDCMTKRescaleImageIOTest4.dcm)

itk_add_test(
NAME
itkDCMTKImageIOTest5
COMMAND
ITKIODCMTKTestDriver
itkDCMTKImageIOTest
DATA{Input/preamble.dcm}
${ITK_TEST_OUTPUT_DIR}/itkDCMTKImageIOTest5.dcm
${ITK_TEST_OUTPUT_DIR}/itkDCMTKImageIOTest5.png
${ITK_TEST_OUTPUT_DIR}/itkDCMTKRescaleImageIOTest5.dcm)

itk_add_test(
NAME
itkDCMTKImageIOTest6
COMMAND
ITKIODCMTKTestDriver
itkDCMTKImageIOTest
DATA{Input/no_preamble.dcm}
${ITK_TEST_OUTPUT_DIR}/itkDCMTKImageIOTest6.dcm
${ITK_TEST_OUTPUT_DIR}/itkDCMTKImageIOTest6.png
${ITK_TEST_OUTPUT_DIR}/itkDCMTKRescaleImageIOTest6.dcm)

itk_add_test(
NAME
itkDCMTKSeriesReadImageWrite
Expand Down
1 change: 1 addition & 0 deletions Modules/IO/DCMTK/test/Input/no_preamble.dcm.cid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bafkreidvhgcecqrku7u63wbzocw52mragf5i4ycbixcon5yohdlfctr63y
1 change: 1 addition & 0 deletions Modules/IO/DCMTK/test/Input/preamble.dcm.cid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bafkreibhyvtpyhwha2y5zjtx5mn4uod5mf33vwvtem3f5whyvivjpcde2a
1 change: 1 addition & 0 deletions Modules/IO/GDCM/test/Baseline/no_preamble.mha.cid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bafkreicwoy4frgs5faincl6oqr6osu4zgn3dt74iyqphmthj7hs3x2y2w4
1 change: 1 addition & 0 deletions Modules/IO/GDCM/test/Baseline/preamble.mha.cid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bafkreicwoy4frgs5faincl6oqr6osu4zgn3dt74iyqphmthj7hs3x2y2w4
26 changes: 26 additions & 0 deletions Modules/IO/GDCM/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,32 @@ itk_add_test(
${ITK_TEST_OUTPUT_DIR}/single-bit.mha
scalar)

itk_add_test(
NAME
itkGDCMImageReadWriteTest_preamble
COMMAND
ITKIOGDCMTestDriver
--compare
DATA{Baseline/preamble.mha}
${ITK_TEST_OUTPUT_DIR}/preamble.mha
itkGDCMImageReadWriteTest
DATA{Input/preamble.dcm}
${ITK_TEST_OUTPUT_DIR}/preamble.mha
scalar)

itk_add_test(
NAME
itkGDCMImageReadWriteTest_no_preamble
COMMAND
ITKIOGDCMTestDriver
--compare
DATA{Baseline/no_preamble.mha}
${ITK_TEST_OUTPUT_DIR}/no_preamble.mha
itkGDCMImageReadWriteTest
DATA{Input/no_preamble.dcm}
${ITK_TEST_OUTPUT_DIR}/no_preamble.mha
scalar)

function(AddComplianceTest fileName)
itk_add_test(
NAME
Expand Down
1 change: 1 addition & 0 deletions Modules/IO/GDCM/test/Input/no_preamble.dcm.cid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bafkreidvhgcecqrku7u63wbzocw52mragf5i4ycbixcon5yohdlfctr63y
1 change: 1 addition & 0 deletions Modules/IO/GDCM/test/Input/preamble.dcm.cid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bafkreibhyvtpyhwha2y5zjtx5mn4uod5mf33vwvtem3f5whyvivjpcde2a

0 comments on commit 8427bbe

Please sign in to comment.