【数据处理—医学图像】利用dcmrtstruct2nii将RTstruct文件保存为nii文件

本文分享了将RTstruct文件转换为NII格式的具体步骤与实践经验。通过使用dcmrtstruct2nii工具包,作者详细介绍了安装配置过程及转换脚本编写方法,并展示了实际运行结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景:

一些医学图像提供的金标准mask是RTstruct文件
需要将其转为nii格式
目的:方便后续在模型中实验。

方法:

利用dcmrtstruct2nii 工具包

步骤

安装dcmrtstruct2nii 包

pip install dcmrtstruct2nii 

官网介绍:

https://pypi.org/project/dcmrtstruct2nii/

代码

# lets test it
from dcmrtstruct2nii import dcmrtstruct2nii, list_rt_structs

print(list_rt_structs('/path/to/dicom/rtstruct/file.dcm'))

dcmrtstruct2nii(rtstruct_file='/path/to/dicom/rtstruct/file.dcm', 
				dicom_file='/path/to/original/extracted/dicom/files',
 				output_path='/output/path')

输入说明
rtstruct_file=待转换的RTstruct文件的文件路径
dicom_file=RTstruct对应的医学dicom图像的文件夹路径
output_path=输出文件夹路径。

我的python代码:

from dcmrtstruct2nii import dcmrtstruct2nii, list_rt_structs

root='E:\Medical imaging dataset/'
patient_Data='patient_001/07-06-2012/'
print(list_rt_structs(root+patient_Data+'1.000000-BSCBLLLRSDCB-27748/1-1.dcm'))
dcmrtstruct2nii(rtstruct_file=root+patient_Data+'1.000000-BSCBLLLRSDCB-27748/1-1.dcm',
                dicom_file=root+patient_Data+'201.000000-PANCREAS DI iDose 3-97846/',
                output_path=root+patient_Data+'1.000000-BSCBLLLRSDCB-27748/')

"""
输出如下:
['Bowel_sm_CBCT', 'LUNG_L', 'LUNG_R', 'Stomach_duo_CBCT']
代表该RTstruct文件,包含四个mask
"""

结果:

最终在output_path文件夹中得到5个nii文件

image.nii由dicom_file=root+patient_Data+'201.000000-PANCREAS DI iDose 3-97846/'中的dicom生成得到。
mask_XX.nii由rtstruct_file=root+patient_Data+'1.000000-BSCBLLLRSDCB-27748/1-1.dcm'RTstruct文件生成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值