Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Change from Debug to Warning macro. #4926

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

zivy
Copy link
Member

@zivy zivy commented Nov 1, 2024

When non DICOM and non standard ITK tags are in the metadata dictionary, issue a warning. This addresses the common mistake of using the comma as a separator in the group-element key instead of the pipe, which is what ITK/GDCM uses. These metadata dictionary entries were silently ignored. The warning should provide the user with a hint about what is happening.

@github-actions github-actions bot added type:Enhancement Improvement of existing methods or implementation area:IO Issues affecting the IO module labels Nov 1, 2024
@zivy zivy requested review from N-Dekker and dzenanz November 1, 2024 13:26
Comment on lines 1011 to 1013
itkDebugMacro("GDCMImageIO: non-DICOM and non-ITK standard key = " << key);
itkWarningMacro(
"ignoring non-DICOM and non-ITK standard key (DICOM key structure is group|element with pipe separator) = "
<< key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the problem is specifically the accidental use of a comma as a separator, would it help to check if the key has any comma inside, before producing the warning?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a way to suppress this warning? If someone knows that not their entire metadata dictionary will be written, but don't want a warning (and don't want to clean it up)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, I wonder why the common (XXXX,XXXX) format isn't supported anyway 🤷

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also recommend 1 warning per file not per tag. That is something like "the following tags are non-standard and are being ignored: ...."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There would still be the issue of the GDCM not supporting parenthesis, which are commonly used too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still like to keep the warning, but switch it to one per file.

Copy link
Contributor

@N-Dekker N-Dekker Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @zivy Of course, if we support both pipe and comma separators, there might be a tiny little chance that the very same DICOM tag is represented in two ways XXXX,XXXX and XXXX|XXXX, in one and the same image. But I guess that would be a very rare mistake, that we may ignore. Right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change the PR so that the warning is per file and not per tag and that both pipe and comma are acceptable separators.
@N-Dekker, you raised a valid corner case which I'd like to ignore for now given the expected rarity (will add it to the documentation instead of directly dealing with it and revisit in the future).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add testing of the new functionality.

Comment on lines 1011 to 1013
itkDebugMacro("GDCMImageIO: non-DICOM and non-ITK standard key = " << key);
itkWarningMacro(
"ignoring non-DICOM and non-ITK standard key (DICOM key structure is group|element with pipe separator) = "
<< key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a way to suppress this warning? If someone knows that not their entire metadata dictionary will be written, but don't want a warning (and don't want to clean it up)?

DICOM group-element separator can be either comma or pipe, accept
both. Also, when non DICOM and non standard ITK tags are in the metadata
dictionary, issue a single warning per file.
@github-actions github-actions bot added the type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct label Nov 3, 2024
@zivy
Copy link
Member Author

zivy commented Nov 3, 2024

Updated and force pushed. Writing supports both comma and pipe separators and added testing. Non-DICOM and non-ITK metadata in dictionary trigger a single warning per file which lists all these unexpected dictionary keys.

@zivy zivy merged commit dae9bef into InsightSoftwareConsortium:master Nov 4, 2024
15 checks passed
@zivy zivy deleted the dicomTagWarning branch November 4, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:IO Issues affecting the IO module type:Enhancement Improvement of existing methods or implementation type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants