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

fix: get direct url pixel data should be optional for video #4152

Merged
merged 4 commits into from
Jun 5, 2024

Conversation

igoroctaviano
Copy link
Contributor

@igoroctaviano igoroctaviano commented May 21, 2024

Refactor getDirectURL into three documented and tested functions. Also, this change allows building /rendered URLs for video instances that does not have pixel data present.

Context

The get direct URL was a multi-purpose util function. This PR splits it into three independent functions that get called within to get the direct url.

Changes & Results

Now getDirectURL calls getBulkDataValue and createRenderedRetrieve as fallbacks.

Testing

  • Load a video study using json loader (with the URL attribute present) and observe that it will be used as direct url and later as video src for video modality
  • Load a study with DirectRetrieveURL and observe that it will be used as a direct URL
  • Load a study with InlineBinary and observe that it will be used as a direct URL
  • Load a study with either 'PixelData' or 'EncapsulatedDocument' and observe that /rendered URL is built and returned as getDirectURL
  • Load a study with BulkDataURI and observe that it will be used as direct URL with the correct accept query param

(!singlepart || (singlepart !== true && singlepart.indexOf(fetchPart) === -1)

Checklist

PR

  • My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

N/A

Tested Environment

  • "OS: 14.4.1 (23E224)
  • "Node version: 16.14
  • "Browser: Chrome Version 123.0.6312.59 (Official Build) (x86_64)

get direct url pixel data should be optional for video /rendered urls
Copy link

netlify bot commented May 21, 2024

Deploy Preview for ohif-dev ready!

Name Link
🔨 Latest commit a98d8a6
🔍 Latest deploy log https://app.netlify.com/sites/ohif-dev/deploys/665473bc194e79000809efd6
😎 Deploy Preview https://deploy-preview-4152--ohif-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented May 21, 2024

Deploy Preview for ohif-platform-docs ready!

Name Link
🔨 Latest commit a98d8a6
🔍 Latest deploy log https://app.netlify.com/sites/ohif-platform-docs/deploys/665473bc90790b0008cfbafa
😎 Deploy Preview https://deploy-preview-4152--ohif-platform-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

cypress bot commented May 21, 2024

Passing run #3978 ↗︎

0 43 0 0 Flakiness 0

Details:

Merge branch 'master' of github.com:ohif/Viewers into fix/get-direct-url-for-vid...
Project: Viewers Commit: a98d8a69ae
Status: Passed Duration: 06:06 💡
Started: May 27, 2024 12:05 PM Ended: May 27, 2024 12:12 PM

Review all test suite changes for PR #4152 ↗︎

@@ -29,31 +29,31 @@ const getDirectURL = (config, params) => {
}

const value = instance[tag];
if (!value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand what value there is in increasing the indent level. The recommended approach for handling things is to return quickly at the top of the function, rather than nesting a function inside, as was done originally.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I see what you are doing, github made it non obvious that there was more code - cut things off below. What I think should be done is to separate this out into two functions, one of which constructs a URL, the other of which uses the value - and export both of them so that they can be used independently, or combined. Then getDirectURL becomes:

const value = instance[tag];
return getBulkdataValue(value) || createRenderedRetrieve(instance)

Then, you can leave the return immediate as is inside getBulkdataValue.
Also, you might add a note that it is incorrect to not have a value here, or rather it means that the value itself is supposed to be empty, but that some DICOMweb systems incorrectly return empty tag values.
Then, we should handle both:

TAG: null
and
TAG: {}

I'd like to see a unit test to check a couple of the various cases, since I think this logic is getting complex enough to warrant that.  

Sorry for the extra work, but by the time things get this complex, splitting it up makes it easier to figure out what one should expect to receive back.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 45.76%. Comparing base (d4b0973) to head (be52b14).
Report is 21 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4152   +/-   ##
=======================================
  Coverage   45.76%   45.76%           
=======================================
  Files          77       77           
  Lines        1274     1274           
  Branches      315      315           
=======================================
  Hits          583      583           
  Misses        550      550           
  Partials      141      141           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wayfarer3130
Copy link
Contributor

Can you update to head and check that the tests pass before committing please? Otherwise I like how you've added the tests and separated out the functionality to make it clearly understandable.

@sedghi sedghi self-assigned this May 29, 2024
@sedghi sedghi changed the title fix: 🐛 get direct url pixel data should be optional for video fix: get direct url pixel data should be optional for video Jun 5, 2024
@sedghi sedghi merged commit 649ffab into master Jun 5, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants