pyorthanc


Namepyorthanc JSON
Version 1.16.1 PyPI version JSON
download
home_pagehttps://gacou54.github.io/pyorthanc/
SummaryOrthanc REST API python wrapper with additional utilities
upload_time2024-02-08 16:13:58
maintainer
docs_urlNone
authorGabriel Couture
requires_python>=3.8,<4.0
licenseMIT
keywords orthanc dicom medical-imaging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![ci](https://github.com/gacou54/pyorthanc/workflows/Test/badge.svg)](https://github.com/gacou54/pyorthanc/actions?query=workflow%3ATest)
[![documentation](https://img.shields.io/badge/docs-mkdocs%20material-blue.svg?style=flat)](https://gacou54.github.io/pyorthanc/)
![PyPI - Version](https://img.shields.io/pypi/v/pyorthanc)
![PyPI - Downloads](https://img.shields.io/pypi/dm/pyorthanc)
# PyOrthanc
**PyOrthanc** is a python client for the Orthanc REST API, which fully wraps all the methods of the REST API.
Additionally, it provides many utility functions to interact with an Orthanc instance.

See the full documentation here https://gacou54.github.io/pyorthanc

---
Install PyOrthanc using pip:
```bash
pip install pyorthanc
```
---
Then use the client. If Orthanc is running locally, the default URL is `http://localhost:8042`.
```python
import pyorthanc

client = pyorthanc.Orthanc('http://localhost:8042', username='orthanc', password='orthanc')
patient_ids = client.get_patients()
```

Interact with connected modalities
```python
import pyorthanc

modality = pyorthanc.Modality(client, 'MY_MODALITY')
assert modality.echo()

# C-Find on modality
response = modality.query({'Level': 'Study', 'Query': {'PatientID': '*'}})

# C-Move to target modality
modality.move(response['ID'], {'TargetAet': 'target_modality'})
```
Find patients
```python
patients = pyorthanc.find_patients(client, {'PatientID': '*P001'})
for patient in patients:
    patient.labels
    patient.is_stable
    patient.name
    ...
    for study in patient.studies:
        study.labels
        study.date
        ...
        for series in study.series:
            ...
            for instance in series.instances:
                pydicom_ds = instance.get_pydicom()
```

Resources (`Patient`, `Study`, `Series`, `Instance`) can be easily __anonymized__.
```python
import pyorthanc

orthanc_patient_id = client.get_patients()[0]
patient = pyorthanc.Patient(orthanc_patient_id, client)
```
Waiting the for the anonymization process:
```python
new_patient = patient.anonymize()
new_patient_with_given_patient_id = patient.anonymize(
   keep=['PatientName'],
   replace={'PatientID': 'TheNewPatientID'},
   force=True  # Needed when changing PatientID/StudyInstanceUID/SeriesInstanceUID/SOPInstanceUID
)
```
For long-running job (i.e. large patient) or to submit many anonymization jobs at the same time, use
```python
job = patient.anonymize_as_job()
job.state  # You can follow the job state

job.wait_until_completion() # Or just wait on its completion
new_patient = pyorthanc.Patient(job.content['ID'], client)
```

## Notes on versioning

The `Orthanc` and `AsyncOrthanc` classes are generated from `https://api.orthanc-server.com/`.

Compatibility of versions between PyOrthanc and the Orthanc REST API are the following.
Note that recent PyOrthanc versions will likely support older Orthanc version.

| PyOrthanc version | Generated from                                |
|-------------------|-----------------------------------------------|
| \>= 1.13.2        | Orthanc API 1.12.1 with Python Plugin 4.1     |
| 1.13.0, 1.13.1    | Orthanc API 1.12.1 with Python Plugin 4.0     |
| 1.12.*            | Orthanc API 1.12.1                            |
| 1.11.*            | Orthanc API 1.11.3                            |
| 0.2.*             | Provided Google sheet from Orthanc maintainer |


You can still use the old client with
```python
from pyorthanc.deprecated.client import Orthanc  # Old client wrote by hand
from pyorthanc.deprecated.client_1_11_3 import Orthanc
```

Note that due to automatic generation some method names may be less clear.
However, the automatic generation allows PyOrthanc to cover all the routes of the API of Orthanc.


## Citation
If you publish using PyOrthanc, we kindly ask that you credit us. PyOrthanc can be found on Zenodo :
https://zenodo.org/record/7086219 .

## Credits
The `orthanc_sdk.py` has been generated from the `scripts/data/python-sdk.txt` file,
which is from the [Python Orthanc Plugin](https://github.com/orthanc-server/orthanc-setup-samples/blob/master/python-samples/python-sdk.txt)

## Contributing
You can contribute to this project with the following steps:
1. First, fork the project on Github 
2. Clone the project
   ```shell
   git clone https://github.com/<your-github-username>/pyorthanc
   cd pyorthanc
   ```
3. Create a poetry environment 
   (this project use the [poetry](https://python-poetry.org/) for dependency management)
   ```shell
   peotry install 
   ```
4. Make a new git branch where you will apply the changes
   ```shell
   git checkout -b your-branch-name
   ```
   Now you can make your changes
5. Once done, `git add`, `git commit` and `git push` the changes.
6. Make a Pull Request from your branch to the https://github.com/gacou54/pyorthanc.


            

Raw data

            {
    "_id": null,
    "home_page": "https://gacou54.github.io/pyorthanc/",
    "name": "pyorthanc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "Orthanc,DICOM,Medical-Imaging",
    "author": "Gabriel Couture",
    "author_email": "gacou54@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bb/ea/188e53365dc697fb685b24ffe6d7b547437bc0716d3c5a0a1781e304403b/pyorthanc-1.16.1.tar.gz",
    "platform": null,
    "description": "[![ci](https://github.com/gacou54/pyorthanc/workflows/Test/badge.svg)](https://github.com/gacou54/pyorthanc/actions?query=workflow%3ATest)\n[![documentation](https://img.shields.io/badge/docs-mkdocs%20material-blue.svg?style=flat)](https://gacou54.github.io/pyorthanc/)\n![PyPI - Version](https://img.shields.io/pypi/v/pyorthanc)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/pyorthanc)\n# PyOrthanc\n**PyOrthanc** is a python client for the Orthanc REST API, which fully wraps all the methods of the REST API.\nAdditionally, it provides many utility functions to interact with an Orthanc instance.\n\nSee the full documentation here https://gacou54.github.io/pyorthanc\n\n---\nInstall PyOrthanc using pip:\n```bash\npip install pyorthanc\n```\n---\nThen use the client. If Orthanc is running locally, the default URL is `http://localhost:8042`.\n```python\nimport pyorthanc\n\nclient = pyorthanc.Orthanc('http://localhost:8042', username='orthanc', password='orthanc')\npatient_ids = client.get_patients()\n```\n\nInteract with connected modalities\n```python\nimport pyorthanc\n\nmodality = pyorthanc.Modality(client, 'MY_MODALITY')\nassert modality.echo()\n\n# C-Find on modality\nresponse = modality.query({'Level': 'Study', 'Query': {'PatientID': '*'}})\n\n# C-Move to target modality\nmodality.move(response['ID'], {'TargetAet': 'target_modality'})\n```\nFind patients\n```python\npatients = pyorthanc.find_patients(client, {'PatientID': '*P001'})\nfor patient in patients:\n    patient.labels\n    patient.is_stable\n    patient.name\n    ...\n    for study in patient.studies:\n        study.labels\n        study.date\n        ...\n        for series in study.series:\n            ...\n            for instance in series.instances:\n                pydicom_ds = instance.get_pydicom()\n```\n\nResources (`Patient`, `Study`, `Series`, `Instance`) can be easily __anonymized__.\n```python\nimport pyorthanc\n\northanc_patient_id = client.get_patients()[0]\npatient = pyorthanc.Patient(orthanc_patient_id, client)\n```\nWaiting the for the anonymization process:\n```python\nnew_patient = patient.anonymize()\nnew_patient_with_given_patient_id = patient.anonymize(\n   keep=['PatientName'],\n   replace={'PatientID': 'TheNewPatientID'},\n   force=True  # Needed when changing PatientID/StudyInstanceUID/SeriesInstanceUID/SOPInstanceUID\n)\n```\nFor long-running job (i.e. large patient) or to submit many anonymization jobs at the same time, use\n```python\njob = patient.anonymize_as_job()\njob.state  # You can follow the job state\n\njob.wait_until_completion() # Or just wait on its completion\nnew_patient = pyorthanc.Patient(job.content['ID'], client)\n```\n\n## Notes on versioning\n\nThe `Orthanc` and `AsyncOrthanc` classes are generated from `https://api.orthanc-server.com/`.\n\nCompatibility of versions between PyOrthanc and the Orthanc REST API are the following.\nNote that recent PyOrthanc versions will likely support older Orthanc version.\n\n| PyOrthanc version | Generated from                                |\n|-------------------|-----------------------------------------------|\n| \\>= 1.13.2        | Orthanc API 1.12.1 with Python Plugin 4.1     |\n| 1.13.0, 1.13.1    | Orthanc API 1.12.1 with Python Plugin 4.0     |\n| 1.12.*            | Orthanc API 1.12.1                            |\n| 1.11.*            | Orthanc API 1.11.3                            |\n| 0.2.*             | Provided Google sheet from Orthanc maintainer |\n\n\nYou can still use the old client with\n```python\nfrom pyorthanc.deprecated.client import Orthanc  # Old client wrote by hand\nfrom pyorthanc.deprecated.client_1_11_3 import Orthanc\n```\n\nNote that due to automatic generation some method names may be less clear.\nHowever, the automatic generation allows PyOrthanc to cover all the routes of the API of Orthanc.\n\n\n## Citation\nIf you publish using PyOrthanc, we kindly ask that you credit us. PyOrthanc can be found on Zenodo :\nhttps://zenodo.org/record/7086219 .\n\n## Credits\nThe `orthanc_sdk.py` has been generated from the `scripts/data/python-sdk.txt` file,\nwhich is from the [Python Orthanc Plugin](https://github.com/orthanc-server/orthanc-setup-samples/blob/master/python-samples/python-sdk.txt)\n\n## Contributing\nYou can contribute to this project with the following steps:\n1. First, fork the project on Github \n2. Clone the project\n   ```shell\n   git clone https://github.com/<your-github-username>/pyorthanc\n   cd pyorthanc\n   ```\n3. Create a poetry environment \n   (this project use the [poetry](https://python-poetry.org/) for dependency management)\n   ```shell\n   peotry install \n   ```\n4. Make a new git branch where you will apply the changes\n   ```shell\n   git checkout -b your-branch-name\n   ```\n   Now you can make your changes\n5. Once done, `git add`, `git commit` and `git push` the changes.\n6. Make a Pull Request from your branch to the https://github.com/gacou54/pyorthanc.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Orthanc REST API python wrapper with additional utilities",
    "version": "1.16.1",
    "project_urls": {
        "Homepage": "https://gacou54.github.io/pyorthanc/",
        "Repository": "https://github.com/gacou54/pyorthanc"
    },
    "split_keywords": [
        "orthanc",
        "dicom",
        "medical-imaging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0fddf95975a61ac36bd0f181b16373294252bc49c5d5357eb08bcc17904ff887",
                "md5": "3bfcd0186276d3a0f2b8d874b7dbcff7",
                "sha256": "dd0603c01f9c321bdfeb01acd93d146b32b9245259d84cafdcbcb3f6e6234cd1"
            },
            "downloads": -1,
            "filename": "pyorthanc-1.16.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3bfcd0186276d3a0f2b8d874b7dbcff7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 170975,
            "upload_time": "2024-02-08T16:13:56",
            "upload_time_iso_8601": "2024-02-08T16:13:56.083548Z",
            "url": "https://files.pythonhosted.org/packages/0f/dd/f95975a61ac36bd0f181b16373294252bc49c5d5357eb08bcc17904ff887/pyorthanc-1.16.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bbea188e53365dc697fb685b24ffe6d7b547437bc0716d3c5a0a1781e304403b",
                "md5": "6a9d153549e9660a1fd7183d5832d04d",
                "sha256": "6700a24cae1ff7029e2aa249c1fa41131b3fee3210b042672dee799e1dae721c"
            },
            "downloads": -1,
            "filename": "pyorthanc-1.16.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6a9d153549e9660a1fd7183d5832d04d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 156431,
            "upload_time": "2024-02-08T16:13:58",
            "upload_time_iso_8601": "2024-02-08T16:13:58.472401Z",
            "url": "https://files.pythonhosted.org/packages/bb/ea/188e53365dc697fb685b24ffe6d7b547437bc0716d3c5a0a1781e304403b/pyorthanc-1.16.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-08 16:13:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gacou54",
    "github_project": "pyorthanc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyorthanc"
}
        
Elapsed time: 0.19157s