[DICOM] DCMTK - PACS

Posted by William Basics on Wednesday, December 7, 2022

DCMTK - PACS

概述

本篇将介绍如何利用DCMTK在Windows 10系统中部署一个简单的PACS系统,并利用DCMTK提供的工具来验证PACS提供的四类服务。

概念

  • PACS

    PACS是 Picture Archiving and Communication System 的简称,主要用于医院的数字医疗设备如 CT、MR(磁共振)、US(超声成像、X-Ray、 DSA (数字减影、 CR(计算机成像)、ECT 等设备所产生的数字化医学图像信息的采集、存储、管理、诊断和信息处理。

  • DCMTK

    DCMTK是由offis公司提供的开源项目,已经基本实现了DICOM协议的所有内容。在github上有其代码库的镜像 https://github.com/DCMTK/dcmtk

安装DCMTK

在Windows 10,安装DCMTK十分方便,可以直接通过Windows第三方包管理器chocolatey来安装。(需要预先安装一下)

以管理员权限启动一个命令行工具,运行以下命令

> choco install dcmtk

安装完毕后,我们就可以开始着手启动PACS了。

启动PACS

dcmqrscp.exe

在DCMTK中,PACS的服务是由 dcmqrscp.exe 来提供的。

DICOM协议中规定了PACS至少支持以下5种服务

  1. Verification - 验证服务器是否符合DICOM标准
  2. Storage - 将DICOM对象存储到PACS服务器
  3. Query - 根据指定的关键字查询PACS数据库
  4. Retrieve - 从PACS服务器下载图像到本地
  5. Storage commitment(DCMTK开源版本不支持)

开源版本的dcmqrscp.exe 支持前4种服务。这四种服务分别对应了DCMTK中的

echoscu.exe → Verification

storescu.exe → Storage

findscu.exe → Query

movescu.exe → Retrieve

顺便提一下,“*scp”*是 Service Class Provider的简称,“*scu”*是 Service Class User的简称。它们都是DICOM标准中的概念。

dcmqrscp.cfg 配置文件

DCMTK中包含了一个dcmqrscp.cfg 的sample,里边注释挺全的,可以拿来参考。

#
# Global Configuration Parameters
#
# 监听端口
NetworkTCPPort  = 10001
# 定义PDU传输时刻的最大长度
MaxPDUSize      = 16384
# 允许的最大连接数
MaxAssociations = 16

#
# Default settings for specific character set behavior:
# SpecificCharacterSet = fallback

#
# Uncomment to override response character set with UTF-8 and enable
# transliteration and discarding of unsupported characters:
# SpecificCharacterSet = "ISO_IR 192", override, discard, transliterate

#
# UserName      = <not used>
# GroupName     = <not used>

HostTable BEGIN
#
# The HostTable defines symbolic names for collections of network
# DICOM Application Entities.  A symbolic name can represent a single
# application entity or it can represent a group of application entities.
# Each DICOM application entity is defined by a triple consisting of
# Application Entity Title, host name and TCP/IP port number.
#
# Entry Format: SymbolicName = ( AETitle, HostName, Portnumber ), ...   |
#               SymbolicName = SymbolicName, ...
#
# NOTE: in the current implementation you cannot substitute an IP address
# for a hostname.
#
acme1           = (ACME1, PC098, 5678)
acmeCTcompany   = acme1
# acme2           = (ACME2, acmehost2, 5678)
# acmeCTcompany   = acme1, acme2
# united1         = (UNITED1, unitedhost1, 104)
# united2         = (UNITED2, unitedhost2, 104)
# unitedMRcompany = united1, united2
#
HostTable END

VendorTable BEGIN
#
# The VendorTable is used by the dcmqrdb and dcmqrti applications.
# You can give a vendor name (r.h.s. entry below) to the dcmqrti
# program and it will talk to all hosts and AEs of the vendor.
# The dcmqrdb program can use the vendor table to restrict move destination
# to hosts belonging to a vendor.
# Also, the dcmqrti and dcmqrdb programs use the name defined on the left hand side
# as the vendor name to display above images.
#
# The format:
#       VendorName = SymbolicName
# The symbolic name should be defined in the HostTable.
#
"Acme CT Company"   = acmeCTcompany
# "United MR Company" = unitedMRcompany
#
VendorTable END

AETable BEGIN
#
# Each row of the AETable defines an Application Entities (AE) Title known
# to the dcmqrdb application.  Each AE Title represents a separate
# image database located in the specified file system directory (storage area).
# Each AE Title has read/write, quota and peer access restrictions.
#
# Entry Format: AETitle  StorageArea  Access  Quota  Peers
# AccessFormat: R | RW | W
# Quota Format: ( maxStudies, maxBytesPerStudy )
# Peers Format: ( Hostname, AETitle, Portnumber ), ...  |
#               Entry in HostTable                      |
#               ANY
#
# COMMON       /home/dicom/db/COMMON       R  (200, 1024mb) ANY
ACME_STORE   C:\temp\PACS   RW (9, 1024mb)   acmeCTcompany
# UNITED_STORE /home/dicom/db/UNITED_STORE RW (9, 1024mb)   unitedMRcompany
#
AETable END

启动

运行以下指令

> dcmqrscp.exe -d --config "path\to\dcmqrscp.cfg"

同PACS交互

Verification

在DCMTK中通过 echoscu.exe 来完成。

> echoscu localhost 10001 -aet ACME1 -aec ACME_STORE -d

成功运行后,会有以下类似打印

pacs

pacs

Storage

在DCMTK中通过 storescu.exe 来完成。

storescu localhost 10001 c:\temp\IMG00002 -aet ACME1 -aec ACME_STORE -d

运行成功的话,会有以下类似打印。

pacs

Query

在DCMTK中通过 findscu.exe 来完成。

findscu.exe -v -S -aec ACME_STORE -aet ACME1 localhost 10001 -k QueryRetrieveLevel=STUDY -k StudyDate -k StudyDescription -k StudyInstanceUID

成功运行后,会有以下类似打印

pacs

记住这个1.2.840.113704.1.111.8132.1603688240.1 ,后面验证Retrieve会用到。

Retrieve

在DCMTK中通过 movescu.exe 来完成。

movescu.exe -v -S -aec ACME_STORE -aet ACME1 -aem ACME1 --port 5678 -od c:\temp2 localhost 10001 -k QueryRetrieveLevel=STUDY -k StudyInstanceUID=1.2.840.113704.1.111.8132.1603688240.1 -d

成功运行后,会有以下类似打印

pacs

在下载路径 C:\temp2 下,我们可以看到新文件下载完成了。

pacs

总结

至此,我们安装好了DCMTK,启动了PACS,然后简单验证了PACS的四种服务。

🔚