WIP: ENH: Increase itk::DCMTKFileReader class coverage#2796
WIP: ENH: Increase itk::DCMTKFileReader class coverage#2796jhlegarreta wants to merge 1 commit intoInsightSoftwareConsortium:mainfrom
itk::DCMTKFileReader class coverage#2796Conversation
|
A few notes:
Using the built-in I submitted an experimental build to see if that helps other folks to try to reproduce the issue: Thus, I could not compile and run the test to see its errors. Not sure if the CIs have the module flag set to
|
itk::DCMTKFileReader class coverageitk::DCMTKFileReader class coverage
dzenanz
left a comment
There was a problem hiding this comment.
Making the test quantitative would be good, but that can be a follow-up commit. This is good as-is.
Sounds reasonable. Note that I have not been able to compile the module, and hence nor I have tested it, and I would not merge this until it gets tested. The CI builds did not set the module to |
|
I will test it locally and report back. |
|
It fails to compile for me too: |
|
The offending file is located in |
Meaning that including the directory is missing in the I did try to add it manually to my MSVC properties, but it did not solve the problem. But maybe I did not do it appropriately. Also, Brad's AWS build tests the module, so it would be weird that this should not happen on Linux: |
|
Adding the entire content of I don't know where the fix needs to be applied, but it is almost certainly somewhere in ITK's DCMTK-related CMake code. |
|
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
|
This is still relevant stale bot. I am willing to take up this as soon as #2817 gets resolved. |
| // Acquisition Duration | ||
| group = 0x0019; | ||
| element = 0x105a; | ||
| // Expect 1304791694 |
There was a problem hiding this comment.
Strange, my viewer and also dcmdump show
(0019,105a) FL 414273984 # 4, 1 AcquisitionDuration
not 1304791694. Somehow strange values for float, there may be an issue in the file.
There was a problem hiding this comment.
Strange, my viewer and also dcmdump show
(0019,105a) FL 414273984 # 4, 1 AcquisitionDuration
not 1304791694. Somehow strange values for float, there may be an issue in the file.
Not sure where I got the value from :-S. I probably used an online viewer, which might not be fully trustworthy.
I am not able to build the module locally, so I was relying on an online tool rather than installing locally some library/tool. But I am willing to fix it if anybody can point me to a dependable tool that I could use to potentially get the accurate values for more tags.
There was a problem hiding this comment.
Also applicable to all private tags in the test, it is correct to access private tags (odd group) using private creator, not just by group and element.
Can you elaborate on this? If there is a better way to access the tags, I may have a look to also add them (?).
There was a problem hiding this comment.
This particular tag is also known for DCMTK (is in private dictionary), so it is OK.
There was a problem hiding this comment.
I am not able to build the module locally, so I was relying on an online tool rather than installing locally some library/tool.
I have no problem with Linux build and internal DCMTK. I remember with external and at least static libraries there were problems too, something with missing libraries (they were there, but not found).
P.S.
I have to admit I am not experienced with DCMTK, actually I am testing it for PACS stuff, it seems to be clean and well maintained library.
38bea5f to
73c450e
Compare
I may give a go at this. If the module is turned on by the CIs, they'll tell about the tag contents. I'd think of two ways to make this quantitative:
If the latter is possible, it involves less code, and allows for improvements (e.g. reading/comparing more tags) without minimal changes to the test code. @dzenanz Wondering whether the CMake |
|
DCMTK has own tests, BTW, there are some macros too e.g. OFCHECK_EQUAL |
👍 Here we are trying to make sure that ITK's
👍 Thanks Mihail. |
|
CMake can compare files (syntax), but only binary comparison. It should work in this case, and it is less work to set up than read the file and compare ourselves. The downside is that error message will be "file are different", rather than more meaningful messages we can craft in the custom code. If you have time, you can go the custom comparison route. Otherwise let CMake compare the outputs. P.S. I don't know how easy or hard it is to turn |
|
Slicer should be able to read DICOM tags. |
Yes, that one I had found yesterday, but did not find out whether our |
|
FYI, some parts are too bad for testing and coverage, e.g. this function. IOPixelEnum
DCMTKFileReader::GetImagePixelType() const
{
unsigned short SamplesPerPixel;
if (this->GetElementUS(0x0028, 0x0100, SamplesPerPixel, false) != EXIT_SUCCESS)
{
return IOPixelEnum::UNKNOWNPIXELTYPE;
}
IOPixelEnum pixelType;
switch (SamplesPerPixel)
{
case 8:
case 16:
pixelType = IOPixelEnum::SCALAR;
break;
case 24:
pixelType = IOPixelEnum::RGB;
break;
default:
pixelType = IOPixelEnum::VECTOR;
}
return pixelType;
}Edit: |
|
@issakomi Thanks for the investigation. I'd be more than happy to add more test cases to test the relevant methods if the appropriate DICOM data can be shared. |
I think i have mentioned a bug, better say forgotten garbage in DCMTKFileReader class. The test is here, it is complete minimal standalone test. Not intended to be included in test suite. #include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkDCMTKImageIO.h"
#include "itkDCMTKFileReader.h"
#include <iostream>
int main(int, char **)
{
auto imageIO = itk::DCMTKImageIO::New();
imageIO->SetFileName("../data/raw-RGB.dcm");
try
{
imageIO->ReadImageInformation();
}
catch (const itk::ExceptionObject & ex)
{
std::cout << ex.GetDescription() << std::endl;
}
itk::IOPixelEnum pixel_type1 = imageIO->GetPixelType();
std::cout << "DCMTKImageIO reported Pixel Type "
<< imageIO->GetPixelTypeAsString(pixel_type1)
<< std::endl;
// GetImagePixelType() is unused garbage
itk::DCMTKFileReader dcmtkFileReader;
dcmtkFileReader.SetFileName("../data/raw-RGB.dcm");
dcmtkFileReader.LoadFile();
itk::IOPixelEnum pixel_type2 = dcmtkFileReader.GetImagePixelType();
std::cout << "DCMTKFileReader reported Pixel Type "
<< imageIO->GetPixelTypeAsString(pixel_type2)
<< std::endl;
return 0;
}Sorry, but i am out and will not do any more work on DCMTK in the near future. |
73c450e to
f3f3979
Compare
| } | ||
|
|
||
| // Image Pixel Type | ||
| IOPixelEnum pixelType = fileReader.GetImagePixelType(); |
There was a problem hiding this comment.
GetImagePixelType() is obviously too bad and should be fixed or even better removed from the class.
There was a problem hiding this comment.
The ideal thing would be to fix it. If itk::DCMTKImageIO (maybe through itk::ImageIOBase) or the itk::DCMTKImageIO::ReadImageInformation are doing a better job in this, then part of the code might be valid for here (haven't looked). If we do not find a way to fix it, then it should be deprecated (and yet be tested so that at least its behavior is consistent) prior to being removed.
There was a problem hiding this comment.
itk::DCMTKImageIO::ReadImageInformation is in fact OK, not ideal too, i don't like that SamplesPerPixel=4 is assumed to be RGBA, in fact it could be e.g. CMYK. But is really not important, currently there are no DICOM files with SamplesPerPixel=4 (CMYK, ARGB), they were deprecated long long ago. So in 99.999% ReadImageInformation works fine. There are more to test (manually first), e.g. how DCMKT handles YBR images, PALETTE_COLOR. Maybe later.
There was a problem hiding this comment.
and yet be tested so that at least its behavior is consistent) prior to being removed
test are always good, but not including known completely broken stuff into test suite, sorry. The test text files can not match too, sorry.
There was a problem hiding this comment.
Thanks for all this insight. Will see when I get the time to push this, as I am still being blocked by #2817 to be able to properly do this.
f3f3979 to
172680e
Compare
Add a new test to the `IODCMTK` module to increase the coverage of the `itk::DCMTKFileReader::GetElement*` methods.
172680e to
005ac14
Compare
|
Closing as superseded by #6189, which carries this work forward to a buildable, runnable state on current The new PR addresses everything in this thread:
The two test invocations targeting @jhlegarreta — your authorship of the original test concept is preserved via Closing this PR; please follow the discussion on #6189. |
…wareConsortium#3820) The ITK module ITKIODCMTK declares ITKDCMTK as PRIVATE_DEPENDS so the DCMTK headers do not leak through the toolkit's public include surface. But the public header itkDCMTKFileReader.h transitively #includes <dcmtk/dcmdata/dcdict.h>, so any test file that includes itkDCMTKFileReader.h fails to compile with: fatal error: 'dcmtk/dcmdata/dcdict.h' file not found This blocked PR InsightSoftwareConsortium#2796 from landing for over three years and is tracked as issue InsightSoftwareConsortium#3820. Add a narrowly-scoped target_include_directories() block in Modules/IO/DCMTK/test/CMakeLists.txt that adds the DCMTK ExternalProject's per-library include dirs and the generated configuration header dir to ITKIODCMTKTestDriver only. No change to the public DEPENDS surface of the IODCMTK module --- only the test driver target acquires the additional include paths. When ITK is built with ITK_USE_SYSTEM_DCMTK=ON the system-installed DCMTK headers are already on the default search path, so the block is gated behind NOT ITK_USE_SYSTEM_DCMTK.
Add a test that exercises every well-formed VR-typed accessor on itk::DCMTKFileReader against the existing fixture Input/DicomSeries/Image0075.dcm: GetElementDA StudyDate GetElementTM StudyTime GetElementPN PatientName GetElementCS PatientSex, PhotometricInterpretation GetElementDS PatientWeight GetElementIS EchoNumber GetElementFL AcquisitionDuration (private GE tag) GetElementSL LocsPer3DSlab (private GE tag) GetElementUS SamplesPerPixel, Rows, BitsAllocated GetElementUI ScannerStudyEntityUID Expected values were verified out-of-band with pydicom against the on-disk fixture before authoring, fixing several wrong-by-transcription expectations from the original PR InsightSoftwareConsortium#2796 (e.g. AcquisitionDuration was recorded there as 1304791694, the integer reinterpretation of the float bit pattern; the actual scanner-reported FL value is 414273984.0). Each tag is asserted in-process via ITK_TEST_EXPECT_EQUAL; the test also writes one tag-value-per-line to argv[2] for diagnostic inspection. The in-process assertions are the source of truth for correctness, so no --compare baseline file is needed. The fixture is the single slice Image0075.dcm rather than the DicomSeries regex; the test reads exactly one file via SetFileName, not a series. Two further test invocations proposed by PR InsightSoftwareConsortium#2796 (against RGBDicomSeries/raw-RGB.dcm and RTDoseDicomSeries/32bitDoseRTImage.dcm) are dropped for now because those fixtures were never published to ITKTestingData. Supersedes PR InsightSoftwareConsortium#2796. Co-Authored-By: jhlegarreta <jon.haitz.legarreta@gmail.com>
Add a new test to the
IODCMTKmodule to increase the coverage of theitk::DCMTKFileReader::GetElement*methods.PR Checklist