赞
踩
import pydicom
# Read DICOM file
dataset = pydicom.dcmread("path_to_dicom_file.dcm")
# Access metadata and pixel data
patient_name = dataset.PatientName
pixel_array = dataset.pixel_array
import SimpleITK as sitk
# Read DICOM file
image = sitk.ReadImage("path_to_dicom_file.dcm")
# Access metadata and pixel data
spacing = image.GetSpacing()
pixel_array = sitk.GetArrayFromImage(image)
import itk
# Read DICOM series
series_reader = itk.ImageSeriesReader.New()
series_reader.SetFileNames("path_to_dicom_series/*.dcm")
series_reader.Update()
# Access metadata and pixel data
image = series_reader.GetOutput()
spacing = image.GetSpacing()
pixel_array = itk.GetArrayViewFromImage(image)
import gdcm
# Read DICOM file
file_reader = gdcm.ImageReader()
file_reader.SetFileName("path_to_dicom_file.dcm")
file_reader.Read()
# Access metadata and pixel data
dataset = file_reader.GetImage()
pixel_array = dataset.GetBuffer()
import os
import SimpleITK as sitk
import numpy as np
# Specify the folder containing DICOM files
folder_path = "path_to_folder_containing_dicom_files"
# Get the list of DICOM files in the folder
dicom_files = [os.path.join(folder_path, file) for file in os.listdir(folder_path) if file.endswith('.dcm')]
# Read the DICOM series
reader = sitk.ImageSeriesReader()
reader.SetFileNames(dicom_files)
image = reader.Execute()
# Convert the 3D image to a NumPy array
volume = sitk.GetArrayFromImage(image)
# Access metadata (same for all DICOM files in the folder)
first_file = dicom_files[0]
first_dataset = sitk.ReadImage(first_file)
patient_name = first_dataset.GetMetaData("PatientName")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。