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

Example of DICOM load, edit and download edited version, issue with DicomWriter #1695

Closed
git-toni opened this issue Jul 2, 2024 · 5 comments
Labels
question Further information is requested
Milestone

Comments

@git-toni
Copy link

git-toni commented Jul 2, 2024

Helloo!
I'm attempting to complete a rather simple task but I seem to be stuck, I'm certainly missing something quite obvious. Thank you in advance 🙏

Task:

  1. Load DICOM via loadURLs .
  2. Edit some metadata fields.
  3. Draw some shapes on the canvas.
  4. Write an edited copy of the DICOM and download it.

I prepared a JSFiddle forking one of the main examples from the docs.
Note that I omitted step 2) for the sake of simplicity; correct me if I'm misunderstanding but to achieve that one would directly edit a particular field in the metadata object of type {string, DataElement}.

The issue in the example is at step 4), particularly when calling

writer.getBuffer(dicomElements)

Error:
image

What the example does is get the metadata from dataId=0, then pass it to getBuffer as dicomElements, so I reckon I'm not sending the right argument here.
If you think it can be informative, I'd be happy to submit a PR to the repo with a new example once I can get the whole thing working (both the vanilla examples & react which is what I'm working with) ☺️

Thanks for the lib & help!

PS. Also attempted it via explicit XHTMLRequest arraybuffer parsing, but then one needs to implement the image + layer + view creation logic, which is slightly more tedious IIUC.

@ivmartel ivmartel added the question Further information is requested label Jul 8, 2024
@ivmartel ivmartel added this to the 0.34.0 milestone Jul 8, 2024
@ivmartel
Copy link
Owner

ivmartel commented Jul 8, 2024

Hi, if you are expecting to save the drawn shape with the dicom, this will not work. The idea is to save it as a separate file. I'm working on it for #1020, the idea is to replace the current json state file by a DICOM one.
On the other side, the meta that you retrieve from the parser does not contain the pixel data. I remove it to not overload the browser, this could maybe be revised since if you do not have the parser, you do not have access to the pixel data.

@git-toni
Copy link
Author

git-toni commented Jul 9, 2024

Thank you for the reply @ivmartel!

this will not work
idea is to save it as a separate file. I'm working on it for #1020, the idea is to replace the current json state file by a DICOM one.

Oh I see, I didn't catch that. So to achieve my goal (draw a shape and store it for the next load), couple related questions:

  1. Is there an example via JSON state file that illustrates how to draw a shape (eg. red line or black rectangle), store it and then re-load it? Just to see what's the recommended approach in those cases where one wants the next image load to display the shapes.

  2. Is there a way to actually burn/overwrite the pixel data today that you can think of, involving third party libs I presume? I'm assuming you're working on implementing that "in-house" but was wondering if there's already a way via external lib.

does not contain the pixel data. I remove it to not overload the browser, this could maybe be revised since if you do not have the parser

  1. Can you point to the module/function where that removal is implemented? Just curious to understand better the processing "pipeline" of dwv.

Thanks!

@ivmartel
Copy link
Owner

  1. The test viewer has a 'save state' link at the bottom, you can load it via file > open; you can also check the state tests at https://github.com/ivmartel/dwv/tree/develop/tests/state
  2. There is no code yet to burn an edited image (via filter for example), there is for non edited but without the app, just the DicomParser/DicomWriter, check the anonymiser (https://github.com/ivmartel/dwv/blob/develop/tests/dicom/pages/anonymiser.html); but if you goal is just to save a drawing, you do not need to save the dicom image, no?
  3. The removal is done there: https://github.com/ivmartel/dwv/blob/develop/src/image/dicomBufferToView.js#L309

@git-toni
Copy link
Author

Aah, thanks a lot! Will try to work with those. Closing this issue then for the time being ☺️

if you goal is just to save a drawing, you do not need to save the dicom image, no?

My goal was to actually overwrite the pixels in the image with an opaque square, so it would have been ideal to actually alter the pixels in the new dicom image. But I totally understand this is not an available use-case today.
For context, this was desirable to anonymize DICOM's apart from the meta header; since some of them have burned patient names or sensitive data in the image.

@ivmartel
Copy link
Owner

I created #1705 for image anonymisation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants