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+BUG for the visual DICOM browser #1203

Merged
merged 8 commits into from May 17, 2024

Conversation

Punzo
Copy link
Contributor

@Punzo Punzo commented May 7, 2024

No description provided.

@Punzo
Copy link
Contributor Author

Punzo commented May 7, 2024

Copy link
Member

@lassoan lassoan left a comment

Choose a reason for hiding this comment

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

The change looks good, but this is a sneaky error that has many other manifestations if we are not being very careful. We need to make the code as safe as possible by design, and if not possible then by documentation.

The obvious fix would be to not store DICOM tags as strings, because those 2x2 bytes could be stored in an int and then we would not have string comparison issues and also the comparison and any conversions would be much faster. However, if we want to support private tags in the future then we need to store private creator string as well and then integer will not suffice. So, let's keep it a string and make sure it is used correctly everywhere and improve the documentation to reduce chances of errors creeping in again.

There should minimum number (preferably only one) for converting a tag to string and it should be used everywhere. Not just capitalization, but also zero-padding can be inconsistent, and if we add support for private tags then we want to change the code at only one place. Check where else tags are converted to strings and make sure this single implementation is used everywhere.

We should probably also normalize tag string formatting in all tagcache methods (e.g., before storage or comparison of a tag string, it should be normalized). Similarly to tag to string conversion, there should be only one normalization method imlementation and that should be used everywhere.

Finally, we should improve documentation:

  • Improve tagcache documentation: describe how the tag string is formatted (we can refer to the conversion or normalization method) in the database, and in get/set methods documentation describe what input formatting is allowed and what formatting is used for the output.
  • Improve dicomTagToString method documentation
  • Add a descriptive commit message.

@Punzo
Copy link
Contributor Author

Punzo commented May 7, 2024

I'm not completely familiar with this specific part of codebase of the cktDICOMDatabase, so this PR was just a quick fix following the discussion on https://discourse.slicer.org/t/dicom-database-update-is-requested-after-new-slicer-version-but-appears-to-be-impossible/35821/18. The idea wasn't to merge it as-is, but rather to use it as a starting point (I will change the PR status to draft).
Reference commit introducing the regression is: 8418771

I agree with you that a basic method shouldn't break with the first change in a commit. This indicates that CTK doesn't have adequate unit tests for the DICOM tag methods, so I think we need to add them as well (in addition to cleaning, proper documentation, etc....). In fact we discovered this regression only after 5 months.

It might be faster for Steve to apply the feedback, since he's the original author of the commit. However, if you think we should raise the priority of this issue with my HIVE hours, I can step in to help.

@Punzo Punzo marked this pull request as draft May 7, 2024 13:50
@pieper
Copy link
Member

pieper commented May 7, 2024

This looks good to me, but I agree more tests would be very helpful. I'm not funded on any projects related to this at the moment so if you have time available yes, please jump in. 🙏

As a general rule I suggest we minimize the use of hex, either as strings or as literals in the code, since they are very error prone and hard to read and work with. Although in the tag cache itself we may not be able to avoid using the hex strings.
In general we should always use the tag names as defined by the dictionary.

@Punzo
Copy link
Contributor Author

Punzo commented May 10, 2024

@pieper @lassoan I summarized the issue in #1204, so we can work on it as soon as we have dev time available for it.

Please let me know, if I need to do anything else for this PR (which fix only the regression).

@Punzo Punzo marked this pull request as ready for review May 10, 2024 17:28
@Punzo Punzo force-pushed the visualDICOMBrowserENH branch 3 times, most recently from 1b1ae28 to 8c3f640 Compare May 15, 2024 20:18
@Punzo Punzo force-pushed the visualDICOMBrowserENH branch 2 times, most recently from 6c8ef42 to aee6c80 Compare May 16, 2024 11:22
@Punzo
Copy link
Contributor Author

Punzo commented May 16, 2024

@lassoan I am using this PR for the next round of enhs and fixes for the visual dicom browser. I have changed the title accordingly

@Punzo Punzo changed the title BUG: Convert lower case dicom tags ENH+BUG for the visual DICOM browser May 16, 2024
@Punzo Punzo marked this pull request as draft May 16, 2024 11:36
@lassoan
Copy link
Member

lassoan commented May 16, 2024

@Punzo There are a couple of important fixes here. Could we merge this as is (and you can create a follow-up pull request with more updates)?

@Punzo
Copy link
Contributor Author

Punzo commented May 16, 2024

@Punzo There are a couple of important fixes here. Could we merge this as is (and you can create a follow-up pull request with more updates)?

Yes for me it's good to go. Next week I will create a new PR with more ENH

@Punzo Punzo marked this pull request as ready for review May 16, 2024 16:46
Copy link
Member

@lassoan lassoan left a comment

Choose a reason for hiding this comment

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

These look good to me, thank you.

@lassoan lassoan merged commit 4c71546 into commontk:master May 17, 2024
4 checks passed
@Punzo
Copy link
Contributor Author

Punzo commented May 18, 2024

These look good to me, thank you.

I have opened a PR in SLicer for updating the CTK hash Slicer/Slicer#7751

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants