Thanks ORTHANC team for the valuable PACS server.
I am very new to Medical terminologies and DICOM related task.
I have a requirement to download the DICOM images of ORTHANC server to my local machine file system from python. Currently, I am using one python library which is “pynetdicom3” but facing lots of issues. If you have any specific library or any sample code through which I can achieve my goal, please let me know.
Thanks in advance.
from pynetdicom3 import AE
from pydicom import read_file
from pydicom import Dataset
from pynetdicom3 import AE
from pynetdicom3 import StorageSOPClassList
from pynetdicom3 import QueryRetrieveSOPClassList
from pydicom.uid import UID
# The Verification SOP Class has a UID of 1.2.840.10008.1.1
# List of presentation context : http://dicom.nema.org/medical/dicom/2014c/output/chtml/part02/sect_F.4.2.2.4.html Which presentation context I should use?
ct_storage_uid = UID('1.2.840.10008.1.1')
ae = AE(scu_sop_class=[ct_storage_uid])
# Try and associate with the peer AE
# Returns the Association thread
print('Requesting Association with the peer')
assoc = ae.associate("localhost", 4242)
print (assoc)
if assoc.is_established:
print('Association accepted by the peer')
# Creat a new DICOM dataset with the attributes to match against
# In this case match any patient's name at the PATIENT query
# level. See PS3.4 Annex C.6 for the complete list of possible
# attributes and query levels.
dataset = Dataset()
dataset.PatientID = '*'
dataset.QueryRetrieveLevel = "PATIENT"
# Send a DIMSE C-FIND request to the peer
# query_model is the Query/Retrieve Information Model to use
# and is one of 'W', 'P', 'S', 'O'
# 'W' - Modality Worklist (1.2.840.10008.5.1.4.31)
# 'P' - Patient Root (1.2.840.10008.5.1.4.1.2.1.1)
# 'S' - Study Root (1.2.840.10008.5.1.4.1.2.2.1)
# 'O' - Patient/Study Only (1.2.840.10008.5.1.4.1.2.3.1)
responses = assoc.send_c_get(dataset, query_model='P')
print ( responses)
for (status, dataset) in responses:
# While status is pending we should get the matching datasets
if status == 'Pending':
print(dataset)
elif status == 'Success':
print('C-FIND finished, releasing the association')
elif status == 'Cancel':
print('C-FIND cancelled, releasing the association')
elif status == 'Failure':
print('C-FIND failed, releasing the association')
# Release the association
assoc.release()
Alain Mazy / CTO
a...@osimis.io / +32 494 31 67 27
| OSIMIS S.A. |