Want to download/retrive DICOM files to my local file system.

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.

I’ve used python with the requests module to run Orthanc API requests against the server.

For example, you can request a particular study download as a zip archive:

query = orthanc_url + ‘/studies/’ + orthanc_study_id + ‘/archive’
response_study = requests.get(query, verify=False,
auth=(orthanc_user, orthanc_password))
if response_study.status_code != 200:
print ‘Problem retrieving study: ’ + orthanc_study_id
print response_study.status, response_study.reason
print ’ Retrieved: %s’ % orthanc_study_id
zip_content = response_study.content

I then use the io and zipfile modules to extract the DICOM:

file_like_object = io.BytesIO(zip_content)
zip_object = zipfile.ZipFile(file_like_object)
for zip_name in zip_object.namelist():
zip_object.extract(zip_name, some_destination_dir)

Note that the above snippets are cut/paste from working code. I haven’t confirmed that the above code works by itself. Obviously, you need to define the variable values. My Orthanc is behind an Apache proxy, so I have to use the auth option in requests to send a login and password.


Hi John,

Thanks for the help.

Actually, I need to connect with only “TCP/IP address” and “port number” as I may have many other PACS as well like “Conquest” etc. Currently, I am using following code snippets on “pynetdicom3” to fetch DICOM files but getting an error: “No accepted Presentation Context for ‘dataset’”. I am bit confused what should be the Presentation context for the Orthanc server.

Here is my code:


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.* 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.
    #       'P' - Patient Root (1.2.840.10008.
    #       'S' - Study Root (1.2.840.10008.
    #       'O' - Patient/Study Only (1.2.840.10008.
    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':
        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


Manoj Solanki

This is not a pynetdicom support forum !

FYI, you’re actually using send_c_get, not send_c_find. C-GET is not supported by Orthanc.

Hi Manoj,

Were you able to solve your issue? I’m currently facing a similar problem

As mentioned in another thread, instead of send_c_get, you should use send_c_move.