python获取window共享目录列表_利用Python获取DICOM RTstructure勾画列表

本文介绍如何使用Python读取Windows共享目录中的DICOM RTstructure文件,并获取勾画列表。通过修改load_scan()函数,添加条件判断t.Modality == 'RTSTRUCT',读取RTstructure文件,然后解析StructureSetROISequence下的ROIName获取勾画名称。以HNSCC_01为例展示具体操作,并提供相关文件供读者实践。
摘要由CSDN通过智能技术生成

在《利用Python打开DICOM CT文件》一文中,我们利用pydicom.dcmread()读取了CT图像。本文中我们将修改load_scan()函数来读取RTstructure文件并获取勾画列表

1. 打开Jupyter notebook,导入需要的科学包

import numpy as npimport mathimport pydicomimport osimport matplotlib.pyplot as pltimport scipy.ndimagefrom skimage import measure, draw

2. 在load_scan()加入t.Modality == 'RTSTRUCT'作为判断读取RTstructure文件

def load_scan(path):    temp = [pydicom.dcmread(path + f) for f in os.listdir(path)]    RT = [t for t in temp if t.Modality == 'RTSTRUCT']    slices = [t for t in temp if t.Modality == 'CT']    slices.sort(key = lambda x: int(x.InstanceNumber))    try:        slice_thickness = np.abs(slices[0].ImagePositionPatient[2] - slices[1].ImagePositionPatient[2])    except:        slice_thick
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值