tsha-mri-tumor-labeling/src/check_dicom.py

27 lines
835 B
Python
Raw Normal View History

import pydicom
import os
import sys
filepath = "/mnt/nextcloud/2026/計畫/TSHA_腦腫瘤驗證標記資料/Brain Tumor Label example/1.2.826.0.1.3680043.8.498.16118352232694493510220170548312112804.dcm"
try:
ds = pydicom.dcmread(filepath)
print(f"Transfer Syntax: {ds.file_meta.TransferSyntaxUID}")
try:
arr = ds.pixel_array
print("Successfully accessed pixel_array")
# Try converting to uncompressed
ds.decompress()
print("Successfully decompressed")
except Exception as e:
print(f"Error accessing pixel_array or decompressing: {e}")
# Check for handlers
import pydicom.uids
print(f"Available handlers for this syntax: {pydicom.config.pixel_data_handlers}")
except Exception as e:
print(f"Error reading file: {e}")