Skip to main content

My first python repo for kk.

Project description

KkOrthanc

Python library that wraps the Orthanc REST API.

Installation

$ pip install KkOrthanc

Example of usage

Be sure that Orthanc is running. The default URL (if running locally) is http://localhost:8042.

Get all the patients, studies, series and instances identifiers:

from orthanc import Orthanc
orthanc = Orthanc("http://localhost:8042/")

patients_identifiers = orthanc.get_patients()
study_identifiers = orthanc.get_studies()
series_identifiers = orthanc.get_series()
instance_identifiers = orthanc.get_instances()

Get specified patient, study, series, instance information:

from orthanc import Orthanc
orthanc = Orthanc("http://localhost:8042/")

# To get patients identifiers
patients_identifiers = orthanc.get_patients()

# To get patient's studies identifier and main information
for patient_identifier in patients_identifiers:
    patient_information = orthanc.get_patients_info(patient_identifier)
    study_identifiers = patient_information['Studies']   
    # To get study's series identifier and main information
    for study_identifier in study_identifiers:
        study_information = orthanc.get_studies_info(study_identifier)	
        series_identifiers = study_information['Series']
        # To get series' instances identifier and main information
        for series_identifier in series_identifiers:
            series_information = orthanc.get_series_info(series_identifier)	
            instance_identifiers = series_information['Instances']
            # To get instances main information
            for instance_identifier in instance_identifiers:
                instance_information = orthanc.get_instances_info(instance_identifier)

Delete specified study

from orthanc import Orthanc
orthanc = Orthanc("http://localhost:8042/")

studies_identifiers = orthanc.get_studies()
print(studies_identifiers)
>>> ['c4bd9044-6b9654bd-43d61bca-2c58acd5-458c7854']
orthanc.delete_study('c4bd9044-6b9654bd-43d61bca-2c58acd5-458c7854')

studies_identifiers = orthanc.get_studies()
print(studies_identifiers)
>>> []

Post specified instance

from orthanc import Orthanc
orthanc = Orthanc("http://localhost:8042/")

with open('/Users/apple/Desktop/Instance.dcm', 'rb') as file:
    orthanc.post_instances(file.read())

Delete specified study

from orthanc import Orthanc
orthanc = Orthanc("http://localhost:8042/")

instances_identifiers = orthanc.get_instances()
print(instances_identifiers)
>>> ['5dbdad22-d21b8e67-83358204-fc591c97-55571dda']
orthanc.delete_instance('5dbdad22-d21b8e67-83358204-fc591c97-55571dda')

instances_identifiers = orthanc.get_instances()
print(instances_identifiers)
>>> []

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

KkOrthanc-0.1.5.tar.gz (5.4 kB view details)

Uploaded Source

File details

Details for the file KkOrthanc-0.1.5.tar.gz.

File metadata

  • Download URL: KkOrthanc-0.1.5.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for KkOrthanc-0.1.5.tar.gz
Algorithm Hash digest
SHA256 b42c3572cf2a0f79e2a5a9d7ddb5dae737cf5a417d7d8c1658f10f460d58b2e5
MD5 039de55bc0e11b7e9a9d847520b29a28
BLAKE2b-256 3737f20c5786b27fbb6bcd34139d477a893ec5c1aca277b9b823c8a4293b89fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page