用于pacs相关操作(echo、find、move和listen)的dcmtk包装器

pypx的Python项目详细描述


https://badge.fury.io/py/pypx.svghttps://travis-ci.org/FNNDSC/pypx.svg?branch=masterhttps://img.shields.io/badge/python-3.5%2B-blue.svg

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

5. Credits

PyDicom

DCMTK

  • 作者:dicom@offices团队

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java类BufferedInputStream导致调试器无法在任何断点中挂起?   java如何固定一捆卡片   java Android:如何将recyclerview滚动条置于recyclerview之上。物品装饰?   递归通用数据结构中的java对象排序   在java中定制ipv6数据包   java复制spring属性文件   java为什么在使用MongoDB和JPA时会出现这个错误?   Java:如何解析大量数据。csv文件?   java为什么嵌套类的私有成员可以被封闭类的方法访问?   安卓 java。lang.RuntimeException:无法实例化应用程序com。项目。App:java。lang.ClassNotFoundException   在java组件xwiki中获取子页面   Java3D获取时间问题   java如何在另一个类中执行某些操作时刷新该类的实例   java无法解析“类型参数不在typevariable的范围内”错误   Java/Android不允许将“this”作为意图声明中的参数   未找到java Trie置换