用于pacs相关操作(echo、find、move和listen)的dcmtk包装器
pypx的Python项目详细描述
目录
1. Overview
pypx是围绕dcmtk和pydicom的一个简单的python包装器。它提供了4种与pacs交互的简单方法:
- px echo:ping pacs以确保其联机(echoscu)。
- px find:在pacs上查找数据(findscu)。
- px移动:从pacs中移动数据(movescu)。
- px侦听:侦听来自pacs的传入数据(storescp)。
2. Installation
apt-get update \ && apt-get install -y dcmtk \ && apt-get install -y python3-pip python3-dev \ && pip3 install --upgrade pip \ && pip install pypx
3. Usage
px-echo
about px-echo
px-echo是dcmtkechoscu的包装。
It sends a DICOM C-ECHO message to a Service Class Provider (SCP) and waits for a response. The application can be used to verify basic DICOM connectivity. -- DCMTK, about echoscu.
px-echo script
# need some help? px-echo --help # ping Orthanc PACS server # calling aet: CHIPS # called aet: ORTHANC # Orthanc PACS server IP: 127.0.0.1 # Orthanc PACS server port: 4242 # echoscu executable: /usr/local/bin/echoscu px-echo --aet CHIPS --aec ORTHANC --serverIP 127.0.0.1 --serverPort 4242 --executable /usr/local/bin/echoscu # output # { 'status': 'success', # 'command': '/usr/local/bin/echoscu --timeout 5 -aec ORTHANC -aet CHIPS 127.0.0.1 4242', # 'data': ''}
px-echo module
# in yourscript.pyimportpypxpacs_settings={'executable':'/usr/local/bin/echoscu','aec':'ORTHANC','aet':'CHIPS','server_ip':'127.0.0.1','server_port':'4242',}output=pypx.echo(pacs_settings)print(output)# output:# {# 'command': '/bin/echoscu --timeout 5 -aec MY-AEC -aet MY-AET 192.168.1.110 4242',# 'data': '',# 'status': 'success'# }
px-find
about px-find
px-find是dcmtkfindscu的包装。
在给定大量参数的pacs服务器上查找序列。完整列表请参见px-find--help。
It sends query keys to an SCP and awaits responses. The application can be used to test SCPs of the Query/Retrieve and Basic Worklist Management Service Classes. -- DCMTK, about findscu.
px-find script
# need some help? px-find --help # find data in Orthanc PACS server # calling aet: CHIPS # called aet: ORTHANC # Orthanc PACS server IP: 127.0.0.1 # Orthanc PACS server port: 4242 # findscu executable: /usr/local/bin/findscu px-find --aet CHIPS --aec ORTHANC --serverIP 127.0.0.1 --serverPort 4242 --executable /usr/local/bin/findscu \ --patientID 32124# output # {'status': 'success', # 'command': '/usr/local/bin/findscu -xi -S # -k InstanceNumber # -k ModalitiesInStudy # -k NumberOfSeriesRelatedInstances # -k PatientBirthDate # -k "PatientID=32124" # -k PatientName # -k PatientSex # -k PerformedStationAETitle # -k "QueryRetrieveLevel=SERIES" # -k SeriesDate # -k SeriesDescription # -k SeriesInstanceUID # -k StudyDate # -k StudyDescription # -k StudyInstanceUID # -aec ORTHANC -aet CHIPS 127.0.0.1 4242', # 'data': [lot of stuff if a match] # [] if no results # }
px-find module
# in yourscript.pyimportpypxpacs_settings={'executable':'/usr/local/bin/findscu','aec':'ORTHANC','aet':'CHIPS','server_ip':'127.0.0.1','server_port':'4242',}# query parametersquery_settings={'PatientID':32124,}# python 3.5 ** syntaxoutput=pypx.find({**pacs_settings,**query_settings})print(output)# output# {'status': 'success',# 'command': '/usr/local/bin/findscu -xi -S# -k InstanceNumber# -k ModalitiesInStudy# -k NumberOfSeriesRelatedInstances# -k PatientBirthDate# -k "PatientID=32124"# -k PatientName# -k PatientSex# -k PerformedStationAETitle# -k "QueryRetrieveLevel=SERIES"# -k SeriesDate# -k SeriesDescription# -k SeriesInstanceUID# -k StudyDate# -k StudyDescription# -k StudyInstanceUID# -aec ORTHANC -aet CHIPS 127.0.0.1 4242',# 'data': [lot of stuff if a match] # [] if no results# }
px-move
about px-move
px-move是dcmtkmovescu的包装。
根据序列的uid移动序列。seriesuid可以用px-find检索。
It sends query keys to an SCP and awaits responses. The application can be used to test SCPs of the Query/Retrieve Service Class. The movescu application can initiate the transfer of images to a third party or can retrieve images to itself. -- DCMTK, about movescu.
px-move script
px-move --help # move data from Orthanc PACS server to AETL # calling aet: CHIPS # calling aet that will receive the data: CHIPS # called aet: ORTHANC # Orthanc PACS server IP: 127.0.0.1 # Orthanc PACS server port: 4242 # movescu executable: /usr/local/bin/movescu px-move --aet CHIPS --aetl CHIPS --aec ORTHANC --serverIP 127.0.0.1 --serverPort 4242 --executable /usr/local/bin/movescu \ --seriesUID 1.3.12.2.1107.5.2.32.35235.2012041417312491079284166.0.0.0 # output # {'status': 'success', # 'command': '/usr/local/bin/movescu --move CHIPS --timeout 5 # -k QueryRetrieveLevel=SERIES # -k SeriesInstanceUID=1.3.12.2.1107.5.2.32.35235.2012041417312491079284166.0.0.0 # -aec ORTHANC -aet CHIPS 127.0.0.1 4242', # 'data': '' # }
px-move module
# in yourscript.pyimportpypxpacs_settings={'executable':'/usr/local/bin/findscu','aec':'ORTHANC','aet':'CHIPS','server_ip':'127.0.0.1','server_port':'4242',}# query parametersquery_settings={'SeriesInstanceUID':'1.3.12.2.1107.5.2.32.35235.2012041417312491079284166.0.0.0',}# python 3.5 ** syntaxoutput=pypx.move({**pacs_settings,**query_settings})print(output)# output# {'status': 'success',# 'command': '/usr/local/bin/movescu --move CHIPS --timeout 5# -k QueryRetrieveLevel=SERIES# -k SeriesInstanceUID=1.3.12.2.1107.5.2.32.35235.2012041417312491079284166.0.0.0# -aec ORTHANC -aet CHIPS 127.0.0.1 4242',# 'data': ''# }
px-listen
about px-listen
px-listen是dcmtkstorescp的包装。
它应该连接到守护进程/服务,以便充当DICOM_Listener。
It listens on a specific TCP/IP port for incoming association requests from a Storage Service Class User (SCU). It can receive both DICOM images and other DICOM composite objects. -- DCMTK, about storescp.
px-listen script
px-listen --help
# receive DICOM data Orthanc PACS server
# tmp directory to store the data before ordering: /tmp
# log directory to log all incoming/processing data : /incoming/log
# data directory to store ordered data : /incoming/data
# storescp executable: /usr/local/bin/storescp
px-listen -t /tmp -l /incoming/log -d /incoming/data --executable /usr/local/bin/storescp
4. Local testing
下面是要测试然后运行的二进制命令中的uncomment first 2 imports。
python3 bin/px-find --aet CHIPS --aec CHIPS --serverIP 192.168.0.1 --serverPort 4242