StoreSCP: how to ensure saved image is identical to that received #947
Replies: 1 comment 1 reply
-
On the other hand, if there's no transfer syntax change and you use pynetdicom to write the raw dataset codestream directory to file/memory without decoding it first, the codestream should be identical to that sent by the SCU. Then you only have to account for any differences between the file as-read and the file as-sent that may be introduced by the SCU. def handle_store(event):
"""Handle a C-STORE request event."""
with open(f"{uuid.uuid4()}", 'wb') as f:
# Write the raw encoded dataset to `f`
# No file meta information header, not conformant to DICOM Standard!
f.write(event.encoded_dataset(include_meta=False))
# Return a 'Success' status
return 0x0000 And as long as the transfer syntax hasn't changed from uncompressed to/from compressed then the actual element values of things like Pixel Data should remain the same, where "should" means the same as it always does in relation to DICOM, which means it will probably work about 98% of the time. Personally, I'd compare the output you care about though. from pydicom import dcmread
import numpy as np
ds_original = dcmread("file_sent.dcm")
ds_received = dcmread("file_received.dcm")
assert np.array_equal(ds_received.pixel_array, ds_original.pixel_array) Just remember to keep the plugin used for pixel data conversion to ndarray consistent. |
Beta Was this translation helpful? Give feedback.
-
First of all, pynetdicom is bringing major joy to my summer. Its awesome to build my own StoreSCP (in a university research group). Thanks to everyone who makes this possible!
I did not see the answer to my question in previous open or closed issues, or in the docs, or when consulting a LLM.
Ideally, I'd like to have a test where I compare sha1sums of an instance (saved as a file) before and after sending it through my StoreSCP, and have them be identical. (I had this working in Orthanc sending an image using the REST API. Using dcmsend, it would add OFFIS_DCMTK_364 into the header.)
I'm seeing various diffs pre-post, eg in the headers (using dcmdump):
Questions
Here's the supported contexts--trying to support ~everything, but I only need MRI-related
here's the part of my store-event callback where I (try to) get the file_meta info
and here's how I am storing each received image:
With pynetdicom v2.0.x I was doing this, same behavior
Beta Was this translation helpful? Give feedback.
All reactions