DICOM

  • 의료 영상 데이터를 저장하고 전송하기 위한 표준 파일 형식
  • 의료 영상을 디지털 형식으로 저장하고 공유하는 데 사용
  • 다양한 의료 기기(X-ray, CT 스캔, MRI, 초음파 등)와 시스템 간에 데이터를 교환하는 데 쓰임
  • 국제표준
    • DICOM Standard https://www.dicomstandard.org/current
    • 다른 의료 기기나 시스템과의 상호 운용성을 보장
  • 보안과 개인 정보 보호
  • 데이터
    • Image(Pixel data) + Metadata(Header)
    • Data Examples
      • 포함되는 정보
      • 환자 정보(이름, 주민등록번호 등)
        • Patient Name: 환자 이름
        • Patient ID: 환자 식별자
      • 영상 정보(픽셀 값, 크기, 모달리티 등)
        • SOP Class UID (Service-Object Pair Class Unique Identifier)
        • SOP Instance UID (Service-Object Pair Instance Unique Identifier)
        • Transfer Syntax UID (인코딩 방식을 식별하는 식별자)
        • Modality (영상 획득에 사용된 기술의 종류, 코드. ex) CT, MR, XA 등)
        • Pixel Data (실제 영상 데이터)
      • 기타 메타데이터(획득 시간, 기기 정보 등)
        • Study Date: 영상 획득 날짜
        • Study Time: 영상 획득 시간
  • See source, Dicom.py #
    pip install pydicom
    

    ```py

    Verified

    import numpy as np import pydicom from pydicom.dataset import Dataset, FileDataset from pydicom.uid import ImplicitVRLittleEndian

Create a new DICOM dataset

dataset = Dataset()

Set DICOM data elements

dataset.PatientName = “John Doe” dataset.PatientID = “12345” dataset.Modality = “CT” dataset.SeriesDescription = “CT Scan” dataset.Rows = 512 dataset.Columns = 512 dataset.PixelSpacing = [0.976562, 0.976562] dataset.BitsAllocated = 16 dataset.BitsStored = 16 dataset.HighBit = 15 dataset.PixelRepresentation = 0

Create a simple 2D image using NumPy (512x512 with a circle)

image_size = (512, 512) x, y = np.ogrid[:image_size[0], :image_size[1]] circle_center = (image_size[0] // 2, image_size[1] // 2) radius = 100 mask = (x - circle_center[0]) ** 2 + (y - circle_center[1]) ** 2 < radius ** 2 image_data = np.zeros(image_size, dtype=np.uint16) image_data[mask] = 1000 # Set pixel values inside the circle to 1000

Convert image data to bytes and set to DICOM dataset

dataset.PixelData = image_data.tobytes()

Set DICOM file meta information

file_meta = Dataset() file_meta.MediaStorageSOPClassUID = pydicom.uid.ImplicitVRLittleEndian file_meta.MediaStorageSOPInstanceUID = pydicom.uid.generate_uid() file_meta.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian

Set the file meta information in the dataset

dataset.file_meta = file_meta

Set output file path

output_file = “example.dcm”

Save the dataset as a DICOM file

dataset.save_as(output_file)

print(f”DICOM file has been created: {output_file}”) ```

  • Viewer:
    • Mac:
      • OsiriX(powerful)
      • Horos(free, basic)
    • Window:
      • RadiAnt DICOM Viewer(powerful)
      • Microdicom(free, basic) https://www.microdicom.com/
    • Both:
      • 3D Slicer(free, powerful)