gacou54 / pyorthanc Goto Github PK
View Code? Open in Web Editor NEWPython library that wrap the Orthanc REST API and facilitate the manipulation of data in Orthanc
License: MIT License
Python library that wrap the Orthanc REST API and facilitate the manipulation of data in Orthanc
License: MIT License
It would be nice to have functions to convert DICOM IDs to the Orthanc IDs.
to_orthanc_patient_id('PatientID')
-> 'orthanc_patient_id'
to_orthanc_study_id('PatientID', 'StudyInstanceUID')
-> 'orthanc_study_id'
...
Related: https://book.orthanc-server.com/faq/orthanc-ids.html#orthanc-identifiers
It could be interesting to have a property in series for shared tags
For instance :
series = pyorthanc.Series (client=client, resource=resource)
series.shared-tags
that would be equivalent to the call :
/series/{resource}/shared-tags
pyorthanc.Study
should have a .description
attribute since this value is often loop at.
I am wondering about the behavior of find function, will it pull stable and unstable resource ? or just stable ones ?
Definition of stable from Orthanc book:
A DICOM resource (patient, study or series) is referred to as stable if it has not received any new instance for a certain amount of time.
Should we always query the Orthanc server when calling resource properties other than the main DICOM tags?
For example, calling .last_update
should probably always query Orthanc.
I'm not sure how many calls this might apply to, but when calling a C-MOVE from a remote modality, the timeout setting in the data dict appears to be just for Orthanc. HTTPX has it's own timeout default of 5s, so if the requested timeout is larger than that and the request does not resolve in 5s, an HTTPX timeout occurs. Using the C-MOVE in the readme as a start:
from pyorthanc import RemoteModality, Orthanc
orthanc = Orthanc('http://localhost:8042', 'username', 'password')
modality = RemoteModality(orthanc, 'modality')
# Query (C-Find) on modality
data = {'Level': 'Study', 'Query': {'PatientID': '*'}}
query_response = modality.query(data=data)
answer = modality.get_query_answers()[query_response['ID']]
print(answer)
# Retrieve (C-Move) results of query on a target modality (AET)
modality.move(query_response['ID'], {'Timeout': 300}) # <-here's the problem
I'm working on a VPN w/ a slow connection, so the move command takes a while.
Without modification, this will always raise an HTTPX timeout, regardless of the timeout setting (since HTTPX is not being passed this setting). It seems like a relatively easy fix; something like:
timeout = cmove_data.get("Timeout", 5)
dict(self.client.post_modalities_id_query(self.modality, json=data, timeout=timeout))
here:
Line 70 in 778b695
You'd need to adjust post_modalities_id_query
and self._post
as well to handle the parameter, but this would at least make HTTPX use the same timeout as requested for Orthanc.
When I adjusted this manually by removing the timeout (by adding timeout=None
) the C-MOVE was successful given enough time.
There won't be osimis/orthanc
docker image releases in the future. The Orthanc Team now releases the docker images under orthancteam/*
.
See this for more details https://discourse.orthanc-server.org/t/osimis-orthanc-docker-images-replaced-by-orthancteam-orthanc/4282
My code and error:
orthanc = Orthanc('http://localhost:8042/', username='orthanc', password='orthanc')
Traceback (most recent call last):
File "", line 1, in
TypeError: init() got an unexpected keyword argument 'username'
Would be nice to have a cleaner way to access to the parent resources. Probably sometime like
series = pyorthanc.Series(...)
study: pyorthanc.Study = series.parent_study
patient: pyorthanc.Patient = series.parent_patient
I am running the latest version of Orthanc (1.12.1) along with pyorthanc 1.11.5 on macOS Ventura 13.5.1 (Apply M2 Pro). I have loaded an fMRI DICOM dataset that contains 73365 DICOM instances and is ~900MB in size. When I try to do a resource modification (anonymization) via pyorthanc, the operation continues to yield a ReadTimeout: timed out error. I have tried setting orthanc.timeout = 20000 but the anonymization process seems to take a very long time and continues to time out. This is what I am using to anonymize:
anonymized_patient = Patient(id, orthanc).anonymize(keep=['PatientName'], replace={'PatientID': 'TheNewPatientID'}, remove=['ReferringPhysicianName'], force=True )
I would expect anonymization to take some time for this size dataset but I'm wondering if there is anything else I can do to have the process complete successfully (i.e. should I use the Async client in this case?). Any help would be greatly appreciated.
PyOrthanc should have a comprehensive ReadTheDocs for users. The actual documentation (README.md) is incomplete and hard to understand.
This code is working :
if __name__ == '__main__':
client = pyorthanc.Orthanc('orthanc', timeout=200, return_raw_response=False)
series = pyorthanc.find_series(client, {'Modality': 'SR'})
But this one is KO :
if __name__ == '__main__':
client = pyorthanc.Orthanc('orthanc', timeout=200, return_raw_response=True)
series = pyorthanc.find_series(client, {'Modality': 'SR'})
We get this error
TypeError: object of type 'Response' has no len()
from this line.
When raw_reponse option is enabled, methods using requests are ko when they are waiting for response.content and get response body instead.
A possibility would be to keep raw_response in inner methods and return content (according to return_raw_response option) in higher levels. @gacou54, what do you think ?
Currently, we have to modify the tags with the client:
import pyorthanc
client = pyorthanc.Orthanc(...)
client.post_studies_id_modify(...)
Would be neat if this would work
patient = Patient(...)
patient.modify()
study = Sudy(...)
study.modify(...)
...
Current pyorthanc.orthanc_sdk
cover the Python Plugin 4.0.
We should update to Python Plugin 4.1
https://www.orthanc-server.com/browse.php?path=/plugin-python
The Patient, Study, Series and Instance def __repr__()
method should probably only display the Orthanc ID.
e.g. Patient(<orthanc-id>), Study(<orthanc-id>), Series(<orthanc-id>), Instance(<orthanc-id>)
There is a typo where the StudyDescription is accessed instead of the SeriesDescription here
pyorthanc/pyorthanc/_resources/series.py
Line 115 in aff2ee3
It would be awesome if the ability to edit Orthanc config file could be edited specially the ability to do things like add/edit/delete things like modalities and users etc.
For each resource, the main tags are retrieved with the .get_main_information()
method.
However, the Orthanc nomenclature refers to the main DICOM tags as the "main dicom tags".
I suggest adding an alias to the get_main_information()
method named get_main_tags()
or get_main_dicom_tags()
to be consistent with Orthanc nomenclature.
Hey, great project!
Could you add a headers parameter to the find
function (
pyorthanc/pyorthanc/filtering.py
Line 30 in b41a7ee
Orthanc
instantiation. We use Orthanc behind a proxy and requires a header. I'd love to use find
via the proxy.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.