Python은 RTstruct 파일을 nii 파일로 저장합니다.

배경 :
주로 의료 영상 정합을 하는데, 모델을 학습시키거나 테스트할 때 데이터셋에 있는 gold standard mask가 필요합니다. 일부 조직에서는 RTstruct 파일을 제공하는데 편의상 nii 형식으로 변환해야 합니다.

방법 :
dcmrtstruct2nii 툴킷 사용
1단계 : dcmrtstruct2nii 패키지 설치

pip install dcmrtstruct2nii 

2단계 :
공식 웹사이트 소개 사용:
공식 웹사이트 URL 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
output_path=Output 폴더 경로에 해당하는 의료 디컴 이미지의 폴더 경로입니다.

내 시도 및 결과:
내 파이썬 코드:

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_path5개의 nii 파일

image.nii가 폴더에 dicom dicom_file=root+patient_Data+'201.000000-PANCREAS DI iDose 3-97846/'에 의해 .
mask_XX.nii rtstruct_file=root+patient_Data+'1.000000-BSCBLLLRSDCB-27748/1-1.dcm'는 RTstruct 파일에서 생성됩니다.

Supongo que te gusta

Origin blog.csdn.net/qq_45384162/article/details/127672421
Recomendado
Clasificación