dcm脱敏以及转nii

  • Post author:
  • Post category:其他

DCM脱敏以及DCM转nii序列

Dcm脱敏
from glob import glob
import pydicom as dicom
# 单个Dcm文件夹脱敏(Dcm文件夹内包含一个病例的Dcm文件)
path = sorted(glob('file_path/*'')) # file_path为Dcm文件夹路径

for file_path in path:
    
    ds = dicom.dcmread(file_path)
    ds.PatientName = 'Invisible'
    ds.PatientID = 'Invisible'
	ds.InstitutionAddress = 'Invisible'
    ds.InstitutionName = 'Invisible'
    ds.save_as(r'./new_file/{}'.format(file_path.split('/')[-1][-16:]))
Dcm转nii
import SimpltITK as sitk

reader = sitk.ImageSeriesReader()
dcmName = reader.GetGDCMSeriesFileNames('file_path') # file_path为Dcm文件夹路径
reader.SetFileNames(dcmName)
sitkData = reader.Execute()
sitk.WriteImage(sitkData, 'new_file.nii.gz')

版权声明:本文为qq_40797296原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。