orhanc dicom服务器的rest客户端
orthanc-rest-client的Python项目详细描述
orthanc rest客户端
提供针对Orthancrest api端点的rest客户端。
基于优秀的apiron库。
安装
pip install orthanc-rest-client
如何使用
导入预定义的客户端并传递服务器详细信息
from orthanc_rest_client import Orthanc
orthanc = Orthanc('http://localhost:8042')
# Patient endpoints
orthanc.get_patients()
orthanc.get_patient(id)
...and so on
# Study endpoints
orthanc.get_studies()
orthanc.get_study(id)
...and so on
# Series endpoints
orthanc.get_series()
orthanc.get_one_series(id)
...and so on
# Instance endpoints
orthanc.get_instances()
orthanc.get_instance(id)
...and so on
# Get changes
orthanc.get_changes()
# Find objects by query
query = {'Level': 'Patient',
'Query': {'PatientName': 'Jon*'},
}
orthanc.find(query)
# Get previous queries
orthanc.get_queries()
还有许多其他预配置的端点。
认证
传递有效的身份验证对象:
from requests.auth import HTTPBasicAuth
auth = HTTPBasicAuth('orthanc', 'orthanc')
orthanc = Orthanc('https://test.server.com', auth=auth)
然后正常调用函数(自动传递auth对象)。
高级示例
将实例文件保存到本地目录:
def save_dcm_file(instance_id):
fileName = '.'.join([instance_id, "dcm"])
with open(fileName, 'wb') as dcm:
for chunk in orthanc.get_instance_file(instance_id):
dcm.write(chunk)
http端点
rest客户端将在使用http端点时发出警告。考虑到数据敏感性,强烈考虑使用https。