Raspberry PiでDCMTK 3.6.5を使ってみた

#環境
Raspberry Pi 4B(メモリ4GB)
Raspberry Pi OS 10.4

# ビルドおよびインストール

ソースコードは以下から入手
https://dicom.offis.de/dcmtk.php.en

```
$ tar zxvf dcmtk-3.6.5.tar.gz
$ cd dcmtk-3.6.5/
$ mkdir build
$ cd build/
$ cmake ../
$ make
$ sudo make install
```

ビルド時間は、Raspberry Pi 4B(メモリ4GB)で1時間弱ぐらい

# DICOMサーバーの起動

設定ファイルは以下を参考に作成
dcmtk-3.6.5/dcmqrdb/etc/dcmqrscp.cfg

(元の設定から変更点のみ抜粋)

```dcmqrscp.cfg
#acme1           = (ACME1, acmehost1, 5678)
acme1           = (ACME1, localhost, 5678)

#ACME_STORE   /home/dicom/db/ACME_STORE   RW (9, 1024mb)   acmeCTcompany
ACME_STORE   /home/pi/work/dicom_db/ACME_STORE   RW (9, 1024mb)   acmeCTcompany
```

index.datを作成後に、DICOMサーバーを起動する

```
$ dcmqridx /home/pi/work/dicom_db/ACME_STORE
$ dcmqrscp -d -c dcmqrscp.cfg 5678
```

C-ECHOで動作しているか確認

```
$ echoscu -v localhost 5678 -aec ACME_STORE -aet ACME1
I: Requesting Association
I: Association Accepted (Max Send PDV: 16372)
I: Sending Echo Request (MsgID 1)
I: Received Echo Response (Success)
I: Releasing Association
```

サーバー側の設定が正しくないと以下のようにRejectされる

```
$ echoscu -v localhost 5678 -aec ACME_STORE -aet ACME1
I: Requesting Association
F: Association Rejected:
F: Result: Rejected Permanent, Source: Service User
F: Reason: Called AE Title Not Recognized
```

# DICOM画像ファイルの送信

送信ファイルは以下のものを使用
http://www.jira-net.or.jp/dicom/dicom_data_01_02.html

モダリティがSC(SecondaryCapture)、IR6(ascii)形式のJPEG画像を転送

```
$ dcmsend -v localhost 5678 -aec ACME_STORE -aet ACME1 SC_JPG_IR6a.dcm 
I: checking input files ...
I: starting association #1
I: initializing network ...
I: negotiating network association ...
I: Requesting Association
I: Association Accepted (Max Send PDV: 16372)
I: sending SOP instances ...
I: Converting transfer syntax: JPEG Lossless, Non-hierarchical, 1st Order Prediction -> Little Endian Explicit
I: Sending C-STORE Request (MsgID 1, SC)
I: Received C-STORE Response (Success)
I: Releasing Association
I: 
I: Status Summary
I: --------------
I: Number of associations   : 1
I: Number of pres. contexts : 1
I: Number of SOP instances  : 1
I: - sent to the peer       : 1
I:   * with status SUCCESS  : 1
```

ちなみに上記のDICOM画像ファイルをダンプすると以下のようになっている

```
$ dcmdump SC_JPG_IR6a.dcm 
```

```SC_JPG_IR6a.dcm
# Dicom-File-Format

# Dicom-Meta-Information-Header
# Used TransferSyntax: Little Endian Explicit
(0002,0000) UL 174                                      #   4, 1 FileMetaInformationGroupLength
(0002,0001) OB 00\01                                    #   2, 1 FileMetaInformationVersion
(0002,0002) UI =SecondaryCaptureImageStorage            #  26, 1 MediaStorageSOPClassUID
(0002,0003) UI [1.2.392.200036.8120.100.20110121.1184002.2001003001] #  52, 1 MediaStorageSOPInstanceUID
(0002,0010) UI =JPEGLossless:Non-hierarchical-1stOrderPrediction #  22, 1 TransferSyntaxUID
(0002,0012) UI [1.2.826.0.1.3680043.2.1545.1]           #  28, 1 ImplementationClassUID

# Dicom-Data-Set
# Used TransferSyntax: JPEG Lossless, Non-hierarchical, 1st Order Prediction
(0008,0008) CS [DERIVED\SECONDARY]                      #  18, 2 ImageType
(0008,0016) UI =SecondaryCaptureImageStorage            #  26, 1 SOPClassUID
(0008,0018) UI [1.2.392.200036.8120.100.20110121.1184002.2001003001] #  52, 1 SOPInstanceUID
(0008,0020) DA [20110121]                               #   8, 1 StudyDate
(0008,0023) DA [20110121]                               #   8, 1 ContentDate
(0008,0030) TM [184002.000]                             #  10, 1 StudyTime
(0008,0033) TM [184002.000]                             #  10, 1 ContentTime
(0008,0050) SH [00000001]                               #   8, 1 AccessionNumber
(0008,0060) CS [CT]                                     #   2, 1 Modality
(0008,0064) CS [WSD]                                    #   4, 1 ConversionType
(0008,0070) LO [JIRA]                                   #   4, 1 Manufacturer
(0008,0080) LO [JIRA HOSPITAL]                          #  14, 1 InstitutionName
(0008,0090) PN [SHIROGANE^HIDEO]                        #  16, 1 ReferringPhysicianName
(0008,1090) LO [SC0001]                                 #   6, 1 ManufacturerModelName
(0010,0010) PN [SHINANOMACHI^TOWAKO]                    #  20, 1 PatientName
(0010,0020) LO [2011012106]                             #  10, 1 PatientID
(0010,0030) DA [19800302]                               #   8, 1 PatientBirthDate
(0010,0040) CS [F]                                      #   2, 1 PatientSex
(0018,5100) CS [HFS]                                    #   4, 1 PatientPosition
(0020,000d) UI [1.2.392.200036.8120.100.20110121.1184002.2001] #  46, 1 StudyInstanceUID
(0020,000e) UI [1.2.392.200036.8120.100.20110121.1184002.2001003] #  48, 1 SeriesInstanceUID
(0020,0010) SH [38]                                     #   2, 1 StudyID
(0020,0011) IS [3]                                      #   2, 1 SeriesNumber
(0020,0013) IS [1]                                      #   2, 1 InstanceNumber
(0020,0020) CS [L\P]                                    #   4, 2 PatientOrientation
(0028,0002) US 1                                        #   2, 1 SamplesPerPixel
(0028,0004) CS [MONOCHROME2]                            #  12, 1 PhotometricInterpretation
(0028,0010) US 512                                      #   2, 1 Rows
(0028,0011) US 512                                      #   2, 1 Columns
(0028,0100) US 16                                       #   2, 1 BitsAllocated
(0028,0101) US 16                                       #   2, 1 BitsStored
(0028,0102) US 15                                       #   2, 1 HighBit
(0028,0103) US 1                                        #   2, 1 PixelRepresentation
(0028,1050) DS [0]                                      #   2, 1 WindowCenter
(0028,1051) DS [1]                                      #   2, 1 WindowWidth
(7fe0,0010) OB (PixelSequence #=2)                      # u/l, 1 PixelData
  (fffe,e000) pi 00\00\00\00                              #   4, 1 Item
  (fffe,e000) pi ff\d8\ff\c4\00\16\00\01\01\01\00\00\00\00\00\00\00\00\00\00\00\00... # 51800, 1 Item
(fffe,e0dd) na (SequenceDelimitationItem)               #   0, 0 SequenceDelimitationItem
```