免費工具

DICOM 影像標準驗證工具 dciodvfy、dcentvfy 使用教學與範例

ma介紹如何使用 Dicom3tools 工具組中的 dciodvfydcentvfy 指令驗證醫學影像是否符合 DICOM 標準。

dciodvfydcentvfy 兩個指令都包含在 Dicom3tools 工具組中,安裝方式請參考 DICOM 影像工具 Dicom3tools:編譯、安裝、使用教學與範例

dciodvfy 檢測單一 DICOM 影像檔案

dciodvfy 指令工具是由 David Clunie 所開發的 DICOM 標準驗證工具,同時也被 TCIAIHE Connectathon 等單位所採用,可以針對單一 DICOM 影像檔案進行以下檢測:

軟體版本

在使用 dciodvfy 指令工具進行 DICOM 影像檔案檢測時,要注意軟體的版本,加上 -version 參數可以查詢工具的版本:

# 查看 dciodvfy 版本
dciodvfy -version
dicom3tools Version: 1.00.snapshot.20211009110822
dicom3tools Platform: Linux largeimg 5.4.0-87-generic #98~18.04.1-Ubuntu SMP Wed Sep 22 10:45:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
dicom3tools Preprocessor: gcc cpp 7.5.0
dicom3tools Compiler: gcc g++ 7.5.0
dicom3tools UID Root: 1.2.840.99999

檢測 DICOM 影像

若要檢查影像檔案是否符合 DICOM 標準,可以執行 dciodvfy 並在參數中指定輸入的 DICOM 影像檔案名稱即可。

這裡我們以 kaggle 上的 ID_0000_AGE_0060_CONTRAST_1_CT.dcm 這一個 DICOM 影像檔案為例,檢測其是否符合 DICOM 標準:

# 檢測影像是否符合 DICOM 標準
dciodvfy ID_0000_AGE_0060_CONTRAST_1_CT.dcm
Warning - Missing attribute or value that would be needed to build DICOMDIR - Study ID
Warning - Value dubious for this VR - (0x0010,0x0010) PN Patient's Name  PN [1] = <TCGA-17-Z034> - Retired Person Name form
Error - Value invalid for this VR - (0x0013,0x1010) LO Project Name  LO - Trailing character invalid for this VR = '' (0)
Error - Dicom dataset contains invalid data values for Value Representations
Warning - Retired attribute - (0x0008,0x0000) UL Group Length
Warning - Retired attribute - (0x0008,0x0040) US Data Set Type
Warning - Retired attribute - (0x0008,0x0041) LO Data Set Subtype
Warning - Retired attribute - (0x0009,0x0000) UL Group Length
Warning - Retired attribute - (0x0010,0x0000) UL Group Length
Warning - Retired attribute - (0x0011,0x0000) UL Group Length
Warning - Retired attribute - (0x0012,0x0000) UL Group Length
Warning - Retired attribute - (0x0008,0x0000) UL Group Length
Warning - Retired attribute - (0x0008,0x0000) UL Group Length
Warning - Retired attribute - (0x0008,0x0000) UL Group Length
Warning - Retired attribute - (0x0008,0x0000) UL Group Length
Warning - Retired attribute - (0x0008,0x0000) UL Group Length
Warning - Retired attribute - (0x0008,0x0000) UL Group Length
Warning - Retired attribute - (0x0008,0x0000) UL Group Length
Warning - Retired attribute - (0x0008,0x0000) UL Group Length
Warning - Retired attribute - (0x0013,0x0000) UL Group Length
Warning - Retired attribute - (0x0018,0x0000) UL Group Length
Warning - Retired attribute - (0x0019,0x0000) UL Group Length
Warning - Retired attribute - (0x0020,0x0000) UL Group Length
Warning - Retired attribute - (0x0020,0x0030) DS Image Position
Warning - Retired attribute - (0x0020,0x0035) DS Image Orientation
Warning - Retired attribute - (0x0020,0x0050) DS Location
Warning - Retired attribute - (0x0020,0x0070) LO Image Geometry Type
Warning - Retired attribute - (0x0020,0x0080) CS Masking Image
Warning - Retired attribute - (0x0020,0x3100) CS Source Image IDs
Warning - Retired attribute - (0x0020,0x3402) CS Modified Image ID
Warning - Retired attribute - (0x0020,0x3403) DA Modified Image Date
Warning - Retired attribute - (0x0020,0x3405) TM Modified Image Time
Warning - Retired attribute - (0x0020,0x5000) AT Original Image Identification
Warning - Retired attribute - (0x0020,0x5002) LO Original Image Identification Nomenclature
Warning - Retired attribute - (0x0021,0x0000) UL Group Length
Warning - Retired attribute - (0x0028,0x0000) UL Group Length
Warning - Retired attribute - (0x0028,0x0005) US Image Dimensions
Warning - Retired attribute - (0x0028,0x0040) CS Image Format
Warning - Retired attribute - (0x0028,0x0050) LO Manipulated Image
Warning - Retired attribute - (0x0028,0x0060) CS Compression Code
Warning - Retired attribute - (0x0028,0x0200) US Image Location
Warning - Retired attribute - (0x0029,0x0000) UL Group Length
Warning - Retired attribute - (0x0031,0x0000) UL Group Length
Warning - Retired attribute - (0x0032,0x0000) UL Group Length
Warning - Retired attribute - (0x0032,0x4000) LT Study Comments
Warning - Retired attribute - (0x0040,0x0000) UL Group Length
Warning - Retired attribute - (0x0091,0x0000) UL Group Length
Warning - Retired attribute - (0x0095,0x0000) UL Group Length
Warning - Retired attribute - (0x0097,0x0000) UL Group Length
Warning - Retired attribute - (0x0099,0x0000) UL Group Length
Warning - Retired attribute - (0x7003,0x0000) UL Group Length
Warning - Retired attribute - (0x7fe0,0x0000) UL Group Length
Warning - Dicom dataset contains retired attributes
CTImage
Warning - Attribute is not present in standard DICOM IOD - (0x0008,0x0040) US Data Set Type
Warning - Attribute is not present in standard DICOM IOD - (0x0008,0x0041) LO Data Set Subtype
Warning - Attribute is not present in standard DICOM IOD - (0x0018,0x0020) CS Scanning Sequence
Warning - Attribute is not present in standard DICOM IOD - (0x0020,0x0030) DS Image Position
Warning - Attribute is not present in standard DICOM IOD - (0x0020,0x0035) DS Image Orientation
Warning - Attribute is not present in standard DICOM IOD - (0x0020,0x0050) DS Location
Warning - Attribute is not present in standard DICOM IOD - (0x0020,0x0070) LO Image Geometry Type
Warning - Attribute is not present in standard DICOM IOD - (0x0020,0x0080) CS Masking Image
Warning - Attribute is not present in standard DICOM IOD - (0x0020,0x3100) CS Source Image IDs
Warning - Attribute is not present in standard DICOM IOD - (0x0020,0x3402) CS Modified Image ID
Warning - Attribute is not present in standard DICOM IOD - (0x0020,0x3403) DA Modified Image Date
Warning - Attribute is not present in standard DICOM IOD - (0x0020,0x3405) TM Modified Image Time
Warning - Attribute is not present in standard DICOM IOD - (0x0020,0x5000) AT Original Image Identification
Warning - Attribute is not present in standard DICOM IOD - (0x0020,0x5002) LO Original Image Identification Nomenclature
Warning - Attribute is not present in standard DICOM IOD - (0x0028,0x0005) US Image Dimensions
Warning - Attribute is not present in standard DICOM IOD - (0x0028,0x0040) CS Image Format
Warning - Attribute is not present in standard DICOM IOD - (0x0028,0x0050) LO Manipulated Image
Warning - Attribute is not present in standard DICOM IOD - (0x0028,0x0060) CS Compression Code
Warning - Attribute is not present in standard DICOM IOD - (0x0028,0x0200) US Image Location
Warning - Attribute is not present in standard DICOM IOD - (0x0032,0x4000) LT Study Comments
Warning - Attribute is not present in standard DICOM IOD - (0x0040,0x1003) SH Requested Procedure Priority
Warning - Dicom dataset contains attributes not present in standard DICOM IOD - this is a Standard Extended SOP Class

通常檢測的結果需要再經過人工判讀,參照 DICOM 標準規範與 dciodvfy 的說明,才能夠確認問題的嚴重程度,以及是否需要進一步修正。

在這份檢測結果中出現了許多退役屬性(Retired attribute)的警告,代表檔案中含有一些過時的標籤,另外還有一些非標準的屬性(Attribute is not present in standard DICOM IOD),這些問題看起來都不是很嚴重,不會影響到正常的影像使用。

而這裡有一個錯誤是 Project Name 的內容不符合其對應的 VR 規範,結尾處的補充字元不可以使用 NULL(0x00),這個錯誤並不是非常嚴重,在大部分的情況下大概也不會造成問題。若要修正這個錯誤,可以將結尾處的補充字元替換為空白字元即可,以下是用 Pydicom 修正此 DICOM 影像的指令稿:

from pydicom import dcmread

# 讀取 DICOM 檔案
ds = dcmread("ID_0000_AGE_0060_CONTRAST_1_CT.dcm")

# 將 0x00 取代為空白
ds[0x0013,0x1010].value = ds[0x0013,0x1010].value.replace(b'\x00',b' ')

# 另存 DICOM 檔案
ds.save_as("ID_0000_AGE_0060_CONTRAST_1_CT_fixed.dcm")

顯示詳細說明

若要顯示較詳細的說明,可以加上 -describe 參數:

# 顯示詳細說明
dciodvfy -describe ID_0000_AGE_0060_CONTRAST_1_CT.dcm

若需要最詳細的輸出訊息,可以加上 -v-verbose 參數:

# 顯示最詳細說明
dciodvfy -v ID_0000_AGE_0060_CONTRAST_1_CT.dcm

顯示檔案屬性

若要顯示 DICOM 影像的檔案屬性,可以加上 -dump 參數:

# 顯示檔案屬性
dciodvfy -dump ID_0000_AGE_0060_CONTRAST_1_CT.dcm
[略]
(0x7003,0x0000) UL Group Length 	 VR=<UL>   VL=<0x0004>  Used=<F> IE=<Unknown> [0x00000014]
(0x7003,0x0010) LO PrivateCreator 	 VR=<LO>   VL=<0x000c>  Used=<F> IE=<Unknown> <SIEMENS MED >
(0x7fe0,0x0000) UL Group Length 	 VR=<UL>   VL=<0x0004>  Used=<F> IE=<Unknown> [0x00080008]
(0x7fe0,0x0010) OX Pixel Data 	 VR=<OW>   VL=<0x80000>  Used=<T> IE=<Image>

這個輸出與 dcdump 的輸出類似,不過這裡多了各屬性是否用於該 IOD,以及 information entity 的資訊。

新輸出格式

若要讓 dciodvfy 採用新式的輸出格式,可以加上 -new 參數,讓輸出訊息的格式更為一致 (Error/Warning – 屬性路徑 – 訊息 – 內容):

# 以新格式輸出
dciodvfy -new ID_0000_AGE_0060_CONTRAST_1_CT.dcm
Warning - </StudyID(0020,0010)> - Missing attribute or value that would be needed to build DICOMDIR
Warning - </PatientName(0010,0010)[1]> - Value dubious for this VR [PN] = <TCGA-17-Z034> - Retired Person Name form
Error - </(0013,1010,"CTP")> - Value invalid for this VR [LO] - Trailing character invalid for this VR = '' (0)
Warning - </(0008,0000)> - Retired attribute
Warning - </DataSetType(0008,0040)> - Retired attribute
Warning - </DataSetSubtype(0008,0041)> - Retired attribute
Warning - </(0009,0000)> - Retired attribute
Warning - </(0010,0000)> - Retired attribute
Warning - </(0011,0000)> - Retired attribute
Warning - </(0012,0000)> - Retired attribute
Warning - </DeidentificationMethodCodeSequence(0012,0064)[1]/(0008,0000)> - Retired attribute
Warning - </DeidentificationMethodCodeSequence(0012,0064)[2]/(0008,0000)> - Retired attribute
Warning - </DeidentificationMethodCodeSequence(0012,0064)[3]/(0008,0000)> - Retired attribute
Warning - </DeidentificationMethodCodeSequence(0012,0064)[4]/(0008,0000)> - Retired attribute
Warning - </DeidentificationMethodCodeSequence(0012,0064)[5]/(0008,0000)> - Retired attribute
Warning - </DeidentificationMethodCodeSequence(0012,0064)[6]/(0008,0000)> - Retired attribute
Warning - </DeidentificationMethodCodeSequence(0012,0064)[7]/(0008,0000)> - Retired attribute
Warning - </DeidentificationMethodCodeSequence(0012,0064)[8]/(0008,0000)> - Retired attribute
Warning - </(0013,0000)> - Retired attribute
Warning - </(0018,0000)> - Retired attribute
Warning - </(0019,0000)> - Retired attribute
Warning - </(0020,0000)> - Retired attribute
Warning - </ImagePosition(0020,0030)> - Retired attribute
Warning - </ImageOrientation(0020,0035)> - Retired attribute
Warning - </Location(0020,0050)> - Retired attribute
Warning - </ImageGeometryType(0020,0070)> - Retired attribute
Warning - </MaskingImage(0020,0080)> - Retired attribute
Warning - </SourceImageIDs(0020,3100)> - Retired attribute
Warning - </ModifiedImageID(0020,3402)> - Retired attribute
Warning - </ModifiedImageDate(0020,3403)> - Retired attribute
Warning - </ModifiedImageTime(0020,3405)> - Retired attribute
Warning - </OriginalImageIdentification(0020,5000)> - Retired attribute
Warning - </OriginalImageIdentificationNomenclature(0020,5002)> - Retired attribute
Warning - </(0021,0000)> - Retired attribute
Warning - </(0028,0000)> - Retired attribute
Warning - </ImageDimensions(0028,0005)> - Retired attribute
Warning - </ImageFormat(0028,0040)> - Retired attribute
Warning - </ManipulatedImage(0028,0050)> - Retired attribute
Warning - </CompressionCode(0028,0060)> - Retired attribute
Warning - </ImageLocation(0028,0200)> - Retired attribute
Warning - </(0029,0000)> - Retired attribute
Warning - </(0031,0000)> - Retired attribute
Warning - </(0032,0000)> - Retired attribute
Warning - </StudyComments(0032,4000)> - Retired attribute
Warning - </(0040,0000)> - Retired attribute
Warning - </(0091,0000)> - Retired attribute
Warning - </(0095,0000)> - Retired attribute
Warning - </(0097,0000)> - Retired attribute
Warning - </(0099,0000)> - Retired attribute
Warning - </(7003,0000)> - Retired attribute
Warning - </(7fe0,0000)> - Retired attribute
CTImage
Warning - </DataSetType(0008,0040)> - Attribute is not present in standard DICOM IOD
Warning - </DataSetSubtype(0008,0041)> - Attribute is not present in standard DICOM IOD
Warning - </ScanningSequence(0018,0020)> - Attribute is not present in standard DICOM IOD
Warning - </ImagePosition(0020,0030)> - Attribute is not present in standard DICOM IOD
Warning - </ImageOrientation(0020,0035)> - Attribute is not present in standard DICOM IOD
Warning - </Location(0020,0050)> - Attribute is not present in standard DICOM IOD
Warning - </ImageGeometryType(0020,0070)> - Attribute is not present in standard DICOM IOD
Warning - </MaskingImage(0020,0080)> - Attribute is not present in standard DICOM IOD
Warning - </SourceImageIDs(0020,3100)> - Attribute is not present in standard DICOM IOD
Warning - </ModifiedImageID(0020,3402)> - Attribute is not present in standard DICOM IOD
Warning - </ModifiedImageDate(0020,3403)> - Attribute is not present in standard DICOM IOD
Warning - </ModifiedImageTime(0020,3405)> - Attribute is not present in standard DICOM IOD
Warning - </OriginalImageIdentification(0020,5000)> - Attribute is not present in standard DICOM IOD
Warning - </OriginalImageIdentificationNomenclature(0020,5002)> - Attribute is not present in standard DICOM IOD
Warning - </ImageDimensions(0028,0005)> - Attribute is not present in standard DICOM IOD
Warning - </ImageFormat(0028,0040)> - Attribute is not present in standard DICOM IOD
Warning - </ManipulatedImage(0028,0050)> - Attribute is not present in standard DICOM IOD
Warning - </CompressionCode(0028,0060)> - Attribute is not present in standard DICOM IOD
Warning - </ImageLocation(0028,0200)> - Attribute is not present in standard DICOM IOD
Warning - </StudyComments(0032,4000)> - Attribute is not present in standard DICOM IOD
Warning - </RequestedProcedurePriority(0040,1003)> - Attribute is not present in standard DICOM IOD

顯示檔案名稱

若要在 dciodvfy 的輸出中顯示檔案名稱,可以加上 -filename 參數:

# 顯示檔案名稱
dciodvfy -filename ID_0000_AGE_0060_CONTRAST_1_CT.dcm
Filename: "ID_0000_AGE_0060_CONTRAST_1_CT.dcm"
Warning - Missing attribute or value that would be needed to build DICOMDIR - Study ID
Warning - Value dubious for this VR - (0x0010,0x0010) PN Patient's Name  PN [1] = <TCGA-17-Z034> - Retired Person Name form
Error - Value invalid for this VR - (0x0013,0x1010) LO Project Name  LO - Trailing character invalid for this VR = '' (0)
Error - Dicom dataset contains invalid data values for Value Representations
Warning - Retired attribute - (0x0008,0x0000) UL Group Length
[略]

dcentvfy 檢測多 DICOM 檔案屬性一致性

dcentvfy 指令工具可以用於檢測多個 DICOM 檔案之間的屬性一致性,例如在同一個 Study 或同一個 Series 之下應該要一致的屬性等,同時也會檢查有無重複的 SOP Instance UIDs。

# 檢測多個 DICOM 檔案屬性一致性
dcentvfy *.dcm

檢測檔案清單

若檔案輸量很龐大,或是散落在不同地方,可以使用 -f-filelist 參數來指定檔案清單,透過檔案清單來指定要檢測的 DICOM 影像檔案(檔案清單的格式為一行一個 DICOM 檔案路徑):

# 透過檔案清單指定 DICOM 檔案
dcentvfy -f filelist.txt

詳細輸出

若想要輸出詳細的訊息,可以加上 -v 參數:

# 詳細輸出
dcentvfy -v *.dcm

若加上 -vv 參數,可以輸出最詳盡的訊息:

# 最詳細輸出
dcentvfy -vv *.dcm

參考資料

Share
Published by
Office Guide
Tags: DICOM

Recent Posts

Python 使用 PyAutoGUI 自動操作滑鼠與鍵盤

本篇介紹如何在 Python ...

9 個月 ago

Ubuntu Linux 以 WireGuard 架設 VPN 伺服器教學與範例

本篇介紹如何在 Ubuntu ...

9 個月 ago

Linux 網路設定 ip 指令用法教學與範例

本篇介紹如何在 Linux 系...

9 個月 ago

Windows 使用 TPM 虛擬智慧卡保護 SSH 金鑰教學與範例

本篇介紹如何在 Windows...

10 個月 ago

Linux 以 Shamir’s Secret Sharing 分割保存金鑰教學與範例

介紹如何在 Linux 中使用...

11 個月 ago

Linux 以 Cryptsetup、LUKS 加密 USB 隨身碟教學與範例

介紹如何在 Linux 系統中...

11 個月 ago