Something Important for Me in Pydicom User Giude

1. Core elements in pydicom

1.1 Dataset

Dataset(数据集)是一个字典数据类型,键是 DICOM tag,值是 DataElemtne instance。可以直接通过标签(tags)访问数据成员(data element)。

访问 Dataset 中的数据:

import pydicom
# 导入数据集⬇
path = "D:/Master/核素治疗/王宁20200815/DICOM/20200828/18100000(ECT图像)/93441326"
ds = pydicom.dcmread(path)  # Dataset 简称 ds

# 显示 ds 的信息的第一种方法⬇

print(ds)
>> 
Dataset.file_meta -------------------------------
(0002, 0000) File Meta Information Group Length  UL: 196
(0002, 0001) File Meta Information Version       OB: b'\x00\x01'
... ...
(0010, 0010) Patient's Name                      PN: 'WANG NING'
(0010, 0020) Patient ID                          LO: '20200815'
(0010, 0030) Patient's Birth Date                DA: '19830815'
... ...
(0028, 0002) Samples per Pixel                   US: 3
(0028, 0004) Photometric Interpretation          CS: 'RGB'
(0028, 0006) Planar Configuration                US: 0
(0028, 0010) Rows                                US: 512
(0028, 0011) Columns                             US: 512
... ...
(7fe0, 0010) Pixel Data                          OW: Array of 786432 elements

# 显示 ds 的信息的第二种方法⬇
print(ds.PatientName)  # 键值访问的语法用“.”
>> WANG NING

# 显示 ds 的信息的第三种方法(将 Dataset 中的信息存入字典中)⬇ (导入数据集的操作如前4行)
info = {}  # 字典初始化
info["Rows"] = ds.Rows                         # 在 Dicom 格式图像中像素的行数
info["Columns"] = ds.Columns                   # 在 Dicom 格式图像中像素的列数

访问像素数据:
可通过关键词 PixelData 获得(7FE0,0010) 中的原始 Pixel Data(像素数据)

1.2 DataElement

1.3 Tag

1.4 Sequence

2. Writing DICOM Files

Introduction

Using the Codify Script

Writing a file from Scratch

3. Working with Pixel Data

Introduction

Dataset.pixel_array

Color space

Palette Color

Modality LUT or Rescale Operation

VOI LUT or Windowing Operation

4. Working with Overlay Data

Introduction

Dataset.overlay_array()

5. Working with Waveform Data

Introduction

Dataset.waveform_array()

6. Handling of compressed pixel data

Preconditions

Supported Transfer Syntaxes

Usage

7. Viewing Images

Introduction

Using pydicom with matplotlib

Using pydicom with Tkinter

Using pydicom with Python Imaging Library (PIL)

Using pydicom with Python Imaging Library (PIL)

8. Private Data Elements

Introduction

Displaying Private Data Elements in pydicom

Setting Private Data Elements with pydicom

Removing All Private Data Elements

9. Best Practices

Introduction

Enforcing Valid DICOM

Future-proofing your code

Limiting the pydicom major version in your package

上一篇:《简·爱》


下一篇:融云 Web 播放声音 — Flash 篇 (播放 AMR、WAV)